mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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)
60402d68da
This commit is contained in:
parent
c1d7a28093
commit
141df73930
@ -3769,14 +3769,17 @@ find_decl (
|
|||||||
t = false; /* match after start is failure too */
|
t = false; /* match after start is failure too */
|
||||||
|
|
||||||
if (thisblock && t != false) {
|
if (thisblock && t != false) {
|
||||||
pos_T *pos;
|
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
|
// Check that the block the match is in doesn't end before the
|
||||||
* position where we started the search from. */
|
// position where we started the search from.
|
||||||
if ((pos = findmatchlimit(NULL, '}', FM_FORWARD,
|
if (pos != NULL && pos->lnum < old_pos.lnum) {
|
||||||
(int)(old_pos.lnum - curwin->w_cursor.lnum + 1))) != NULL
|
// There can't be a useful match before the end of this block.
|
||||||
&& pos->lnum < old_pos.lnum)
|
// Skip to the end
|
||||||
|
curwin->w_cursor = *pos;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t == false) {
|
if (t == false) {
|
||||||
@ -6895,7 +6898,7 @@ static void nv_g_cmd(cmdarg_T *cap)
|
|||||||
else
|
else
|
||||||
show_utf8();
|
show_utf8();
|
||||||
break;
|
break;
|
||||||
|
// "g<": show scrollback text
|
||||||
case '<':
|
case '<':
|
||||||
show_sb_text();
|
show_sb_text();
|
||||||
break;
|
break;
|
||||||
|
@ -288,3 +288,24 @@ func Test_cursorline_keep_col()
|
|||||||
set nocursorline
|
set nocursorline
|
||||||
endfunc
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user