From 746b53d5d7792ebb63b638116973f32fc492787a Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Fri, 24 Oct 2014 00:18:32 +0200 Subject: 33520: correct cursor positioning following a vi mode yank operation --- ChangeLog | 3 +++ Src/Zle/zle_vi.c | 9 ++++++++- Test/X02zlevi.ztst | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 53a8ac4ab..970c45edc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2014-10-23 Oliver Kiddle + * 33520: Src/Zle/zle_vi.c, Test/X02zlevi.ztst: correct cursor + positioning following a vi mode yank operation + * unposted: .editorconfig: specify 8 char indent for ChangeLog * 33519: Src/Zle/zle_move.c, Test/X02zlevi.ztst: last character diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c index 20cece0a8..53919e361 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 b4426a8fb..d9fa0d51f 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 -- cgit 1.4.1