From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: smart-insert-last-word bug in zsh 5.0.7
Date: Fri, 12 Jun 2015 12:12:42 -0700 [thread overview]
Message-ID: <150612121242.ZM789@torch.brasslantern.com> (raw)
In-Reply-To: <20150612091627.GA10815@ypig.lip.ens-lyon.fr>
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
[Esc].[Left][Backspace][Ctrl-e][Space]
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
changed.
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
NUMERIC=$[_ilw_count+1]
lcursor=$_ilw_lcursor
else
@@ -116,4 +116,4 @@ fi
(( NUMERIC > $#lastcmd )) && return 1
LBUFFER[lcursor+1,cursor+1]=$lastcmd[-NUMERIC]
-_ilw_cursor=$CURSOR
+_ilw_changeno=$UNDO_CHANGE_NO
next prev parent reply other threads:[~2015-06-12 19:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-12 9:16 Vincent Lefevre
2015-06-12 19:12 ` Bart Schaefer [this message]
2015-06-13 16:52 ` Peter Stephenson
2015-06-13 18:23 ` Bart Schaefer
2015-06-15 2:47 ` Bart Schaefer
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=150612121242.ZM789@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--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).