mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
vim-patch:8.2.2058: using mkview/loadview changes the jumplist
Problem: Using mkview/loadview changes the jumplist.
Solution: Use ":keepjumps". Don't let ":badd" or ":balt" change the
jumplist. (closes vim/vim#7371)
3482be6a33
Definition for BufWinEnter autocmd in Test_mkview_loadview_jumplist()
was moved down a few lines until after the views are written, as in
Nvim, :loadview throws if the view file can't be opened.
This commit is contained in:
@@ -7345,7 +7345,9 @@ do_exedit(
|
|||||||
else if (eap->cmdidx == CMD_enew)
|
else if (eap->cmdidx == CMD_enew)
|
||||||
readonlymode = FALSE; /* 'readonly' doesn't make sense in an
|
readonlymode = FALSE; /* 'readonly' doesn't make sense in an
|
||||||
empty buffer */
|
empty buffer */
|
||||||
|
if (eap->cmdidx != CMD_balt && eap->cmdidx != CMD_badd) {
|
||||||
setpcmark();
|
setpcmark();
|
||||||
|
}
|
||||||
if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg),
|
if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg),
|
||||||
NULL, eap, eap->do_ecmd_lnum,
|
NULL, eap, eap->do_ecmd_lnum,
|
||||||
(buf_hide(curbuf) ? ECMD_HIDE : 0)
|
(buf_hide(curbuf) ? ECMD_HIDE : 0)
|
||||||
|
@@ -449,9 +449,9 @@ static int put_view(
|
|||||||
"let s:l = %" PRId64 " - ((%" PRId64
|
"let s:l = %" PRId64 " - ((%" PRId64
|
||||||
" * winheight(0) + %" PRId64 ") / %" PRId64 ")\n"
|
" * winheight(0) + %" PRId64 ") / %" PRId64 ")\n"
|
||||||
"if s:l < 1 | let s:l = 1 | endif\n"
|
"if s:l < 1 | let s:l = 1 | endif\n"
|
||||||
"exe s:l\n"
|
"keepjumps exe s:l\n"
|
||||||
"normal! zt\n"
|
"normal! zt\n"
|
||||||
"%" PRId64 "\n",
|
"keepjumps %" PRId64 "\n",
|
||||||
(int64_t)wp->w_cursor.lnum,
|
(int64_t)wp->w_cursor.lnum,
|
||||||
(int64_t)(wp->w_cursor.lnum - wp->w_topline),
|
(int64_t)(wp->w_cursor.lnum - wp->w_topline),
|
||||||
(int64_t)(wp->w_height_inner / 2),
|
(int64_t)(wp->w_height_inner / 2),
|
||||||
|
@@ -399,6 +399,58 @@ func Test_mkview_no_file_name()
|
|||||||
%bwipe
|
%bwipe
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_mkview_loadview_jumplist()
|
||||||
|
set viewdir=Xviewdir
|
||||||
|
au BufWinLeave * silent mkview
|
||||||
|
" au BufWinEnter * silent loadview
|
||||||
|
|
||||||
|
edit Xfile1
|
||||||
|
call setline(1, ['a', 'bbbbbbb', 'c'])
|
||||||
|
normal j3l
|
||||||
|
call assert_equal([2, 4], getcurpos()[1:2])
|
||||||
|
write
|
||||||
|
|
||||||
|
edit Xfile2
|
||||||
|
call setline(1, ['d', 'eeeeeee', 'f'])
|
||||||
|
normal j5l
|
||||||
|
call assert_equal([2, 6], getcurpos()[1:2])
|
||||||
|
write
|
||||||
|
|
||||||
|
edit Xfile3
|
||||||
|
call setline(1, ['g', 'h', 'iiiii'])
|
||||||
|
normal jj3l
|
||||||
|
call assert_equal([3, 4], getcurpos()[1:2])
|
||||||
|
write
|
||||||
|
|
||||||
|
" The commented :au above was moved here so that :mkview (on BufWinLeave) can
|
||||||
|
" run before :loadview. This is needed because Nvim's :loadview raises E484 if
|
||||||
|
" the view can't be opened, while Vim's silently fails instead.
|
||||||
|
au BufWinEnter * silent loadview
|
||||||
|
|
||||||
|
edit Xfile1
|
||||||
|
call assert_equal([2, 4], getcurpos()[1:2])
|
||||||
|
edit Xfile2
|
||||||
|
call assert_equal([2, 6], getcurpos()[1:2])
|
||||||
|
edit Xfile3
|
||||||
|
call assert_equal([3, 4], getcurpos()[1:2])
|
||||||
|
|
||||||
|
exe "normal \<C-O>"
|
||||||
|
call assert_equal('Xfile2', expand('%'))
|
||||||
|
call assert_equal([2, 6], getcurpos()[1:2])
|
||||||
|
exe "normal \<C-O>"
|
||||||
|
call assert_equal('Xfile1', expand('%'))
|
||||||
|
call assert_equal([2, 4], getcurpos()[1:2])
|
||||||
|
|
||||||
|
au! BufWinLeave
|
||||||
|
au! BufWinEnter
|
||||||
|
bwipe!
|
||||||
|
call delete('Xviewdir', 'rf')
|
||||||
|
call delete('Xfile1')
|
||||||
|
call delete('Xfile2')
|
||||||
|
call delete('Xfile3')
|
||||||
|
set viewdir&
|
||||||
|
endfunc
|
||||||
|
|
||||||
" A clean session (one empty buffer, one window, and one tab) should not
|
" A clean session (one empty buffer, one window, and one tab) should not
|
||||||
" set any error messages when sourced because no commands should fail.
|
" set any error messages when sourced because no commands should fail.
|
||||||
func Test_mksession_no_errmsg()
|
func Test_mksession_no_errmsg()
|
||||||
@@ -689,4 +741,27 @@ func Test_scrolloff()
|
|||||||
set sessionoptions&
|
set sessionoptions&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_altfile()
|
||||||
|
edit Xone
|
||||||
|
split Xtwo
|
||||||
|
edit Xtwoalt
|
||||||
|
edit #
|
||||||
|
wincmd w
|
||||||
|
edit Xonealt
|
||||||
|
edit #
|
||||||
|
mksession! Xtest_altfile
|
||||||
|
only
|
||||||
|
bwipe Xonealt
|
||||||
|
bwipe Xtwoalt
|
||||||
|
bwipe!
|
||||||
|
source Xtest_altfile
|
||||||
|
call assert_equal('Xone', bufname())
|
||||||
|
call assert_equal('Xonealt', bufname('#'))
|
||||||
|
wincmd w
|
||||||
|
call assert_equal('Xtwo', bufname())
|
||||||
|
call assert_equal('Xtwoalt', bufname('#'))
|
||||||
|
only
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user