Mercurial > vim
comparison src/ex_cmds.c @ 11372:1074f58e1673 v8.0.0571
patch 8.0.0571: negative line number when using :z^ in an empty buffer
commit https://github.com/vim/vim/commit/a364cdb648ae009fa7aa05382f5659335683d349
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 20 21:12:30 2017 +0200
patch 8.0.0571: negative line number when using :z^ in an empty buffer
Problem: The cursor line number becomes negative when using :z^ in an empty
buffer. (neovim https://github.com/vim/vim/issues/6557)
Solution: Correct the line number. Also reset the column.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 20 Apr 2017 21:15:04 +0200 |
parents | ef32a5c74515 |
children | c45fb081391c |
comparison
equal
deleted
inserted
replaced
11371:a945e33a8879 | 11372:1074f58e1673 |
---|---|
4662 if (end > curbuf->b_ml.ml_line_count) | 4662 if (end > curbuf->b_ml.ml_line_count) |
4663 end = curbuf->b_ml.ml_line_count; | 4663 end = curbuf->b_ml.ml_line_count; |
4664 | 4664 |
4665 if (curs > curbuf->b_ml.ml_line_count) | 4665 if (curs > curbuf->b_ml.ml_line_count) |
4666 curs = curbuf->b_ml.ml_line_count; | 4666 curs = curbuf->b_ml.ml_line_count; |
4667 else if (curs < 1) | |
4668 curs = 1; | |
4667 | 4669 |
4668 for (i = start; i <= end; i++) | 4670 for (i = start; i <= end; i++) |
4669 { | 4671 { |
4670 if (minus && i == lnum) | 4672 if (minus && i == lnum) |
4671 { | 4673 { |
4684 for (j = 1; j < Columns; j++) | 4686 for (j = 1; j < Columns; j++) |
4685 msg_putchar('-'); | 4687 msg_putchar('-'); |
4686 } | 4688 } |
4687 } | 4689 } |
4688 | 4690 |
4689 curwin->w_cursor.lnum = curs; | 4691 if (curwin->w_cursor.lnum != curs) |
4692 { | |
4693 curwin->w_cursor.lnum = curs; | |
4694 curwin->w_cursor.col = 0; | |
4695 } | |
4690 ex_no_reprint = TRUE; | 4696 ex_no_reprint = TRUE; |
4691 } | 4697 } |
4692 | 4698 |
4693 /* | 4699 /* |
4694 * Check if the restricted flag is set. | 4700 * Check if the restricted flag is set. |