summary refs log tree commit diff
path: root/Functions/Zle/smart-insert-last-word
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 /Functions/Zle/smart-insert-last-word
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
Diffstat (limited to 'Functions/Zle/smart-insert-last-word')
-rw-r--r--Functions/Zle/smart-insert-last-word5
1 files changed, 3 insertions, 2 deletions
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