mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.1.0034: cursor not restored with ":edit #"
Problem: Cursor not restored with ":edit #".
Solution: Don't assume autocommands moved the cursor when it was moved to
the first non-blank.
adb8fbec4f
This commit is contained in:
parent
61df24b998
commit
a021b30ede
@ -2546,11 +2546,17 @@ int do_ecmd(
|
|||||||
}
|
}
|
||||||
check_arg_idx(curwin);
|
check_arg_idx(curwin);
|
||||||
|
|
||||||
// If autocommands change the cursor position or topline, we should keep
|
// If autocommands change the cursor position or topline, we should
|
||||||
// it. Also when it moves within a line.
|
// keep it. Also when it moves within a line. But not when it moves
|
||||||
|
// to the first non-blank.
|
||||||
if (!equalpos(curwin->w_cursor, orig_pos)) {
|
if (!equalpos(curwin->w_cursor, orig_pos)) {
|
||||||
newlnum = curwin->w_cursor.lnum;
|
const char_u *text = get_cursor_line_ptr();
|
||||||
newcol = curwin->w_cursor.col;
|
|
||||||
|
if (curwin->w_cursor.lnum != orig_pos.lnum
|
||||||
|
|| curwin->w_cursor.col != (int)(skipwhite(text) - text)) {
|
||||||
|
newlnum = curwin->w_cursor.lnum;
|
||||||
|
newcol = curwin->w_cursor.col;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (curwin->w_topline == topline)
|
if (curwin->w_topline == topline)
|
||||||
topline = 0;
|
topline = 0;
|
||||||
|
@ -1390,3 +1390,18 @@ func Test_edit_complete_very_long_name()
|
|||||||
endif
|
endif
|
||||||
set swapfile&
|
set swapfile&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_edit_alt()
|
||||||
|
" Keeping the cursor line didn't happen when the first line has indent.
|
||||||
|
new
|
||||||
|
call setline(1, [' one', 'two', 'three'])
|
||||||
|
w XAltFile
|
||||||
|
$
|
||||||
|
call assert_equal(3, line('.'))
|
||||||
|
e Xother
|
||||||
|
e #
|
||||||
|
call assert_equal(3, line('.'))
|
||||||
|
|
||||||
|
bwipe XAltFile
|
||||||
|
call delete('XAltFile')
|
||||||
|
endfunc
|
||||||
|
Loading…
Reference in New Issue
Block a user