Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: cursor position after vi yank
- X-seq: zsh-workers 33520
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: cursor position after vi yank
- Date: Fri, 24 Oct 2014 00:06:30 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1414101991; bh=XVCzo7WSc1sUqlrQWz8JUzkyPIxpGFpn3rQ7Nczvn+0=; h=From:To:Subject:Date:From:Subject; b=oYdCpi5pimArgcsyMwB5bKngeN43OJqVq8DracTbu8kgu+vOW2L/t0xpbKwhW5iOg03Q7tMbLTjwFcuZSV1879PqOwyj+c8YjieCyHSyXgN5QCIsW1qmDxjtwpQl9muksq/DTZNJRsSMW46Li5+Pa09J0IGJS6Q7Up7Y1yrBRvnUeMe7+eTQzkFBUTgPq5OER3OS+bGa2v1tTAs1g7/5DoI/+5JWdRtX8TYSd7nsrF/pcnEYfAcu+MI0cc91Cuv4rW3T3yah51rowD/d9mOl6MtTAN1FOPDcXacrg2l9Vo089nAvgVpYdFMTX+UyTlI85Sy80WRu1SrZI39LVjQF8g==
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=yahoo.co.uk; b=jKq1L05PZCxtG8kZ6aQya5c/crJmxvq4pCZAtrU/XXSgGID0ajwYJRWZhRNQEr7G/vOfQwmUE2iIrdB/QAuI+m2qkcbvlnz6yNFrbXv0Pcuwk5CFKgkyWFVVqw7nZ7Qc/ks2AbHWQlTUQ3r9KacpaCLiwpUREgQb3h1I+rs9po5kvJ1uQaAEHivaf9aTNZdofqPm+Kv9gweydY9sHjXOlMvCuZSkPuA8UECULiYUmmEEchyG0N3cW+6WAI9oHW6NbAuWaz+NTo67RutQFC7ly+bFNU7jtsxyFHHz3dB2zMN3oWd+1AaFm2SgkI432pBjUPqT4cgwPh/IQ8i1gPJmHQ==;
- 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
When producing the test cases, I noticed that zsh is not quite matching
vi in terms of cursor positioning after a yank. This fixes that.
Oliver
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index 20cece0..53919e3 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -457,7 +457,14 @@ viyank(UNUSED(char **args))
ret = 0;
}
vichgflag = 0;
- zlecs = oldcs;
+ /* cursor now at the start of the range yanked. For line mode
+ * restore the column position */
+ if (vilinerange) {
+ while (oldcs > 0 && zleline[oldcs - 1] != ZWC('\n') &&
+ zlecs != zlell && zleline[zlecs] != ZWC('\n')) {
+ ++zlecs; --oldcs;
+ }
+ }
return ret;
}
diff --git a/Test/X02zlevi.ztst b/Test/X02zlevi.ztst
index b4426a8..d9fa0d5 100644
--- a/Test/X02zlevi.ztst
+++ b/Test/X02zlevi.ztst
@@ -15,6 +15,28 @@
>BUFFER: good
>CURSOR: 4
+ zletest $'one two\eyb'
+0:yank left moves the cursor
+>BUFFER: one two
+>CURSOR: 4
+
+ zletest $'one two\e0ye'
+0:yank right leaves the cursor
+>BUFFER: one two
+>CURSOR: 0
+
+ zletest $'short\eoand longer\eyk'
+0:yank up line moves cursor up but not to buffer start
+>BUFFER: short
+>and longer
+>CURSOR: 4
+
+ zletest $'one\eotwo\ekyj'
+0:yank down line leaves the cursor
+>BUFFER: one
+>two
+>CURSOR: 2
+
zletest $'yankee doodle\ebhDyy0"1P'
0:paste register 1 to get last deletion
>BUFFER: doodleyankee
Messages sorted by:
Reverse Date,
Date,
Thread,
Author