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

bracketed paste - chopping trailing newlines


35834 adds stripping a final newline from pasted text in order to enable
distinguishing a running command from a paste.

Pasting a command with one trailing space now looks exactly like typing
the command without the trailing space, which is a very intuitive way to
prompt the user to press return to execute the command.

If the paste contains more than one trailing newline, this rationale
does not apply anymore, i.e., stripping one of these newlines does not
imply that the user should press return to execute the command.  Pasting
multiple trailing newlines can also be intentional, e.g., to build
a here document.  Therefore I think, that a trailing newline should only
be stripped if it does not immediately follow an other newline (what the
correct behaviour is if only one newline and no other character is
pasted is debatable - and the behaviour of this corner case could be
adapted for later releases).

Ideally, a stripped newline of a previous paste would be added again if
the user pastes again without acknowledging the previous paste first.
If this would be implemented, pasting $'foo\n' would result in $'foo'
and pasting $'foo\n' and $'bar\n' would result in $'foo\nbar'.

The other natural choice to enable distinguishing a running command from
a paste is using zle_highlight.  This could also avoid the need for the
possibly unexpected newline stripping feature.

Using paste:standout has been suggested, but in 36160 it has been
mentioned that region highlight already uses standout and that there
could be some problems with rendering the cursor on basic terminals.

An alternative to paste:standout is paste:underline.  Given that this
one does not suffer from similar possible problems as paste:standout,
I would prefer using paste:underline as default and dropping the
stripping of trailing newlines (using both would also be an option).

I think at least the 'only chop single newlines' change should be
implemented (this would need to check if n > 2 and to check the value of
wpaste[n-2]).  It would be great if this could already be part of zsh
5.1 in to order to minimize the behavioural changes between releases.


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