Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bracketed paste - chopping trailing newlines



Oliver Kiddle wrote on Sun, Sep 06, 2015 at 15:51:05 +0200:
> Daniel Shahaf wrote:
> > The behaviour is: (a) pastes are never executed until <Enter> is pressed;
> > (b) zle_highlight is set; (c) newlines are removed only at <accept-line>.
> 
> I really don't see the point of doing (c).

Several reasons:

1. So that making several pastes in a row, which each paste a single line
including a \n, will retain the newlines.  In 5.1, the newlines will be
eaten (and users might not know how to insert literal newlines "by hand"
at a place where <accept-line> would simply execute the input-so-far).

2. Cosmetic: when I have a screenful of prompts, I'd like all of them to
have the same number of empty lines between them, regardless of whether
the command was typed manually or pasted.  In other words, once I've
decided to execute the command, I'm happy to remove any trailing \n's it
may have.

3. Avoid saving trailing newlines into history.

> Perhaps the reason for
> removing newlines in the current 5.1 behaviour has got lost in all this.
> From pre-5.1, users are accustomed to pasted newlines being executed.
> With a trailing newline, it is now hard to discern that the line hasn't
> been executed: the cursor advances to the next line whether the newline
> is accepted or inserted so without the stripping the user is left
> waiting until they lose patience.

Thanks for reminding us of that.

I do agree that we shouldn't confuse users.  However, I also think that
most useful handling of pastes is to never strip newlines.  I do not
think we should be handling pastes in a suboptimal manner in order to
avoid risking confusing users.  I think we should handle pastes
optimally — which, to me, means the behaviour described in my previous
mail — and find some other way to ensure we don't confuse users.

How about trying to collect some actual data about whether or not
newline retention confuses users?  For example, we could make the
5.1-test-2 release behave as I'm suggesting, and then wait to see
whether users who test that release complain about pasted commands
hanging indefinitely.

> I think that the default behaviour
> should cater to normal users who don't follow this list.

Agreed.

> I agree that the newline stripping isn't ideal but it seemed the best
> option for the short term. And it is possible to work around it with a
> custom widget.

I'm thinking of 'zsh -f' and of the long term.  I think the behaviour
I'm proposing would make perfect sense to someone who has never pasted
into a shell in his life.

Cheers,

Daniel



Messages sorted by: Reverse Date, Date, Thread, Author