To: vim_dev@googlegroups.com Subject: Patch 8.2.4645 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4645 Problem: 'shortmess' changed when session does not store options. Solution: Save and restore 'shortmess' if needed. (James Charti, closes #10037) Files: src/session.c, src/testdir/test_mksession.vim *** ../vim-8.2.4644/src/session.c 2022-03-14 20:24:45.747034960 +0000 --- src/session.c 2022-03-29 11:55:27.097784535 +0100 *************** *** 686,691 **** --- 686,696 ---- if (put_line(fd, "endif") == FAIL) goto fail; + // save 'shortmess' if not storing options + if ((ssop_flags & SSOP_OPTIONS) == 0 + && put_line(fd, "let s:shortmess_save = &shortmess") == FAIL) + goto fail; + // Now save the current files, current buffer first. if (put_line(fd, "set shortmess=aoO") == FAIL) goto fail; *************** *** 956,965 **** if (put_line(fd, "unlet! s:wipebuf") == FAIL) goto fail; ! // Re-apply 'winheight', 'winwidth' and 'shortmess'. ! if (fprintf(fd, "set winheight=%ld winwidth=%ld shortmess=%s", ! p_wh, p_wiw, p_shm) < 0 || put_eol(fd) == FAIL) goto fail; if (tab_firstwin->w_next != NULL) { // Restore 'winminheight' and 'winminwidth'. --- 961,983 ---- if (put_line(fd, "unlet! s:wipebuf") == FAIL) goto fail; ! // Re-apply 'winheight' and 'winwidth'. ! if (fprintf(fd, "set winheight=%ld winwidth=%ld", ! p_wh, p_wiw) < 0 || put_eol(fd) == FAIL) goto fail; + + // Restore 'shortmess'. + if (ssop_flags & SSOP_OPTIONS) + { + if (fprintf(fd, "set shortmess=%s", p_shm) < 0 || put_eol(fd) == FAIL) + goto fail; + } + else + { + if (put_line(fd, "let &shortmess = s:shortmess_save") == FAIL) + goto fail; + } + if (tab_firstwin->w_next != NULL) { // Restore 'winminheight' and 'winminwidth'. *** ../vim-8.2.4644/src/testdir/test_mksession.vim 2022-03-14 20:24:45.747034960 +0000 --- src/testdir/test_mksession.vim 2022-03-29 11:50:35.206199720 +0100 *************** *** 1007,1012 **** --- 1007,1055 ---- set sessionoptions& endfunc + " Test for mksession with and without options restores shortmess + func Test_mksession_shortmess() + " Without options + set sessionoptions-=options + split + mksession! Xtest_mks.out + let found_save = 0 + let found_restore = 0 + let lines = readfile('Xtest_mks.out') + for line in lines + let line = trim(line) + + if line ==# 'let s:shortmess_save = &shortmess' + let found_save += 1 + endif + + if found_save !=# 0 && line ==# 'let &shortmess = s:shortmess_save' + let found_restore += 1 + endif + endfor + call assert_equal(1, found_save) + call assert_equal(1, found_restore) + call delete('Xtest_mks.out') + close + set sessionoptions& + + " With options + set sessionoptions+=options + split + mksession! Xtest_mks.out + let found_restore = 0 + let lines = readfile('Xtest_mks.out') + for line in lines + if line =~# 's:shortmess_save' + let found_restore += 1 + endif + endfor + call assert_equal(0, found_restore) + call delete('Xtest_mks.out') + close + set sessionoptions& + endfunc + " Test for mksession with 'compatible' option func Test_mksession_compatible() mksession! Xtest_mks1.out *** ../vim-8.2.4644/src/version.c 2022-03-29 11:38:13.643070603 +0100 --- src/version.c 2022-03-29 11:53:14.289970059 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4645, /**/ -- LAUNCELOT: I am, sir. I am a Knight of King Arthur. FATHER: 'Mm ... very nice castle, Camelot ... very good pig country.... "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///