Mercurial > vim
changeset 11366:b16bc115a270 v8.0.0568
patch 8.0.0568: 1gd may hang
commit https://github.com/vim/vim/commit/60402d68da09997cacdeec71fd22c9344f8f40d5
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 20 18:54:50 2017 +0200
patch 8.0.0568: 1gd may hang
Problem: "1gd" may hang.
Solution: Don't get stuck in one position. (Christian Brabandt, closes https://github.com/vim/vim/issues/1643)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 20 Apr 2017 19:00:06 +0200 |
parents | 9b314fd2e99b |
children | 7a5c99db288b |
files | src/normal.c src/testdir/test_goto.vim src/version.c |
diffstat | 3 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/normal.c +++ b/src/normal.c @@ -4371,7 +4371,12 @@ find_decl( if ((pos = findmatchlimit(NULL, '}', FM_FORWARD, (int)(old_pos.lnum - curwin->w_cursor.lnum + 1))) != 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 == FAIL) @@ -8311,6 +8316,7 @@ nv_g_cmd(cmdarg_T *cap) break; #endif + /* "g<": show scrollback text */ case '<': show_sb_text(); break;
--- a/src/testdir/test_goto.vim +++ b/src/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