diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-12-28 08:12:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-28 08:12:20 +0800 |
commit | b3940cf8a1b388a49a2076573a7702ca4a22d059 (patch) | |
tree | 89582487d6f4d5c3640c99e6303f3cd8ddd466fb | |
parent | d82e105727475aa18720bd0b12103c23600e7ca0 (diff) | |
download | rneovim-b3940cf8a1b388a49a2076573a7702ca4a22d059.tar.gz rneovim-b3940cf8a1b388a49a2076573a7702ca4a22d059.tar.bz2 rneovim-b3940cf8a1b388a49a2076573a7702ca4a22d059.zip |
vim-patch:9.0.2188: cursor wrong after { in single line buffer (#26766)
Problem: cursor wrong after { in single line buffer
(Edwin Chan)
Solution: do not place the cursor at the end for a single
line buffer when moving backwards
(Gary Johnson)
closes: vim/vim#13780
closes: vim/vim#13783
https://github.com/vim/vim/commit/9e6549d2fb282c45a2492ea95fe7ba54c2082c3e
Co-authored-by: Gary Johnson <garyjohn@spocom.com>
-rw-r--r-- | src/nvim/textobject.c | 2 | ||||
-rw-r--r-- | test/old/testdir/test_normal.vim | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 0cfbb50684..2d1fd8c699 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -213,7 +213,7 @@ bool findpar(bool *pincl, int dir, int count, int what, bool both) curr++; } curwin->w_cursor.lnum = curr; - if (curr == curbuf->b_ml.ml_line_count && what != '}') { + if (curr == curbuf->b_ml.ml_line_count && what != '}' && dir == FORWARD) { char *line = ml_get(curr); // Put the cursor on the last character in the last line and make the diff --git a/test/old/testdir/test_normal.vim b/test/old/testdir/test_normal.vim index 6a8c15bd48..96992c4d89 100644 --- a/test/old/testdir/test_normal.vim +++ b/test/old/testdir/test_normal.vim @@ -4169,4 +4169,21 @@ func Test_normal34_zet_large() norm! z9765405999999999999 endfunc +" Test for { and } paragraph movements in a single line +func Test_brace_single_line() + let text =<< trim [DATA] + foobar one two three + [DATA] + + new + call setline(1, text) + 1 + norm! 0} + + call assert_equal([0, 1, 20, 0], getpos('.')) + norm! { + call assert_equal([0, 1, 1, 0], getpos('.')) + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab |