Skip to content

Commit 60402d6

Browse files
committed
patch 8.0.0568: 1gd may hang
Problem: "1gd" may hang. Solution: Don't get stuck in one position. (Christian Brabandt, closes #1643)
1 parent fc8f111 commit 60402d6

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/normal.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4371,7 +4371,12 @@ find_decl(
43714371
if ((pos = findmatchlimit(NULL, '}', FM_FORWARD,
43724372
(int)(old_pos.lnum - curwin->w_cursor.lnum + 1))) != NULL
43734373
&& pos->lnum < old_pos.lnum)
4374+
{
4375+
/* There can't be a useful match before the end of this block.
4376+
* Skip to the end. */
4377+
curwin->w_cursor = *pos;
43744378
continue;
4379+
}
43754380
}
43764381

43774382
if (t == FAIL)
@@ -8311,6 +8316,7 @@ nv_g_cmd(cmdarg_T *cap)
83118316
break;
83128317
#endif
83138318

8319+
/* "g<": show scrollback text */
83148320
case '<':
83158321
show_sb_text();
83168322
break;

src/testdir/test_goto.vim

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,24 @@ func Test_cursorline_keep_col()
288288
set nocursorline
289289
endfunc
290290

291+
func Test_gd_local_block()
292+
let lines = [
293+
\ ' int main()',
294+
\ '{',
295+
\ ' char *a = "NOT NULL";',
296+
\ ' if(a)',
297+
\ ' {',
298+
\ ' char *b = a;',
299+
\ ' printf("%s\n", b);',
300+
\ ' }',
301+
\ ' else',
302+
\ ' {',
303+
\ ' char *b = "NULL";',
304+
\ ' return b;',
305+
\ ' }',
306+
\ '',
307+
\ ' return 0;',
308+
\ '}',
309+
\ ]
310+
call XTest_goto_decl('1gd', lines, 11, 11)
311+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
568,
767769
/**/
768770
567,
769771
/**/

0 commit comments

Comments
 (0)