]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.0.0568: 1gd may hang v8.0.0568
authorBram Moolenaar <Bram@vim.org>
Thu, 20 Apr 2017 16:54:50 +0000 (18:54 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 20 Apr 2017 16:54:50 +0000 (18:54 +0200)
Problem:    "1gd" may hang.
Solution:   Don't get stuck in one position. (Christian Brabandt, closes #1643)

src/normal.c
src/testdir/test_goto.vim
src/version.c

index 53bda6cc743961c467c427661047565bc6f8edbe..25c0986b43dcabd3118ea08860a78108525d973a 100644 (file)
@@ -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;
index 2573401707f7778dea5c4c6029f153a0bec08c45..ea67fe738606fb9bfe7ab34eb1c8b183867b27a4 100644 (file)
@@ -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
index 487712d069401a1394a374aa8c0104af55198d8f..b9790d41e3e23c5fe0eac82718aa091720a659db 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    568,
 /**/
     567,
 /**/