Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: fix ancient bug with empty lines
- X-seq: zsh-workers 33639
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: fix ancient bug with empty lines
- Date: Sat, 08 Nov 2014 00:57:32 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1415404653; bh=XWpRQ/PgFkX3q5zY9TBtoWCtiTtBVFmaGsTOmjAnSRU=; h=From:To:Subject:Date:From:Subject; b=eHE69p7XAkZTMUrvrbKJMcG1yjRnokmnidCMp2o+Ar/hFikygLNK9E5k6Jn1hYeDQG0T6YfE7nZoASJ8QRYi/E/47/acKl+wnxKtdTu5+fsKMcg2e1syR6pk/CLo6sQZoPvRugGIq6M1VxjYCSWCK1PsqhL9LuugAQLWeB5FyOeenlHzTCAAFDkDbywnJ76hIQoztvtEvt4pttxgSzSNWvnIWoF86Lx7IJAEx669KFg0i0HZOZ6j7IO/TYsyycN5YgYh33Ca4v/AEx1O/ym12tMxbBRNabQO/iNUwLE8o27dsPc0q1WwS+iSku3hE7/n7XkahLH3DhzJEhFhN8XVMw==
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=yahoo.co.uk; b=kTaHx8tQdsDCkdcE2cnYplI0flDzILbS5T35POJU3nhsVaqG+4aQzy1vFyxnovlPvmYDUwUS7wVsykXiEnctK8RwS1acQAk6MPEFPWj9eurgqSXA14vuYRuRwh3F7IzyMgtSe7kdcLa7RnnglOeq0BohDn7c2Ms8szdwnboPzzi7znt9a6+Xm+yAiJJdt+u9HPuKBMJN/QVjZ3U6o40XqDk60CTPOc94Go6aYl7kezh2WNNqeHlqX42JxEHoM/JWYYeNvvwte06QEGAAenKRnL0Ev4zDkApBMTDEnZnXzY7sirW6d4vvjEyHcspw7OE6/GN+yL89JQNOheHjpsCWHw==;
- 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
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author