summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-11-27 13:28:24 +0000
committerBram Moolenaar <Bram@vim.org>2021-11-27 13:28:24 +0000
commite9b0b40b7978f683977922233b42dd439ef31920 (patch)
treeb0ed3c67047ff8cc107bbcde0fc8e1445733481b
parent279d733dfb838cbabe88c8b8d3549d1493a49bbe (diff)
downloadvim-git-e9b0b40b7978f683977922233b42dd439ef31920.tar.gz
patch 8.2.3684: blockwise insert does not handle autoindent properlyv8.2.3684
Problem: Blockwise insert does not handle autoindent properly. Solution: Adjust text column for indent. (closes #9229)
-rw-r--r--src/ops.c4
-rw-r--r--src/testdir/test_blockedit.vim27
-rw-r--r--src/version.c2
3 files changed, 33 insertions, 0 deletions
diff --git a/src/ops.c b/src/ops.c
index d6190641d..354b2e251 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -1627,6 +1627,10 @@ op_insert(oparg_T *oap, long count1)
--bd2.textlen;
}
bd.textcol = bd2.textcol;
+ if (did_indent && bd.textcol > ind_pre)
+ // If the insert was in the indent then include the indent
+ // change in the new text, otherwise don't.
+ bd.textcol += ind_post - ind_pre;
bd.textlen = bd2.textlen;
}
diff --git a/src/testdir/test_blockedit.vim b/src/testdir/test_blockedit.vim
index 29e24759f..216238a52 100644
--- a/src/testdir/test_blockedit.vim
+++ b/src/testdir/test_blockedit.vim
@@ -14,6 +14,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
diff --git a/src/version.c b/src/version.c
index 7361d90f2..35afaedae 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3684,
+/**/
3683,
/**/
3682,