diff options
author | watiko <service@mail.watiko.net> | 2016-01-18 21:22:49 +0900 |
---|---|---|
committer | watiko <service@mail.watiko.net> | 2016-01-19 12:29:37 +0900 |
commit | c90784836bdeac173f9ff6f12f6a81a8b2e49e2d (patch) | |
tree | 3d4945b8e8d0bd175c6ccc77ad1daecf6c188b46 | |
parent | ee0e214427d7ed2a9fd8ffc85c424cfffc927408 (diff) | |
download | rneovim-c90784836bdeac173f9ff6f12f6a81a8b2e49e2d.tar.gz rneovim-c90784836bdeac173f9ff6f12f6a81a8b2e49e2d.tar.bz2 rneovim-c90784836bdeac173f9ff6f12f6a81a8b2e49e2d.zip |
vim-patch:7.4.616
Problem: Cannot insert a tab in front of a block.
Solution: Correctly compute aop->start. (Christian Brabandt)
https://github.com/vim/vim/commit/f2c03d7301d35590a20cc43431950acc3a2f6036
-rw-r--r-- | src/nvim/ops.c | 32 | ||||
-rw-r--r-- | src/nvim/testdir/test39.in | 10 | ||||
-rw-r--r-- | src/nvim/testdir/test39.ok | bin | 585 -> 663 bytes | |||
-rw-r--r-- | src/nvim/version.c | 2 |
4 files changed, 33 insertions, 11 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index c3d968ca51..a24a754d65 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1991,6 +1991,7 @@ void op_insert(oparg_T *oap, long count1) char_u *firstline, *ins_text; struct block_def bd; int i; + pos_T t1; /* edit() changes this - record it for OP_APPEND */ bd.is_MAX = (curwin->w_curswant == MAXCOL); @@ -2053,7 +2054,16 @@ void op_insert(oparg_T *oap, long count1) } } - edit(NUL, FALSE, (linenr_T)count1); + t1 = oap->start; + edit(NUL, false, (linenr_T)count1); + + // When a tab was inserted, and the characters in front of the tab + // have been converted to a tab as well, the column of the cursor + // might have actually been reduced, so need to adjust here. */ + if (t1.lnum == curbuf->b_op_start_orig.lnum && + lt(curbuf->b_op_start_orig, t1)) { + oap->start = curbuf->b_op_start_orig; + } /* If user has moved off this line, we don't know what to do, so do * nothing. @@ -2069,21 +2079,23 @@ void op_insert(oparg_T *oap, long count1) if (oap->start.lnum == curbuf->b_op_start_orig.lnum && !bd.is_MAX) { if (oap->op_type == OP_INSERT && oap->start.col + oap->start.coladd - != curbuf->b_op_start_orig.col + curbuf->b_op_start_orig.coladd) { + != curbuf->b_op_start_orig.col + curbuf->b_op_start_orig.coladd) { + size_t t = getviscol2(curbuf->b_op_start_orig.col, + curbuf->b_op_start_orig.coladd); oap->start.col = curbuf->b_op_start_orig.col; - pre_textlen -= getviscol2(oap->start.col, oap->start.coladd) - - oap->start_vcol; - oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd); + pre_textlen -= t - oap->start_vcol; + oap->start_vcol = t; } else if (oap->op_type == OP_APPEND && oap->end.col + oap->end.coladd - >= curbuf->b_op_start_orig.col - + curbuf->b_op_start_orig.coladd) { + >= curbuf->b_op_start_orig.col + + curbuf->b_op_start_orig.coladd) { + size_t t = getviscol2(curbuf->b_op_start_orig.col, + curbuf->b_op_start_orig.coladd); oap->start.col = curbuf->b_op_start_orig.col; /* reset pre_textlen to the value of OP_INSERT */ pre_textlen += bd.textlen; - pre_textlen -= getviscol2(oap->start.col, oap->start.coladd) - - oap->start_vcol; - oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd); + pre_textlen -= t - oap->start_vcol; + oap->start_vcol = t; oap->op_type = OP_INSERT; } } diff --git a/src/nvim/testdir/test39.in b/src/nvim/testdir/test39.in index ebbcbd6d0d..71aeee9b95 100644 --- a/src/nvim/testdir/test39.in +++ b/src/nvim/testdir/test39.in @@ -2,6 +2,10 @@ Test Visual block mode commands And test "U" in Visual mode, also on German sharp S. +#define BO_ALL 0x0001 +#define BO_BS 0x0002 +#define BO_CRSR 0x0004 + STARTTEST :so small.vim :so mbyte.vim @@ -68,6 +72,12 @@ G3o987652k02l2jr :exe ":norm! 2k\<C-V>$gj\<Esc>" :let cpos=getpos("'>") :$put ='col:'.cpos[2].' off:'.cpos[3] +:" +:" block_insert when replacing spaces in front of the block with tabs +:set ts=8 sts=4 sw=4 +:4,7y +Gp +:exe ":norm! f0\<C-V>2jI\<tab>\<esc>" :/^the/,$w >> test.out :qa! ENDTEST diff --git a/src/nvim/testdir/test39.ok b/src/nvim/testdir/test39.ok Binary files differindex 198e5b14dc..497e2854ca 100644 --- a/src/nvim/testdir/test39.ok +++ b/src/nvim/testdir/test39.ok diff --git a/src/nvim/version.c b/src/nvim/version.c index 8c9faac0c3..142988d38f 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -508,7 +508,7 @@ static int included_patches[] = { // 619 NA // 618 NA 617, - // 616, + 616, 615, 614, // 613, |