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

Re: [BUG] insert-last-word gets stuck at comments



On Mon, Jul 26, 2021 at 03:50:17PM -0700, Bart Schaefer wrote:
On Mon, Jul 26, 2021 at 12:07 AM Frederick Eaton <frederik@xxxxxxx> wrote:

This may be a somewhat minor bug, but I think that when
interactive_comments is set, the 'insert-last-word' widget gets stuck
on lines that are fully commented:

I'm able to reproduce this.  A fully-commented line has an event
number but contains no words; e.g., it's also an "error" to attempt to
refer to event number 3 e.g. with !3 in the example:

     $ zsh -f -i
     % setopt interactive_comments
     % echo hi #comment
     hi
     % # blah blah
     % echo bye #comment
     bye
     % echo foo
     foo
     % echo <Esc>.<Esc>.<Esc>.

At this point:

% !3
zsh: no such word in event

Even though !2 and !4 work as expected.  So insert-last-word gets as
far as event 3 and then gets the no-such-word error, which interrupts
it.

A workaround is to enable smart-insert-last-word.

I've read the documentation for insert-last-word and
smart-insert-last-word and I can't figure out how they are different.
In the manual page, under 'smart-insert-last-word', it says:

              With a numeric argument, or when passed command  line  arguments
              in a call from another widget, it behaves like insert-last-word,
              except that words in comments are ignored when  INTERACTIVE_COM-
              MENTS is set.

So they are the same when interactive_comments is not set? However,
according to my experiments it seems that insert-last-word also
ignores comments when interactive_comments is set, so I am not able to
understand the difference.

Maybe someday someone will send a patch to fix insert-last-word to
work as described in the documentation?




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