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

Re: smart-insert-last-word bug in zsh 5.0.7

On Jun 12, 11:16am, Vincent Lefevre wrote:
} Subject: smart-insert-last-word bug in zsh 5.0.7
} ypig% autoload -U smart-insert-last-word
} ypig% zle -N insert-last-word smart-insert-last-word
} ypig% echo abc def
} abc def
}   echo [Esc].[Left][Backspace][Ctrl-e] [Esc].
} The second [Esc]. should have given:
}   echo df def[ ]
} like without smart-insert-last-word.

So the problem here is that smart-insert-last-word is using the cursor
position as a clue for whether it should start the search over, or look
farther up the history.  This is still true in 5.0.8.

When you do


you change the line, but then return the cursor to its previous offset.
smart-insert-last-word thinks this means it should pick up where it left
off, because neither the history number nor the cursor position have

Now that we have UNDO_CHANGE_NO, that's probably a better way to track
the state, but maybe someone can find a different problem with that?

diff --git a/Functions/Zle/smart-insert-last-word b/Functions/Zle/smart-insert-last-word
index 27b0849..5288c1d 100644
--- a/Functions/Zle/smart-insert-last-word
+++ b/Functions/Zle/smart-insert-last-word
@@ -47,13 +47,13 @@ setopt extendedglob nohistignoredups
 zle auto-suffix-retain
 # Not strictly necessary:
-# (($+_ilw_hist)) || integer -g _ilw_hist _ilw_count _ilw_cursor _ilw_lcursor
+# (($+_ilw_hist)) || integer -g _ilw_hist _ilw_count _ilw_changeno _ilw_lcursor
 integer cursor=$CURSOR lcursor=$CURSOR
 local lastcmd pattern numeric=$NUMERIC
 # Save state for repeated calls
-if (( HISTNO == _ilw_hist && cursor == _ilw_cursor )); then
+if (( HISTNO == _ilw_hist && UNDO_CHANGE_NO == _ilw_changeno )); then
@@ -116,4 +116,4 @@ fi
 (( NUMERIC > $#lastcmd )) && return 1

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