To: vim_dev@googlegroups.com Subject: Patch 8.2.2058 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2058 Problem: Using mkview/loadview changes the jumplist. Solution: Use ":keepjumps". Don't let ":badd" or ":balt" change the jumplist. (closes #7371) Files: src/session.c, src/ex_docmd.c, src/testdir/test_mksession.vim *** ../vim-8.2.2057/src/session.c 2020-11-07 18:40:47.136725212 +0100 --- src/session.c 2020-11-26 21:44:47.667164864 +0100 *************** *** 460,468 **** (long)wp->w_height / 2, (long)wp->w_height) < 0 || put_eol(fd) == FAIL || put_line(fd, "if s:l < 1 | let s:l = 1 | endif") == FAIL ! || put_line(fd, "exe s:l") == FAIL || put_line(fd, "normal! zt") == FAIL ! || fprintf(fd, "%ld", (long)wp->w_cursor.lnum) < 0 || put_eol(fd) == FAIL) return FAIL; // Restore the cursor column and left offset when not wrapping. --- 460,468 ---- (long)wp->w_height / 2, (long)wp->w_height) < 0 || put_eol(fd) == FAIL || put_line(fd, "if s:l < 1 | let s:l = 1 | endif") == FAIL ! || put_line(fd, "keepjumps exe s:l") == FAIL || put_line(fd, "normal! zt") == FAIL ! || fprintf(fd, "keepjumps %ld", (long)wp->w_cursor.lnum) < 0 || put_eol(fd) == FAIL) return FAIL; // Restore the cursor column and left offset when not wrapping. *** ../vim-8.2.2057/src/ex_docmd.c 2020-11-25 20:12:05.000982716 +0100 --- src/ex_docmd.c 2020-11-26 22:12:44.962192895 +0100 *************** *** 6638,6644 **** else if (eap->cmdidx == CMD_enew) readonlymode = FALSE; // 'readonly' doesn't make sense in an // empty buffer ! setpcmark(); if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg), NULL, eap, // ":edit" goes to first line if Vi compatible --- 6638,6645 ---- else if (eap->cmdidx == CMD_enew) readonlymode = FALSE; // 'readonly' doesn't make sense in an // empty buffer ! if (eap->cmdidx != CMD_balt && eap->cmdidx != CMD_badd) ! setpcmark(); if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg), NULL, eap, // ":edit" goes to first line if Vi compatible *** ../vim-8.2.2057/src/testdir/test_mksession.vim 2020-11-01 17:40:47.829631403 +0100 --- src/testdir/test_mksession.vim 2020-11-26 22:12:08.214320542 +0100 *************** *** 586,591 **** --- 586,638 ---- %bwipe 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 \" + call assert_equal('Xfile2', expand('%')) + call assert_equal([2, 6], getcurpos()[1:2]) + exe "normal \" + 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 " set any error messages when sourced because no commands should fail. func Test_mksession_no_errmsg() *************** *** 872,875 **** --- 919,945 ---- set sessionoptions& 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-8.2.2057/src/version.c 2020-11-26 20:33:56.856583887 +0100 --- src/version.c 2020-11-27 10:59:23.686746640 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2058, /**/ -- CUSTOMER: You're not fooling anyone y'know. Look, isn't there something you can do? DEAD PERSON: I feel happy... I feel happy. [whop] CUSTOMER: Ah, thanks very much. MORTICIAN: Not at all. See you on Thursday. CUSTOMER: Right. The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///