mirror of
https://github.com/vim/vim.git
synced 2026-05-28 00:21:37 +02:00
patch 9.1.2118: 'cursorline' missing after :diffput to empty buf
Problem: 'cursorline' and part of 'statusline' are missing after
:diffput to an empty buffer.
Solution: Make sure the cursor doesn't go beyond the last line after
:diffput (zeertzjq)
related: neovim/neovim#37621
closes: #19281
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
cfe9d83a85
commit
ce1e562fda
@@ -4224,7 +4224,13 @@ ex_diffgetput(exarg_T *eap)
|
||||
// Adjust the cursor position if it's in/after the changed
|
||||
// lines.
|
||||
if (curwin->w_cursor.lnum >= lnum + count)
|
||||
{
|
||||
curwin->w_cursor.lnum += added;
|
||||
// When the buffer was previously empty, the cursor may
|
||||
// now be beyond the last line, so clamp cursor lnum.
|
||||
curwin->w_cursor.lnum = MIN(curwin->w_cursor.lnum,
|
||||
curbuf->b_ml.ml_line_count);
|
||||
}
|
||||
else if (added < 0)
|
||||
curwin->w_cursor.lnum = lnum;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user