aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/normal.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <janedmundlazo@hotmail.com>2018-06-08 11:18:50 -0400
committerJan Edmund Lazo <janedmundlazo@hotmail.com>2018-06-19 16:57:29 -0400
commit141df73930159682a48f68a89e02f0b5c38ac9e4 (patch)
treed8fcf6103231c9fcc2e88e5791fa0b9729d8508c /src/nvim/normal.c
parentc1d7a280936470c119035a8e6d5a4350571eb68a (diff)
downloadrneovim-141df73930159682a48f68a89e02f0b5c38ac9e4.tar.gz
rneovim-141df73930159682a48f68a89e02f0b5c38ac9e4.tar.bz2
rneovim-141df73930159682a48f68a89e02f0b5c38ac9e4.zip
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) https://github.com/vim/vim/commit/60402d68da09997cacdeec71fd22c9344f8f40d5
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r--src/nvim/normal.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index b959ea08f3..a649777ddd 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -3769,14 +3769,17 @@ find_decl (
t = false; /* match after start is failure too */
if (thisblock && t != false) {
- pos_T *pos;
-
- /* Check that the block the match is in doesn't end before the
- * position where we started the search from. */
- if ((pos = findmatchlimit(NULL, '}', FM_FORWARD,
- (int)(old_pos.lnum - curwin->w_cursor.lnum + 1))) != NULL
- && pos->lnum < old_pos.lnum)
+ 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
+ // position where we started the search from.
+ if (pos != 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 == false) {
@@ -6895,7 +6898,7 @@ static void nv_g_cmd(cmdarg_T *cap)
else
show_utf8();
break;
-
+ // "g<": show scrollback text
case '<':
show_sb_text();
break;