zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: wayne@opencoder.net
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: A weird smart-insert-last-word bug
Date: Fri, 2 Nov 2018 17:37:34 -0700	[thread overview]
Message-ID: <CAH+w=7aRaOb2b1m+gcicTq7BgP=5DzZgwWYG+XGz7m3Od9-YHg@mail.gmail.com> (raw)
In-Reply-To: <CAHSx_SuJv+dsGYbS2YO0ZUdmO6YGtVXjWHgFNhbnStwKk8mHCQ@mail.gmail.com>

On Fri, Nov 2, 2018 at 5:03 PM Wayne Davison <wayne@opencoder.net> 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

  reply	other threads:[~2018-11-03  0:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-03  0:03 Wayne Davison
2018-11-03  0:37 ` Bart Schaefer [this message]
2018-11-08  1:58   ` Wayne Davison

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7aRaOb2b1m+gcicTq7BgP=5DzZgwWYG+XGz7m3Od9-YHg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=wayne@opencoder.net \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).