diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-01-06 09:29:13 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-01-07 13:39:52 +0800 |
commit | aa5adef969f5f1ffcc3867200211fa236b569ae3 (patch) | |
tree | e45e1b7a4a7ea27caf8d38a51752706aaadbd04a /src/nvim/ex_session.c | |
parent | e58071c92c98fa54fcb29ab87ac6de7c02ede27b (diff) | |
download | rneovim-aa5adef969f5f1ffcc3867200211fa236b569ae3.tar.gz rneovim-aa5adef969f5f1ffcc3867200211fa236b569ae3.tar.bz2 rneovim-aa5adef969f5f1ffcc3867200211fa236b569ae3.zip |
vim-patch:8.2.4007: session does not restore help buffer properly
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 vim/vim#9475,
closes vim/vim#9458, closes vim/vim#9472)
https://github.com/vim/vim/commit/8e7d9db32b53ca2b1cb7570d2042860bcd1e943f
Diffstat (limited to 'src/nvim/ex_session.c')
-rw-r--r-- | src/nvim/ex_session.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index a37cad9f2d..a6d6bcbb8d 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -338,14 +338,26 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr // Edit the file. Skip this when ":next" already did it. if (add_edit && (!did_next || wp->w_arg_idx_invalid)) { - char *fname_esc = - ses_escape_fname(ses_get_fname(wp->w_buffer, flagp), flagp); - // - // Load the file. - // - if (wp->w_buffer->b_ffname != NULL - && (!bt_nofile(wp->w_buffer) - || wp->w_buffer->terminal)) { + char *fname_esc = ses_escape_fname(ses_get_fname(wp->w_buffer, flagp), flagp); + 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; + } + } else if (wp->w_buffer->b_ffname != NULL + && (!bt_nofile(wp->w_buffer) || wp->w_buffer->terminal)) { + // Load the file. + // Editing a file in this buffer: use ":edit file". // This may have side effects! (e.g., compressed or network file). // |