Skip to content

Commit

Permalink
patch 8.0.0568: 1gd may hang
Browse files Browse the repository at this point in the history
Problem:    "1gd" may hang.
Solution:   Don't get stuck in one position. (Christian Brabandt, closes #1643)
  • Loading branch information
brammool committed Apr 20, 2017
1 parent fc8f111 commit 60402d6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/normal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -8311,6 +8316,7 @@ nv_g_cmd(cmdarg_T *cap)
break;
#endif

/* "g<": show scrollback text */
case '<':
show_sb_text();
break;
Expand Down
21 changes: 21 additions & 0 deletions src/testdir/test_goto.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
568,
/**/
567,
/**/
Expand Down

0 comments on commit 60402d6

Please sign in to comment.