summaryrefslogtreecommitdiff
path: root/Src/Zle/zle_vi.c
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2014-10-29 13:34:37 +0100
committerOliver Kiddle <opk@zsh.org>2014-10-29 13:34:37 +0100
commit16cfa78aa98da19f5928dd6bd036705096017815 (patch)
treef61ac2c2a4d44fa069fb3b064c11e8d77d9c7917 /Src/Zle/zle_vi.c
parented90154e58d2bd9a5e91fa430a14f55f78376861 (diff)
downloadzsh-16cfa78aa98da19f5928dd6bd036705096017815.tar.gz
zsh-16cfa78aa98da19f5928dd6bd036705096017815.zip
33528: take notice of last column position when using vi-yank
and an upward cursor movement
Diffstat (limited to 'Src/Zle/zle_vi.c')
-rw-r--r--Src/Zle/zle_vi.c20
1 files changed, 15 insertions, 5 deletions
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;
}