summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@zsh.org>2019-07-08 18:01:38 -0700
committerBart Schaefer <schaefer@zsh.org>2019-07-08 18:01:38 -0700
commitcf66eb7adbff8284a66bccd013c30120fa3ad695 (patch)
treef023b1bbcc428aae1a8a0e473866dd801af7ac18
parent5415e1d4df68a759d5b5c3ca65c5e7b3c7c8cfb1 (diff)
downloadzsh-cf66eb7adbff8284a66bccd013c30120fa3ad695.tar.gz
zsh-cf66eb7adbff8284a66bccd013c30120fa3ad695.tar.xz
zsh-cf66eb7adbff8284a66bccd013c30120fa3ad695.zip
43755: Fix state management for repeat uses to avoid clobbering command line when NOT a repeat
-rw-r--r--ChangeLog4
-rw-r--r--Functions/Zle/smart-insert-last-word5
2 files changed, 7 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index a73ab744c..ab663ccf5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2019-07-08  Bart Schaefer  <schaefer@brasslantern.com>
 
+	* 43755: Functions/Zle/smart-insert-last-word: (Belated commit)
+	Fix state management for repeat uses to avoid clobbering command
+	line when NOT a repeat
+
 	* 44502: Src/builtin.c: Quote function name for "autoload -X"
 
 	* 44495: Doc/Zsh/params.yo: Mention coproc under $!
diff --git a/Functions/Zle/smart-insert-last-word b/Functions/Zle/smart-insert-last-word
index cf8715dfe..05f23cba6 100644
--- a/Functions/Zle/smart-insert-last-word
+++ b/Functions/Zle/smart-insert-last-word
@@ -48,13 +48,14 @@ zle auto-suffix-retain
 
 # Not strictly necessary:
 # (($+_ilw_hist)) || integer -g _ilw_hist _ilw_count _ilw_cursor _ilw_lcursor _ilw_changeno
+# (($+_ilw_result)) || typeset -g _ilw_result
 
 integer cursor=$CURSOR lcursor=$CURSOR
 local lastcmd pattern numeric=$NUMERIC
 
 # Save state for repeated calls
 if (( HISTNO == _ilw_hist && cursor == _ilw_cursor &&
-      UNDO_CHANGE_NO == _ilw_changeno ))
+      UNDO_CHANGE_NO == _ilw_changeno )) && [[ $BUFFER == $_ilw_result ]]
 then
     NUMERIC=$[_ilw_count+1]
     lcursor=$_ilw_lcursor
@@ -119,7 +120,7 @@ fi
 (( NUMERIC > $#lastcmd )) && return 1
 
 LBUFFER[lcursor+1,cursor+1]=$lastcmd[-NUMERIC]
-typeset -g _ilw_cursor=$CURSOR
+typeset -g _ilw_cursor=$CURSOR _ilw_result=$BUFFER
 
 # This is necessary to update UNDO_CHANGE_NO immediately
 zle split-undo && typeset -g _ilw_changeno=$UNDO_CHANGE_NO