Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Regression in bracketed-paste-magic (not in 5.2, but affects 5.3's test releases)
- X-seq: zsh-workers 40118
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zhiming Wang <zmwangx@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Regression in bracketed-paste-magic (not in 5.2, but affects 5.3's test releases)
- Date: Wed, 07 Dec 2016 13:39:51 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1481114392; bh=wnuHWeKvt9gPtpoFNYTGQbIbowI7ukuIPIeVa6JOfEA=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=jjxopaBf5z5JEPunUZeR47YGux0Oi3haTa4uxNvspjsJN4LroiMfFIOnNAIwWwIHrqFq/Vp8CseUYipG9lpCxUFaGPCL9rPkSPBUc1ZB3xkMma8nO0cytTzP0qrJchgI57D3Fp0hoCAtvtAaFmlx1KFGWzIOsjThPs+CZBoV3BesGvATogab2Iv3hmlSOjq8qS11ryFwfnY0ogM6GPZvCfroiXOL3DlUwYsj+YFcASDTSysf4RQvHvRrMivfFHxYlb/JlGoNAIBSfNdDx9CbyWupVWK8r/6+gzW2s4c+jE/RQZVUjtT5nerLv+hS0hUZNk9w1bT23X2aG85Q80dNAw==
- In-reply-to: <CAH+w=7ZbZdfN7rhXQ-yi4_kqyjyAv1w8B7hKi55TPEBnc5Yfvg@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>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <B3CEC842-B789-472A-8C8B-89391950787A@gmail.com> <CAH+w=7ZbZdfN7rhXQ-yi4_kqyjyAv1w8B7hKi55TPEBnc5Yfvg@mail.gmail.com>
Bart wrote:
> This probably indicates a problem with undo-point handling around history
> search, which has been a sticky wicket in the past. The patch you cite
> replaced b-p-m's internal handling of $BUFFER with reliance on the undo
> mechanism.
In this particular case, the problem is that fc -p doesn't result
in a call to zle's remember_edits(). remember_edits() updates the
table of history entries for the current line. The edit associated
with doing BUFFER= CURSOR=1 is thus lost. So when it does the
undo, the line is first restored when the history line is reselected
and then the contents are duplicated when the effect of clearing
$BUFFER is undone.
Unfortunately, the ZLE_CMD_SET_HIST_LINE callback happens after this
history line is updated so we can't call remember_edits() from there.
We could simply add another similar hook and call it earlier.
What I would suggest for 5.3 is the patch below. fc -p doesn't
trigger handleundo() either so by moving split-undo above the
clearing of the buffer, we ensure that the edit is missed by both
the undo and history. Referencing $UNDO_CHANGE_NO does force
handleundo() so the downside of this is that UNDO_LIMIT_NO will
allow an undo back to the state before clearing $BUFFER.
If you're wondering why I suggest this rather than adding a hook
to call remember_edits(), it is because, for a proper post-5.3
patch, fc -p wouldn't actually change the current history line. The
only thing that changes is the history number. If history internals
use the Histent to identify history entries then undo wouldn't see
fc -p/-P as a change of history line and we could kill the associated
bugs. I've got some unfinished work on this on a git branch if
someone's interested to play with it. But for now, calling fc -p
in a widget is going to get you undo oddities.
I don't use bracketed-paste-magic so would appreciate if someone
else could do some testing and make the call on what should go into
5.3.
Oliver
diff --git a/Functions/Zle/bracketed-paste-magic b/Functions/Zle/bracketed-paste-magic
index fb584d5..c3cc8b6 100644
--- a/Functions/Zle/bracketed-paste-magic
+++ b/Functions/Zle/bracketed-paste-magic
@@ -151,10 +151,10 @@ bracketed-paste-magic() {
integer bpm_mark=$MARK bpm_region=$REGION_ACTIVE
integer bpm_numeric=${NUMERIC:-1}
integer bpm_limit=$UNDO_LIMIT_NO bpm_undo=$UNDO_CHANGE_NO
- BUFFER=
- CURSOR=1
zle .split-undo
UNDO_LIMIT_NO=$UNDO_CHANGE_NO
+ BUFFER=
+ CURSOR=1
fc -p -a /dev/null 0 0
if [[ $bmp_keymap = vicmd ]]; then
zle -K viins
Messages sorted by:
Reverse Date,
Date,
Thread,
Author