From c1d7a280936470c119035a8e6d5a4350571eb68a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 8 Jun 2018 11:16:00 -0400 Subject: vim-patch:8.0.0549: no test for the 8g8 command Problem: No test for the 8g8 command. Solution: Add a test. (Dominique Pelle, closes vim/vim#1615) https://github.com/vim/vim/commit/395b6bab33e5ed9a0377d7f140e98fd3ab682672 --- src/nvim/testdir/test_normal.vim | 56 +++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 27ac084ef0..c638920dd3 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -847,7 +847,7 @@ func! Test_normal18_z_fold() norm! j call assert_equal('52', getline('.')) - " zA on a opened fold when foldenale is not set + " zA on a opened fold when foldenable is not set 50 set nofoldenable norm! zA @@ -909,7 +909,7 @@ func! Test_normal18_z_fold() norm! j call assert_equal('55', getline('.')) - " 2) do not close fold under curser + " 2) do not close fold under cursor 51 set nofoldenable norm! zx @@ -1829,18 +1829,60 @@ fun! Test_normal34_g_cmd3() if !has("multi_byte") return endif + " Test for g8 new - call append(0, 'abcdefghijklmnopqrstuvwxyzäüö') - let a=execute(':norm! 1gg$g8') - call assert_equal('c3 b6 ', a[1:]) + let a=execute(':norm! 1G0g8') + call assert_equal("\nNUL", a) + + call setline(1, 'abcdefghijklmnopqrstuvwxyzäüö') + let a=execute(':norm! 1G$g8') + call assert_equal("\nc3 b6 ", a) + + call setline(1, "a\u0302") + let a=execute(':norm! 1G0g8') + call assert_equal("\n61 + cc 82 ", a) - " Test for gp gP - call append(1, range(1,10)) " clean up bw! endfunc +func Test_normal_8g8() + if !has("multi_byte") + return + endif + new + + " Test 8g8 which finds invalid utf8 at or after the cursor. + + " With invalid byte. + call setline(1, "___\xff___") + norm! 1G08g8g + call assert_equal([0, 1, 4, 0, 1], getcurpos()) + + " With invalid byte before the cursor. + call setline(1, "___\xff___") + norm! 1G$h8g8g + call assert_equal([0, 1, 6, 0, 9], getcurpos()) + + " With truncated sequence. + call setline(1, "___\xE2\x82___") + norm! 1G08g8g + call assert_equal([0, 1, 4, 0, 1], getcurpos()) + + " With overlong sequence. + call setline(1, "___\xF0\x82\x82\xAC___") + norm! 1G08g8g + call assert_equal([0, 1, 4, 0, 1], getcurpos()) + + " With valid utf8. + call setline(1, "café") + norm! 1G08g8 + call assert_equal([0, 1, 1, 0, 1], getcurpos()) + + bw! +endfunc + fun! Test_normal35_g_cmd4() " Test for g< " Cannot capture its output, -- cgit From 141df73930159682a48f68a89e02f0b5c38ac9e4 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 8 Jun 2018 11:18:50 -0400 Subject: vim-patch:8.0.0568: 1gd may hang Problem: "1gd" may hang. Solution: Don't get stuck in one position. (Christian Brabandt, closes vim/vim#1643) https://github.com/vim/vim/commit/60402d68da09997cacdeec71fd22c9344f8f40d5 --- src/nvim/normal.c | 19 +++++++++++-------- src/nvim/testdir/test_goto.vim | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index b959ea08f3..a649777ddd 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3769,14 +3769,17 @@ find_decl ( t = false; /* match after start is failure too */ if (thisblock && t != false) { - pos_T *pos; - - /* Check that the block the match is in doesn't end before the - * position where we started the search from. */ - if ((pos = findmatchlimit(NULL, '}', FM_FORWARD, - (int)(old_pos.lnum - curwin->w_cursor.lnum + 1))) != NULL - && pos->lnum < old_pos.lnum) + const int64_t maxtravel = old_pos.lnum - curwin->w_cursor.lnum + 1; + const pos_T *pos = findmatchlimit(NULL, '}', FM_FORWARD, maxtravel); + + // Check that the block the match is in doesn't end before the + // position where we started the search from. + if (pos != NULL && pos->lnum < old_pos.lnum) { + // There can't be a useful match before the end of this block. + // Skip to the end + curwin->w_cursor = *pos; continue; + } } if (t == false) { @@ -6895,7 +6898,7 @@ static void nv_g_cmd(cmdarg_T *cap) else show_utf8(); break; - + // "g<": show scrollback text case '<': show_sb_text(); break; diff --git a/src/nvim/testdir/test_goto.vim b/src/nvim/testdir/test_goto.vim index 2573401707..ea67fe7386 100644 --- a/src/nvim/testdir/test_goto.vim +++ b/src/nvim/testdir/test_goto.vim @@ -288,3 +288,24 @@ func Test_cursorline_keep_col() set nocursorline endfunc +func Test_gd_local_block() + let lines = [ + \ ' int main()', + \ '{', + \ ' char *a = "NOT NULL";', + \ ' if(a)', + \ ' {', + \ ' char *b = a;', + \ ' printf("%s\n", b);', + \ ' }', + \ ' else', + \ ' {', + \ ' char *b = "NULL";', + \ ' return b;', + \ ' }', + \ '', + \ ' return 0;', + \ '}', + \ ] + call XTest_goto_decl('1gd', lines, 11, 11) +endfunc -- cgit