To: vim_dev@googlegroups.com Subject: Patch 8.2.4007 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4007 Problem: Session does not restore help buffer properly when "options' is missing from 'sessionoptions'. Solution: Use a ":help" command to create the help window. (closes #9475, closes #9458, closes #9472) Files: src/session.c, src/testdir/test_mksession.vim *** ../vim-8.2.4006/src/session.c 2022-01-01 14:19:44.052353829 +0000 --- src/session.c 2022-01-05 13:51:05.086944648 +0000 *************** *** 348,363 **** // Edit the file. Skip this when ":next" already did it. if (add_edit && (!did_next || wp->w_arg_idx_invalid)) { # ifdef FEAT_TERMINAL ! if (bt_terminal(wp->w_buffer)) { if (term_write_session(fd, wp, terminal_bufs) == FAIL) return FAIL; } - else # endif // Load the file. ! if (wp->w_buffer->b_ffname != NULL # ifdef FEAT_QUICKFIX && !bt_nofilename(wp->w_buffer) # endif --- 348,379 ---- // Edit the file. Skip this when ":next" already did it. if (add_edit && (!did_next || wp->w_arg_idx_invalid)) { + if (bt_help(wp->w_buffer)) + { + char *curtag = ""; + + // A help buffer needs some options to be set. + // First, create a new empty buffer with "buftype=help". + // Then ":help" will re-use both the buffer and the window and set + // the options, even when "options" is not in 'sessionoptions'. + if (0 < wp->w_tagstackidx + && wp->w_tagstackidx <= wp->w_tagstacklen) + curtag = (char *)wp->w_tagstack[wp->w_tagstackidx - 1].tagname; + + if (put_line(fd, "enew | setl bt=help") == FAIL + || fprintf(fd, "help %s", curtag) < 0 + || put_eol(fd) == FAIL) + return FAIL; + } # ifdef FEAT_TERMINAL ! else if (bt_terminal(wp->w_buffer)) { if (term_write_session(fd, wp, terminal_bufs) == FAIL) return FAIL; } # endif // Load the file. ! else if (wp->w_buffer->b_ffname != NULL # ifdef FEAT_QUICKFIX && !bt_nofilename(wp->w_buffer) # endif *** ../vim-8.2.4006/src/testdir/test_mksession.vim 2021-06-12 12:46:38.055854976 +0100 --- src/testdir/test_mksession.vim 2022-01-05 13:58:13.668217850 +0000 *************** *** 909,914 **** --- 909,944 ---- set sessionoptions& endfunc + " Test for mksession with "help" but not "options" in 'sessionoptions' + func Test_mksession_help_noopt() + set sessionoptions-=options + set sessionoptions+=help + help + let fname = expand('%') + mksession! Xtest_mks.out + bwipe + + source Xtest_mks.out + call assert_equal('help', &buftype) + call assert_equal('help', &filetype) + call assert_equal(fname, expand('%')) + call assert_false(&modifiable) + call assert_true(&readonly) + + helpclose + help index + let fname = expand('%') + mksession! Xtest_mks.out + bwipe + + source Xtest_mks.out + call assert_equal('help', &buftype) + call assert_equal(fname, expand('%')) + + call delete('Xtest_mks.out') + set sessionoptions& + endfunc + " Test for mksession with window position func Test_mksession_winpos() " Only applicable in GUI Vim *** ../vim-8.2.4006/src/version.c 2022-01-05 10:16:27.176425477 +0000 --- src/version.c 2022-01-05 13:54:40.134215004 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4007, /**/ -- hundred-and-one symptoms of being an internet addict: 225. You sign up for free subscriptions for all the computer magazines /// 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 ///