commit 9c91d5c61382639c06ca59e6cc2bfda6ba6abf18
parent d4b9f8186d4a73a661a407efb63fe8abca2c4e88
Author: zeertzjq <zeertzjq@outlook.com>
Date: Tue, 2 Aug 2022 06:57:49 +0800
Merge pull request #19617 from zeertzjq/vim-8.2.4956
vim-patch:8.2.{4899,4956,5013}
Diffstat:
4 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
@@ -4349,6 +4349,9 @@ static void op_format(oparg_T *oap, int keep_cursor)
if (keep_cursor) {
curwin->w_cursor = saved_cursor;
saved_cursor.lnum = 0;
+
+ // formatting may have made the cursor position invalid
+ check_cursor();
}
if (oap->is_VIsual) {
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
@@ -642,6 +642,9 @@ func Test_cmdline_remove_char()
call feedkeys(":abc def\<S-Left>\<C-U>\<C-B>\"\<CR>", 'tx')
call assert_equal('"def', @:, e)
+
+ " This was going before the start in latin1.
+ call feedkeys(": \<C-W>\<CR>", 'tx')
endfor
let &encoding = encoding_save
diff --git a/src/nvim/testdir/test_gf.vim b/src/nvim/testdir/test_gf.vim
@@ -138,6 +138,22 @@ func Test_gf_visual()
call assert_equal('Xtest_gf_visual', bufname('%'))
call assert_equal(3, getcurpos()[1])
+ " do not include the NUL at the end
+ call writefile(['x'], 'X')
+ let save_enc = &enc
+ " for enc in ['latin1', 'utf-8']
+ for enc in ['utf-8']
+ exe "set enc=" .. enc
+ new
+ call setline(1, 'X')
+ set nomodified
+ exe "normal \<C-V>$gf"
+ call assert_equal('X', bufname())
+ bwipe!
+ endfor
+ let &enc = save_enc
+ call delete('X')
+
" line number in visual area is used for file name
if has('unix')
bwipe!
diff --git a/src/nvim/testdir/test_textformat.vim b/src/nvim/testdir/test_textformat.vim
@@ -1534,4 +1534,16 @@ func Test_autoformat_comments()
close!
endfunc
+" This was leaving the cursor after the end of a line. Complicated way to
+" have the problem show up with valgrind.
+func Test_correct_cursor_position()
+ " set encoding=iso8859
+ new
+ norm a0000
+ sil! norm gggg0i0gw0gg
+
+ bwipe!
+ set encoding=utf8
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab