Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: A weird smart-insert-last-word bug
- X-seq: zsh-workers 43755
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: wayne@xxxxxxxxxxxxx
- Subject: Re: A weird smart-insert-last-word bug
- Date: Fri, 2 Nov 2018 17:37:34 -0700
- Cc: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=i4i0JKa0528kBhhUpdQV4Z2SG7kM+QhYLzMfDvVzdIc=; b=TGS1hSXuwheG6k+VxvPmaENPYOlTgZ9JfsWkQ5/EFRtH4VG7ExkrNuEd1oA/kzGSBc 8r5P9BUXbSTjRnuqgm42twdGXenqkQe+8zqvZQ5nND+EOb6kHG082K//tabWXZo7NwLp mKDQZX/e+Tpy5mYSY7Q6RicASxjlEkU/CqUQG1ZjJwwKhUcs1iRIjACS4w6Pdw4Wc4l1 oglDH9Dwv9p05GBtFOCwdTLzU7/5inghOu62c1icskzanas255npF2Q/4kcQIz5tqVdY dlT9hBpHPI5eBr26qm0VKix/oEpxliI8joJxwNMU4cA72At+uQDR/AXFb2X4qZPW30b1 P9IQ==
- In-reply-to: <CAHSx_SuJv+dsGYbS2YO0ZUdmO6YGtVXjWHgFNhbnStwKk8mHCQ@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAHSx_SuJv+dsGYbS2YO0ZUdmO6YGtVXjWHgFNhbnStwKk8mHCQ@mail.gmail.com>
On Fri, Nov 2, 2018 at 5:03 PM Wayne Davison <wayne@xxxxxxxxxxxxx> wrote:
>
> I make use of smart-insert-last-word like this:
>
> zlewidget '' insert-last-word smart-insert-last-word
Sorry, what is "zlewidget" exactly?
> Every now and then it destroys some part of the command line when starting
> a new insert sequence. This seems to be caused by its simple conditional
> at the start of its file being inadequate
Does this help? (Apologies if lines wrap)
diff --git a/Functions/Zle/smart-insert-last-word
b/Functions/Zle/smart-insert-last-word
index cf8715d..05f23cb 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author