Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: get-line shouldn't set histline
- X-seq: zsh-workers 36125
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: get-line shouldn't set histline
- Date: Wed, 12 Aug 2015 16:26:47 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1439389608; bh=Z5pyvvAK/Z83DfFjhEjCk8C5G0fInf1kMz4Xz1/zQSw=; h=From:To:Subject:Date:From:Subject; b=hX2Dh4j+y9k80AuEcVSxAUbfe+g/QypKvVG6/QkLQIuzaCIWAa+/mT8QAbVDY6n5lA3nxgp23Tiq8rnFayhCk8jtbB0uB07ybEoITL8aDJejePBvlT8q4LL+DSSlMvx15ZrpNZgJ/h0oMf037U4ktwKJpt15Gm7pOaoAzF/atGl1LWDtXyZUukf1DqTwS092nm9LN1KP2/7kEsrJQeMHRRfK2JH3QZYlAy8uUmRS6zq0Wb/aRmRH2SCyEJePzSJKDzH+u1eeNiGJe0T3bZJszaiOAjhRxhEMzsMRyEtszjisSg7Cpf8f2lceJu4NAeUeH8T1XA2YyuZtZsXd8d2/Uw==
- 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
Using narrow-to-region modified to use undo to take advantage of the
undo limits, I'm finding issues related to the way undo handles separate
history lines. The following is one such case. The get-line widget is
meant to insert the line from the buffer stack into the current line.
Changing histline without setting the line to correspond to the text
stored for the history entry results in undo information that doesn't
make sense.
To put this into context, I've also included the function I have bound
to Ctrl-R below. Note the use of get-line towards the end. I don't
really use get-line directly anymore as narrow-to-region tends to be an
easier way to collect past history lines together in a new line. Can
anyone see how the change might cause a problem for normal get-line
usage?
Oliver
local left right
if [[ -n $PREDISPLAY || -z $BUFFER ]]; then
zle .$WIDGET
else
zle .vi-add-next
while true; do
(( MARK )) || MARK=CURSOR
if ((MARK < CURSOR)); then
left="$LBUFFER[0,MARK-CURSOR-1]"
right="$RBUFFER"
else
left="$LBUFFER"
right="$BUFFER[MARK+1,-1]"
fi
narrow-to-region -p "$left"$'\u25b8' -P $'\u25c0'"$right"
if [[ $WIDGET = accept-line-and-down-history ]]; then
LBUFFER+=$'\n'"${(M)${LBUFFER##[^$'\n']#?}##[[:blank:]]#}"
(( MARK = CURSOR ))
zle split-undo
zle get-line
else
MARK=-1
break
fi
done
fi
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index ffb7ce9..c61b4ef 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -894,10 +894,8 @@ zgetline(UNUSED(char **args))
free(s);
free(lineadd);
clearlist = 1;
- if (stackhist != -1) {
- histline = stackhist;
- stackhist = -1;
- }
+ /* not restoring stackhist as we're inserting into current line */
+ stackhist = -1;
}
return 0;
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author