mirror of
https://github.com/neovim/neovim.git
synced 2026-11-02 09:49:02 -06:00
vim-patch:9.1.1885: Wrong restored cursor pos when re-entering buffer after changes
Problem: Wrong restored cursor position when re-entering a buffer
previously viewed in a window after making changes to the same
buffer in another window.
Solution: Adjust per-window "last cursor" positions on buffer changes.
(zeertzjq)
closes: vim/vim#18655
https://github.com/vim/vim/commit/b2e6b328dafe1cdfff10f1e811355e514da8071d
This commit is contained in:
1 parent
ae82636276
commit
3fb56ff8af
2 files changed
+55
-14
No files matched your search
@@ -619,17 +619,48 @@ func Test_switch_to_previously_viewed_buffer()
|
||||
vsplit
|
||||
|
||||
call cursor(100, 3)
|
||||
call assert_equal('100', getline('.'))
|
||||
edit Xotherbuf
|
||||
buffer Xviewbuf
|
||||
call assert_equal([0, 100, 3, 0], getpos('.'))
|
||||
call assert_equal('100', getline('.'))
|
||||
|
||||
edit Xotherbuf
|
||||
wincmd p
|
||||
normal! gg10dd
|
||||
wincmd p
|
||||
buffer Xviewbuf
|
||||
call assert_equal([0, 90, 3, 0], getpos('.'))
|
||||
call assert_equal('100', getline('.'))
|
||||
|
||||
edit Xotherbuf
|
||||
wincmd p
|
||||
normal! ggP
|
||||
wincmd p
|
||||
buffer Xviewbuf
|
||||
call assert_equal([0, 100, 3, 0], getpos('.'))
|
||||
call assert_equal('100', getline('.'))
|
||||
|
||||
edit Xotherbuf
|
||||
wincmd p
|
||||
normal! 96gg10ddgg
|
||||
wincmd p
|
||||
buffer Xviewbuf
|
||||
" The original cursor line was deleted, so cursor is restored to the start
|
||||
" of the line before the deleted range.
|
||||
call assert_equal([0, 95, 1, 0], getpos('.'))
|
||||
call assert_equal('95', getline('.'))
|
||||
|
||||
normal! u
|
||||
exe win_id2win(oldwin) .. 'close'
|
||||
setlocal bufhidden=hide
|
||||
|
||||
call cursor(200, 3)
|
||||
call assert_equal('200', getline('.'))
|
||||
edit Xotherbuf
|
||||
buffer Xviewbuf
|
||||
call assert_equal([0, 200, 3, 0], getpos('.'))
|
||||
call assert_equal('200', getline('.'))
|
||||
|
||||
bwipe! Xotherbuf
|
||||
bwipe! Xviewbuf
|
||||
|
||||
Reference in new issue
Block a user