From 16cfa78aa98da19f5928dd6bd036705096017815 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Wed, 29 Oct 2014 13:34:37 +0100 Subject: 33528: take notice of last column position when using vi-yank and an upward cursor movement --- Src/Zle/zle_vi.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'Src/Zle/zle_vi.c') diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c index 53919e361..0a8b27d65 100644 --- a/Src/Zle/zle_vi.c +++ b/Src/Zle/zle_vi.c @@ -248,6 +248,7 @@ getvirange(int wf) * point we just need to make the range encompass entire lines. */ if(vilinerange) { int newcs = findbol(); + lastcol = zlecs - newcs; zlecs = pos; pos = findeol(); zlecs = newcs; @@ -348,6 +349,7 @@ videlete(UNUSED(char **args)) forekill(c2 - zlecs, CUT_RAW); ret = 0; if (vilinerange && zlell) { + lastcol = -1; if (zlecs == zlell) DECCS(); foredel(1, 0); @@ -449,7 +451,7 @@ vichangewholeline(char **args) int viyank(UNUSED(char **args)) { - int oldcs = zlecs, c2, ret = 1; + int c2, ret = 1; startvichange(1); if ((c2 = getvirange(0)) != -1) { @@ -459,11 +461,19 @@ viyank(UNUSED(char **args)) vichgflag = 0; /* 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; + if (vilinerange && lastcol != -1) { + int x = findeol(); + + if ((zlecs += lastcol) >= x) { + zlecs = x; + if (zlecs > findbol() && invicmdmode()) + DECCS(); } +#ifdef MULTIBYTE_SUPPORT + else + CCRIGHT(); +#endif + lastcol = -1; } return ret; } -- cgit 1.4.1