diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Src/Zle/zle_vi.c | 35 | ||||
-rw-r--r-- | Test/X02zlevi.ztst | 12 |
3 files changed, 36 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog index 2616ac480..9994ef399 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2014-11-02 Oliver Kiddle <opk@zsh.org> + * 33593: Src/Zle/zle_vi.c, Test/X02zlevi.ztst: + support numeric argument to vi-join + * 33575: Src/Zle/zle_params.c, Src/Zle/zle_utils.c: reset vi change start position if text is inserted before it or on history movement diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c index b0e696b62..18c76f917 100644 --- a/Src/Zle/zle_vi.c +++ b/Src/Zle/zle_vi.c @@ -796,26 +796,33 @@ int vijoin(UNUSED(char **args)) { int x, pos; + int n = zmult; startvichange(-1); + if (n < 1) + return 1; if ((x = findeol()) == zlell) return 1; - zlecs = x + 1; - pos = zlecs; - for (; zlecs != zlell && ZC_iblank(zleline[zlecs]); INCPOS(zlecs)) - ; - x = 1 + (zlecs - pos); - backdel(x, CUT_RAW); - if (zlecs) { - int pos = zlecs; - DECPOS(pos); - if (ZC_iblank(zleline[pos])) { - zlecs = pos; - return 0; + while (n) { + zlecs = x + 1; + pos = zlecs; + for (; zlecs != zlell && ZC_iblank(zleline[zlecs]); INCPOS(zlecs)) + ; + x = 1 + (zlecs - pos); + backdel(x, CUT_RAW); + if (zlecs) { + int pos = zlecs; + DECPOS(pos); + if (ZC_iblank(zleline[pos])) { + zlecs = pos; + return 0; + } } + spaceinline(1); + zleline[zlecs] = ZWC(' '); + if (--n < 2 || (x = findeol()) == zlell) + return 0; } - spaceinline(1); - zleline[zlecs] = ZWC(' '); return 0; } diff --git a/Test/X02zlevi.ztst b/Test/X02zlevi.ztst index bd3105d14..f8a94ce3d 100644 --- a/Test/X02zlevi.ztst +++ b/Test/X02zlevi.ztst @@ -15,6 +15,18 @@ >BUFFER: good >CURSOR: 4 + zletest $' four\eO\C-v\tthree\eO two\eOone\e3J' +0:join lines with line count +>BUFFER: one two three +> four +>CURSOR: 7 + +# like real vi, we just join as many as possible, in vim this beeps + zletest $'two\eOone\e3J' +0:join more lines than possible +>BUFFER: one two +>CURSOR: 3 + zletest $'one two\eyb' 0:yank left moves the cursor >BUFFER: one two |