summaryrefslogtreecommitdiff
path: root/src/session.c
diff options
context:
space:
mode:
authormatveyt <matthewtarasov@gmail.com>2022-01-05 14:01:30 +0000
committerBram Moolenaar <Bram@vim.org>2022-01-05 14:01:30 +0000
commit8e7d9db32b53ca2b1cb7570d2042860bcd1e943f (patch)
tree551aa83a6dd768fcb79d40121eb3cf3f47d10493 /src/session.c
parentc653e4a2bd4099e2fac8e1c448a0f34581d5a658 (diff)
downloadvim-git-8e7d9db32b53ca2b1cb7570d2042860bcd1e943f.tar.gz
patch 8.2.4007: session does not restore help buffer properlyv8.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)
Diffstat (limited to 'src/session.c')
-rw-r--r--src/session.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/session.c b/src/session.c
index fdda5ee20..21af90245 100644
--- a/src/session.c
+++ b/src/session.c
@@ -348,16 +348,32 @@ put_view(
// 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
- if (bt_terminal(wp->w_buffer))
+ else 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
+ else if (wp->w_buffer->b_ffname != NULL
# ifdef FEAT_QUICKFIX
&& !bt_nofilename(wp->w_buffer)
# endif