zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh workers <zsh-workers@zsh.org>
Subject: PATCH: fix ancient bug with empty lines
Date: Sat, 08 Nov 2014 00:57:32 +0100	[thread overview]
Message-ID: <15753.1415404652@thecus.kiddle.eu> (raw)

I wrote:
> There's an existing old bug with blank lines: dd on a blank line doesn't
> work. It works in 3.0.8 but not in 4.2.1.

It was broken early in the 3.1 branch, definitely before 1997.

The problem is that virangeflag was being reset. This will have been
done so some of the up-line-or-history style commands can tell whether
they're being used from vi operators. Unfortunately this was done too
early losing values being passed back. For empty lines, the value of 2
indicates that getvirange should accept the lack of movement because the
empty line is being selected. Furthermore, a value of -1 is used for
vi-match-bracket to indiciate that a cursor adjustment is required. This
was also broken: a backward movement with % was missing one character.

It is still broken for yy. This is a separate problem: we want to cut
zero bytes but set CUTBUFFER_LINE. I'm not sure how to fix that exactly.

Oliver

diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index d74b40d..a60caa2 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -202,7 +202,6 @@ getvirange(int wf)
 	    zmult = mult1 * zmod.tmult;
     } while(prefixflag && !ret);
     wordflag = 0;
-    virangeflag = 0;
 
     /* It is an error to use a non-movement command to delimit the *
      * range.  We here reject the case where the command modified  *
@@ -222,14 +221,9 @@ getvirange(int wf)
     /* vi-match-bracket changes the value of virangeflag when *
      * moving to the opening bracket, meaning that we need to *
      * change the *starting* position.                        */
-    if(virangeflag == -1)
-    {
-	int origcs = zlecs;
-	zlecs = pos;
-	INCCS();
-	pos = zlecs;
-	zlecs = origcs;
-    }
+    if (virangeflag == -1)
+	INCPOS(pos);
+    virangeflag = 0;
 
     /* Get the range the right way round.  zlecs is placed at the *
      * start of the range, and pos (the return value of this   *
diff --git a/Test/X02zlevi.ztst b/Test/X02zlevi.ztst
index 561a5fd..7e5385b 100644
--- a/Test/X02zlevi.ztst
+++ b/Test/X02zlevi.ztst
@@ -15,6 +15,21 @@
 >BUFFER: good
 >CURSOR: 4
 
+  zletest $'{ ({[}]) }\e0c%chg'
+0:change forward to matching bracket
+>BUFFER: chg
+>CURSOR: 3
+
+  zletest $'s( match )\ed%'
+0:delete backwards to matching bracket
+>BUFFER: s
+>CURSOR: 0
+
+  zletest $'one\eo\edd'
+0:delete empty line
+>BUFFER: one
+>CURSOR: 0
+
   zletest $' four\eO\C-v\tthree\eO  two\eOone\e3J'
 0:join lines with line count
 >BUFFER: one two three


             reply	other threads:[~2014-11-07 23:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-07 23:57 Oliver Kiddle [this message]
2014-11-11  0:15 ` Oliver Kiddle

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=15753.1415404652@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --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).