diff options
author | Christian Clason <c.clason@uni-graz.at> | 2021-11-27 14:54:02 +0100 |
---|---|---|
committer | Christian Clason <c.clason@uni-graz.at> | 2021-11-27 14:55:40 +0100 |
commit | a8dd1ea0118d3416135cb49df0992f2983ad6c44 (patch) | |
tree | 4476ae7267e691b048987838d839e413708b9a2f /src | |
parent | afbf89dc0120b1db5782a0bf807dc7c8db70ccf6 (diff) | |
download | rneovim-a8dd1ea0118d3416135cb49df0992f2983ad6c44.tar.gz rneovim-a8dd1ea0118d3416135cb49df0992f2983ad6c44.tar.bz2 rneovim-a8dd1ea0118d3416135cb49df0992f2983ad6c44.zip |
vim-patch:8.2.3684: blockwise insert does not handle autoindent properly
Problem: Blockwise insert does not handle autoindent properly.
Solution: Adjust text column for indent. (closes vim/vim#9229)
https://github.com/vim/vim/commit/e9b0b40b7978f683977922233b42dd439ef31920
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ops.c | 7 | ||||
-rw-r--r-- | src/nvim/testdir/test_blockedit.vim | 27 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index cbfed5daa5..ceb0049761 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2311,6 +2311,13 @@ void op_insert(oparg_T *oap, long count1) } } bd.textcol = bd2.textcol; + /* + * If the insert was in the indent then include the indent + * change in the new text, otherwise don't. + */ + if (did_indent && bd.textcol > ind_pre) { + bd.textcol += ind_post - ind_pre; + } bd.textlen = bd2.textlen; } diff --git a/src/nvim/testdir/test_blockedit.vim b/src/nvim/testdir/test_blockedit.vim index 180524cd73..5a72bebaba 100644 --- a/src/nvim/testdir/test_blockedit.vim +++ b/src/nvim/testdir/test_blockedit.vim @@ -15,6 +15,33 @@ func Test_blockinsert_indent() bwipe! endfunc +func Test_blockinsert_autoindent() + new + let lines =<< trim END + var d = { + a: () => 0, + b: () => 0, + c: () => 0, + } + END + call setline(1, lines) + filetype plugin indent on + setlocal sw=2 et ft=vim + setlocal indentkeys+=: + exe "norm! 2Gf)\<c-v>2jA: asdf\<esc>" + let expected =<< trim END + var d = { + a: (): asdf => 0, + b: (): asdf => 0, + c: (): asdf => 0, + } + END + call assert_equal(expected, getline(1, 5)) + + filetype off + bwipe! +endfunc + func Test_blockinsert_delete() new let _bs = &bs |