summaryrefslogtreecommitdiff
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-04-20 21:12:30 +0200
committerBram Moolenaar <Bram@vim.org>2017-04-20 21:12:30 +0200
commita364cdb648ae009fa7aa05382f5659335683d349 (patch)
treedb5a75a4f1ec522dcad792847f8ebe4813e6a355 /src/ex_cmds.c
parentc03944151fec2d5469746642a949c8fcb5a744a8 (diff)
downloadvim-git-a364cdb648ae009fa7aa05382f5659335683d349.tar.gz
patch 8.0.0571: negative line number when using :z^ in an empty bufferv8.0.0571
Problem: The cursor line number becomes negative when using :z^ in an empty buffer. (neovim #6557) Solution: Correct the line number. Also reset the column.
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 4b0bdef59..309474ce0 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -4664,6 +4664,8 @@ ex_z(exarg_T *eap)
if (curs > curbuf->b_ml.ml_line_count)
curs = curbuf->b_ml.ml_line_count;
+ else if (curs < 1)
+ curs = 1;
for (i = start; i <= end; i++)
{
@@ -4686,7 +4688,11 @@ ex_z(exarg_T *eap)
}
}
- curwin->w_cursor.lnum = curs;
+ if (curwin->w_cursor.lnum != curs)
+ {
+ curwin->w_cursor.lnum = curs;
+ curwin->w_cursor.col = 0;
+ }
ex_no_reprint = TRUE;
}