From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19607 invoked by alias); 12 Aug 2015 14:32:52 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36125 Received: (qmail 29656 invoked from network); 12 Aug 2015 14:32:49 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 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== X-Yahoo-Newman-Id: 219505.65238.bm@smtp113.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: .gK8s1EVM1lRhLXlZ8KcaJnV0KFcHnLR3vGKsrsZKkhfPh. MhK0YpL72Ipeh4cAVFGRr8HE0KtHV_sviCXwrJDaWCIkfBS0QsU85pOHXCGD 8HoQgfRuMQcw2XhZmfAbQyqeu_inc2G6Vi7EyRP6PNn_gonTm8Iv6PwOHH05 2cBOeg338EItQMOfY8uPpb7flR9QavqQfxRmasJhaMXvIiUafHEWAx9FlRfc BiTTPVVWRc4CJ33UcZaP5iLVqUzVsVRjZIaNePDPMidAK8SgUsOuFNEk5ymR OOso4vvHZ9CRtLUa0RtTxqGFepvnM5HzHsbXCi6Keywc.fd.nHffs1tWA7dN CP4U45.XlWXGd6ApRIF4OxaKUkpjnoW_Ofgfm37wkMs1Z4GEgOAI3IE7EilB 1QvmJIsmdmf82465AwTRgYL0Bq2AE7JYGfXIRwl8T9v_RPNFgf_AzPeU33pt xWQgIQTrv8.DbgUUfXDhhH1D7.XK0khgykZGPOUUkMyzaEBGzwlVZhGsbMxu yIeE9TFzs0GAP85TzbBaPAdpgpvVa5g-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- From: Oliver Kiddle To: Zsh workers Subject: PATCH: get-line shouldn't set histline MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3786.1439389607.1@thecus.kiddle.eu> Date: Wed, 12 Aug 2015 16:26:47 +0200 Message-ID: <3787.1439389607@thecus.kiddle.eu> 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; }