forked from aniani/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 #7371)
This commit is contained in:
@@ -6638,7 +6638,8 @@ 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
|
||||||
setpcmark();
|
if (eap->cmdidx != CMD_balt && eap->cmdidx != CMD_badd)
|
||||||
|
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,
|
NULL, eap,
|
||||||
// ":edit" goes to first line if Vi compatible
|
// ":edit" goes to first line if Vi compatible
|
||||||
|
@@ -460,9 +460,9 @@ put_view(
|
|||||||
(long)wp->w_height / 2, (long)wp->w_height) < 0
|
(long)wp->w_height / 2, (long)wp->w_height) < 0
|
||||||
|| put_eol(fd) == FAIL
|
|| put_eol(fd) == FAIL
|
||||||
|| put_line(fd, "if s:l < 1 | let s:l = 1 | endif") == FAIL
|
|| put_line(fd, "if s:l < 1 | let s:l = 1 | endif") == FAIL
|
||||||
|| put_line(fd, "exe s:l") == FAIL
|
|| put_line(fd, "keepjumps exe s:l") == FAIL
|
||||||
|| put_line(fd, "normal! zt") == FAIL
|
|| put_line(fd, "normal! zt") == FAIL
|
||||||
|| fprintf(fd, "%ld", (long)wp->w_cursor.lnum) < 0
|
|| fprintf(fd, "keepjumps %ld", (long)wp->w_cursor.lnum) < 0
|
||||||
|| put_eol(fd) == FAIL)
|
|| put_eol(fd) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
// Restore the cursor column and left offset when not wrapping.
|
// Restore the cursor column and left offset when not wrapping.
|
||||||
|
@@ -586,6 +586,53 @@ 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
|
||||||
|
|
||||||
|
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()
|
||||||
@@ -872,4 +919,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
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2058,
|
||||||
/**/
|
/**/
|
||||||
2057,
|
2057,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user