about summary refs log tree commit diff
path: root/Src/Zle
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2014-11-17 00:44:26 +0100
committerOliver Kiddle <opk@zsh.org>2014-11-17 00:49:32 +0100
commit25cc978a99aae07604f4c84dd2e82d3669c2c61c (patch)
tree492a6ae2a3921c67e1c0c3c107cb24c25b951f82 /Src/Zle
parent15fc2cd4f09a63ab9aa15f61e9724ffbd8ab8a89 (diff)
downloadzsh-25cc978a99aae07604f4c84dd2e82d3669c2c61c.tar.gz
zsh-25cc978a99aae07604f4c84dd2e82d3669c2c61c.tar.xz
zsh-25cc978a99aae07604f4c84dd2e82d3669c2c61c.zip
33633: support vim style text objects
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/zle_vi.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index a7e8a70cc..c3a9e75aa 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -161,12 +161,13 @@ vigetkey(void)
 static int
 getvirange(int wf)
 {
-    int pos = zlecs, ret = 0;
+    int pos = zlecs, mpos = mark, ret = 0;
     int mult1 = zmult, hist1 = histline;
     Thingy k2;
 
     virangeflag = 1;
     wordflag = wf;
+    mark = -1;
     /* use operator-pending keymap if one exists */
     Keymap km = openkeymap("viopp");
     if (km)
@@ -191,6 +192,7 @@ getvirange(int wf)
 		k2 == Th(z_sendbreak)) {
 	    wordflag = 0;
 	    virangeflag = 0;
+	    mark = mpos;
 	    return -1;
 	}
 	/*
@@ -214,13 +216,16 @@ getvirange(int wf)
 	histline = hist1;
 	ZS_memcpy(zleline, lastline, zlell = lastll);
 	zlecs = pos;
+        mark = mpos;
 	return -1;
     }
 
     /* Can't handle an empty file.  Also, if the movement command *
      * failed, or didn't move, it is an error.                    */
-    if (!zlell || (zlecs == pos && virangeflag != 2) || ret == -1)
+    if (!zlell || (zlecs == pos && mark == -1 && virangeflag != 2) || ret == -1) {
+        mark = mpos;
 	return -1;
+    }
 
     /* vi-match-bracket changes the value of virangeflag when *
      * moving to the opening bracket, meaning that we need to *
@@ -230,6 +235,12 @@ getvirange(int wf)
     virangeflag = 0;
     selectlocalmap(NULL);
 
+    /* if the mark has moved, ignore the original cursor position *
+     * and use the mark. */
+    if (mark != -1)
+	pos = mark;
+    mark = mpos;
+
     /* Get the range the right way round.  zlecs is placed at the *
      * start of the range, and pos (the return value of this   *
      * function) is the end.                                   */