mirror of
https://github.com/neovim/neovim.git
synced 2025-09-20 18:28:19 +00:00
Merge pull request #13692 from mjlbach/fix_cursor_respect_current_line
fix_cursor: do not change line number when edit will not impact cursor row
This commit is contained in:
@@ -1930,7 +1930,6 @@ static void fix_cursor(linenr_T lo, linenr_T hi, linenr_T extra)
|
|||||||
curwin->w_cursor.lnum += extra;
|
curwin->w_cursor.lnum += extra;
|
||||||
check_cursor_col();
|
check_cursor_col();
|
||||||
} else if (extra < 0) {
|
} else if (extra < 0) {
|
||||||
curwin->w_cursor.lnum = lo;
|
|
||||||
check_cursor();
|
check_cursor();
|
||||||
} else {
|
} else {
|
||||||
check_cursor_col();
|
check_cursor_col();
|
||||||
|
@@ -244,6 +244,14 @@ describe('lua buffer event callbacks: on_lines', function()
|
|||||||
eq(1, meths.get_var('listener_cursor_line'))
|
eq(1, meths.get_var('listener_cursor_line'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('has valid cursor position while deleting lines', function()
|
||||||
|
meths.buf_set_lines(0, 0, -1, true, { "line_1", "line_2", "line_3", "line_4"})
|
||||||
|
meths.win_set_cursor(0, {2, 0})
|
||||||
|
eq(2, meths.win_get_cursor(0)[1])
|
||||||
|
meths.buf_set_lines(0, 0, -1, true, { "line_1", "line_2", "line_3"})
|
||||||
|
eq(2, meths.win_get_cursor(0)[1])
|
||||||
|
end)
|
||||||
|
|
||||||
it('does not SEGFAULT when calling win_findbuf in on_detach', function()
|
it('does not SEGFAULT when calling win_findbuf in on_detach', function()
|
||||||
|
|
||||||
exec_lua[[
|
exec_lua[[
|
||||||
|
Reference in New Issue
Block a user