]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1132: Mark positions wrong after triggering multiline completion v9.1.1132
authorzeertzjq <zeertzjq@outlook.com>
Fri, 21 Feb 2025 19:06:26 +0000 (20:06 +0100)
committerChristian Brabandt <cb@256bit.org>
Fri, 21 Feb 2025 19:06:26 +0000 (20:06 +0100)
Problem:  Mark positions wrong after triggering multiline completion.
Solution: Call deleted_lines_mark() after deleting lines.
          (zeertzjq)

closes: #16687

Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/insexpand.c
src/testdir/test_ins_complete.vim
src/version.c

index 624165a9bf8703bf6a0665cbe684c2e3a6deacbe..dc8c76beecfa956ae42d2b2db0a4a14aea8c22b4 100644 (file)
@@ -4429,6 +4429,7 @@ ins_compl_delete(void)
                    VIM_CLEAR(remaining);
                return;
            }
+           deleted_lines_mark(curwin->w_cursor.lnum, 1L);
            curwin->w_cursor.lnum--;
        }
        // move cursor to end of line
index 0b943712bb20d41a85097cc750c900eea87b6643..c34f6426e05a12c01bf110c28760d862e07b0510 100644 (file)
@@ -3182,4 +3182,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
index 8e338f75f5d1d1fed3b35ae3ce35c48c25e28faa..d09ba285cc56d5bd16d7ecbf6d0e32dd4f300e1d 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1132,
 /**/
     1131,
 /**/