From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4319 invoked by alias); 18 Aug 2015 03:43:08 -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: 36212 Received: (qmail 29628 invoked from network); 18 Aug 2015 03:43:07 -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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=olGZOLtdOxH0rSZmRx64pb3/a600Kg+kazWxWt2sCow=; b=db2L2hhN1GCZoRh4AYYV3E6NU1IYUxv5Rvpv4JMWk0y8kTuxf5WXbIb/LVZFpmbtso FkwDWePRDYgp43afl+OeImmoQ4ItPH/7elCEDSnO5ASbxGFhKyeIMl7DOK6kPYi4rq5X 1Q6kFqJBq0qgq8QFhY1nWsoBFer6MKdjEd6g7ByVcMcXPKx1lhUl3HHTZ4ZMWTO1Pbik qiQIINeYh3omaXHDcPUZx4mE2vR3XW2ZXv5UQvEQ3GbbE8PLYyW2lIm8IDnH1QHCSUDm KvF8AaKWuTFE0t1u0KJEq8kXsh/W47j5QJl1T9+yJ34SkjtVYOZa9a52zX8RVCyNUagM hlVA== X-Gm-Message-State: ALoCoQnCdyX1Ee05uwfbVjV/xRPkzWkETuYSAD7SeoLrtm/Ve54JSVKqy7UqO/9efi4ENHa8ZoG2 X-Received: by 10.60.52.110 with SMTP id s14mr3939182oeo.14.1439869385925; Mon, 17 Aug 2015 20:43:05 -0700 (PDT) From: Bart Schaefer Message-Id: <150817204302.ZM28285@torch.brasslantern.com> Date: Mon, 17 Aug 2015 20:43:02 -0700 In-Reply-To: <150817145829.ZM27968@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Re: PATCH: Re: Undo and narrow-to-region (was ...)" (Aug 17, 2:58pm) References: <150620102144.ZM5618@torch.brasslantern.com> <150718164224.ZM4759@torch.brasslantern.com> <19747.1437278114@thecus.kiddle.eu> <150719012304.ZM18439@torch.brasslantern.com> <9927.1437383950@thecus.kiddle.eu> <150722224101.ZM14105@torch.brasslantern.com> <29489.1438011895@thecus.kiddle.eu> <6736.1439398803@thecus.kiddle.eu> <55D24EDF.1060202@thequod.de> <150817145829.ZM27968@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "Zsh Hackers' List" Subject: Re: PATCH: Re: Undo and narrow-to-region (was ...) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Aug 17, 2:58pm, I wrote: } } Oliver may not be able to get to this for a while. Is it possible for } you to try reverting just the change to the narrow-to-region shell code } and see if that fixes things, or if both the shell and C code changes } need to be reverted? I was able to reproduce the broken behavior with 832130c and then back that out to determine that Daniel's example works correctly with the previous version of narrow-to-region. Oliver said: > This is still not perfect with history changes. In fact it's actually horribly broken with respect to history changes, at least with -R / -S, as far as I can tell ... In Daniel's example, we start with BUFFER='', record $UNDO_CHANGE_NO, wander about in the history a bit, then do "zle undo $_ntr_changeno" with the expectation that will return us to the previous state, that is, an empty BUFFER. But it doesn't. It mostly works as long as BUFFER isn't empty when $UNDO_CHANGE_NO is saved. This goes back to Oliver's grumbling that undo decides what to do based on whether the text on the line matches the text at the undo point, In this case there is no text at the undo point, so anything will match and nothing gets undone. The following brute-forces the history back to the same line where the undo point was set before performing the undo. This works for Daniel's example but I have no idea what it will do for other cases. It can't make things any worse, in theory. diff --git a/Functions/Zle/narrow-to-region b/Functions/Zle/narrow-to-region index 0ef28a8..261d821 100644 --- a/Functions/Zle/narrow-to-region +++ b/Functions/Zle/narrow-to-region @@ -32,7 +32,7 @@ setopt localoptions noshwordsplit noksharrays local _ntr_newbuf _ntr_lbuf_return _ntr_rbuf_return local _ntr_predisplay=$PREDISPLAY _ntr_postdisplay=$POSTDISPLAY -integer _ntr_savelim=UNDO_LIMIT_NO _ntr_changeno +integer _ntr_savelim=UNDO_LIMIT_NO _ntr_changeno _ntr_histno=HISTNO integer _ntr_start _ntr_end _ntr_swap _ntr_cursor=$CURSOR _ntr_mark=$MARK integer _ntr_stat @@ -108,7 +108,7 @@ if [[ -n $_ntr_save || -z $_ntr_restore ]]; then builtin typeset -ga $_ntr_save set -A $_ntr_save "${_ntr_predisplay}" "${_ntr_postdisplay}" \ "${_ntr_savelim}" "${_ntr_changeno}" \ - "${_ntr_start}" "${_ntr_end}" || return 1 + "${_ntr_start}" "${_ntr_end}" "${_ntr_histno}" || return 1 fi BUFFER=${BUFFER[_ntr_start+1,_ntr_end]} @@ -135,13 +135,15 @@ if [[ -n $_ntr_restore || -z $_ntr_save ]]; then _ntr_savelim="${${(@P)_ntr_restore}[3]}" _ntr_changeno="${${(@P)_ntr_restore}[4]}" _ntr_start="${${(@P)_ntr_restore}[5]}" - _ntr_end="${${(@P)_ntr_restore}[6]}" }; then + _ntr_end="${${(@P)_ntr_restore}[6]}" + _ntr_histno="${${(@P)_ntr_restore}[7]}" }; then zle -M Failed. >&2 return 1 fi fi _ntr_newbuf="$BUFFER" + HISTNO=_ntr_histno zle undo $_ntr_changeno PREDISPLAY=$_ntr_predisplay POSTDISPLAY=$_ntr_postdisplay -- Barton E. Schaefer