From c57c25649be1d942a7f9ad78e26ac221a3239099 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 2 Aug 2022 05:57:46 +0800 Subject: vim-patch:8.2.4899: with latin1 encoding CTRL-W might go before the cmdline Problem: With latin1 encoding CTRL-W might go before the start of the command line. Solution: Check already being at the start of the command line. https://github.com/vim/vim/commit/ef02f16609ff0a26ffc6e20263523424980898fe --- src/nvim/testdir/test_cmdline.vim | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 094c6fd8d4..7aac731709 100644 --- 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\\\\"\", 'tx') call assert_equal('"def', @:, e) + + " This was going before the start in latin1. + call feedkeys(": \\", 'tx') endfor let &encoding = encoding_save -- cgit From 4f576be881a590172fa620214af6c9a42e98d132 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 2 Aug 2022 05:52:54 +0800 Subject: vim-patch:8.2.4956: reading past end of line with "gf" in Visual block mode Problem: Reading past end of line with "gf" in Visual block mode. Solution: Do not include the NUL in the length. https://github.com/vim/vim/commit/395bd1f6d3edc9f7edb5d1f2d7deaf5a9e3ab93c Omit trailing space: removed in patch 9.0.0126. --- src/nvim/testdir/test_gf.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_gf.vim b/src/nvim/testdir/test_gf.vim index c48e56976e..feae44e5ee 100644 --- 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 \$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! -- cgit From 50672e3850ddd0ddacfcdcd536922440fb719093 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 2 Aug 2022 05:55:07 +0800 Subject: vim-patch:8.2.5013: after text formatting cursor may be in an invalid position Problem: After text formatting the cursor may be in an invalid position. Solution: Correct the cursor position after formatting. https://github.com/vim/vim/commit/78d52883e10d71f23ab72a3d8b9733b00da8c9ad --- src/nvim/ops.c | 3 +++ src/nvim/testdir/test_textformat.vim | 12 ++++++++++++ 2 files changed, 15 insertions(+) (limited to 'src') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index cc67b0d0c1..0bcc5ecd0e 100644 --- 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_textformat.vim b/src/nvim/testdir/test_textformat.vim index 1d1f20d91a..0fc56083aa 100644 --- 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 a000“0 + sil! norm gggg0i0gw0gg + + bwipe! + set encoding=utf8 +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit