aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-02-22 07:07:47 +0800
committerGitHub <noreply@github.com>2025-02-21 23:07:47 +0000
commit59b672fda2c98185a7d8b7740453635b8a40f2ff (patch)
tree0664055fb32aab5f7d23ba6721693cb558304a49
parentf3f94d2c373e2560f84082c11ced2c3f5c7736bb (diff)
downloadrneovim-59b672fda2c98185a7d8b7740453635b8a40f2ff.tar.gz
rneovim-59b672fda2c98185a7d8b7740453635b8a40f2ff.tar.bz2
rneovim-59b672fda2c98185a7d8b7740453635b8a40f2ff.zip
vim-patch:9.1.1132: Mark positions wrong after triggering multiline completion (#32564)
Problem: Mark positions wrong after triggering multiline completion. Solution: Call deleted_lines_mark() after deleting lines. (zeertzjq) closes: vim/vim#16687 https://github.com/vim/vim/commit/060e6556e2cd97512cee1f46bc7915768c0f9e21 Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
-rw-r--r--src/nvim/insexpand.c1
-rw-r--r--test/old/testdir/test_ins_complete.vim44
2 files changed, 45 insertions, 0 deletions
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index b0fa9146f1..e33e48e1d2 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -3795,6 +3795,7 @@ void ins_compl_delete(bool new_leader)
}
return;
}
+ deleted_lines_mark(curwin->w_cursor.lnum, 1);
curwin->w_cursor.lnum--;
}
// move cursor to end of line
diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim
index a0570c7c5d..cf9c970a22 100644
--- a/test/old/testdir/test_ins_complete.vim
+++ b/test/old/testdir/test_ins_complete.vim
@@ -3121,4 +3121,48 @@ function Test_completeopt_preinsert()
delfunc Omni_test
endfunc
+" Check that mark positions are correct after triggering multiline completion.
+func Test_complete_multiline_marks()
+ func Omni_test(findstart, base)
+ if a:findstart
+ return col(".")
+ endif
+ return [
+ \ #{word: "func ()\n\t\nend"},
+ \ #{word: "foobar"},
+ \ #{word: "你好\n\t\n我好"}
+ \ ]
+ endfunc
+ set omnifunc=Omni_test
+
+ new
+ let lines = mapnew(range(10), 'string(v:val)')
+ call setline(1, lines)
+ call setpos("'a", [0, 3, 1, 0])
+
+ call feedkeys("A \<C-X>\<C-O>\<C-E>\<BS>", 'tx')
+ call assert_equal(lines, getline(1, '$'))
+ call assert_equal([0, 3, 1, 0], getpos("'a"))
+
+ call feedkeys("A \<C-X>\<C-O>\<C-N>\<C-E>\<BS>", 'tx')
+ call assert_equal(lines, getline(1, '$'))
+ call assert_equal([0, 3, 1, 0], getpos("'a"))
+
+ call feedkeys("A \<C-X>\<C-O>\<C-N>\<C-N>\<C-E>\<BS>", 'tx')
+ call assert_equal(lines, getline(1, '$'))
+ call assert_equal([0, 3, 1, 0], getpos("'a"))
+
+ call feedkeys("A \<C-X>\<C-O>\<C-N>\<C-N>\<C-N>\<C-E>\<BS>", 'tx')
+ call assert_equal(lines, getline(1, '$'))
+ call assert_equal([0, 3, 1, 0], getpos("'a"))
+
+ call feedkeys("A \<C-X>\<C-O>\<C-Y>", 'tx')
+ call assert_equal(['0 func ()', "\t", 'end'] + lines[1:], getline(1, '$'))
+ call assert_equal([0, 5, 1, 0], getpos("'a"))
+
+ bw!
+ set omnifunc&
+ delfunc Omni_test
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab nofoldenable