vim-patch:8.2.2772: problems when restoring 'runtimepath' from a session file

Problem:    Problems when restoring 'runtimepath' from a session file.
Solution:   Add the "skiprtp" item in 'sessionoptions'.
635bd60804

Allow "terminal" value for sessionoptions even if it's no-opt
because patch v8.0.1592 is not ported yet.

Omit vim9 test, Test_mksession_skiprtp().
This commit is contained in:
Jan Edmund Lazo
2021-05-22 15:01:08 -04:00
parent 8e5439182b
commit 8415615b59
5 changed files with 19 additions and 3 deletions

View File

@@ -5052,6 +5052,7 @@ A jump table for the options with a short description can be found at |Q_op|.
global values for local options) global values for local options)
options all options and mappings (also global values for local options all options and mappings (also global values for local
options) options)
skiprtp exclude 'runtimepath' from the options
resize size of the Vim window: 'lines' and 'columns' resize size of the Vim window: 'lines' and 'columns'
sesdir the directory in which the session file is located sesdir the directory in which the session file is located
will become the current directory (useful with will become the current directory (useful with

View File

@@ -937,8 +937,13 @@ void ex_mkrc(exarg_T *eap)
if (!view_session || (eap->cmdidx == CMD_mksession if (!view_session || (eap->cmdidx == CMD_mksession
&& (*flagp & SSOP_OPTIONS))) { && (*flagp & SSOP_OPTIONS))) {
int flags = OPT_GLOBAL;
if (eap->cmdidx == CMD_mksession && (*flagp & SSOP_SKIP_RTP)) {
flags |= OPT_SKIPRTP;
}
failed |= (makemap(fd, NULL) == FAIL failed |= (makemap(fd, NULL) == FAIL
|| makeset(fd, OPT_GLOBAL, false) == FAIL); || makeset(fd, flags, false) == FAIL);
} }
if (!failed && view_session) { if (!failed && view_session) {

View File

@@ -5232,6 +5232,10 @@ int makeset(FILE *fd, int opt_flags, int local_only)
continue; continue;
} }
if ((opt_flags & OPT_SKIPRTP) && p->var == (char_u *)&p_rtp) {
continue;
}
round = 2; round = 2;
if (p->indir != PV_NONE) { if (p->indir != PV_NONE) {
if (p->var == VAR_WIN) { if (p->var == VAR_WIN) {

View File

@@ -19,6 +19,9 @@ typedef enum {
OPT_MODELINE = 8, ///< Option in modeline. OPT_MODELINE = 8, ///< Option in modeline.
OPT_WINONLY = 16, ///< Only set window-local options. OPT_WINONLY = 16, ///< Only set window-local options.
OPT_NOWIN = 32, ///< Dont set window-local options. OPT_NOWIN = 32, ///< Dont set window-local options.
OPT_ONECOLUMN = 64, ///< list options one per line
OPT_NO_REDRAW = 128, ///< ignore redraw flags on option
OPT_SKIPRTP = 256, ///< "skiprtp" in 'sessionoptions'
} OptionFlags; } OptionFlags;
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS

View File

@@ -572,11 +572,12 @@ EXTERN char_u *p_slm; // 'selectmode'
EXTERN char_u *p_ssop; // 'sessionoptions' EXTERN char_u *p_ssop; // 'sessionoptions'
EXTERN unsigned ssop_flags; EXTERN unsigned ssop_flags;
# ifdef IN_OPTION_C # ifdef IN_OPTION_C
// Also used for 'viewoptions'! // Also used for 'viewoptions'! Keep in sync with SSOP_ flags.
static char *(p_ssop_values[]) = { static char *(p_ssop_values[]) = {
"buffers", "winpos", "resize", "winsize", "buffers", "winpos", "resize", "winsize",
"localoptions", "options", "help", "blank", "globals", "slash", "unix", "localoptions", "options", "help", "blank", "globals", "slash", "unix",
"sesdir", "curdir", "folds", "cursor", "tabpages", NULL "sesdir", "curdir", "folds", "cursor", "tabpages", "terminal", "skiprtp",
NULL
}; };
# endif # endif
# define SSOP_BUFFERS 0x001 # define SSOP_BUFFERS 0x001
@@ -595,6 +596,8 @@ static char *(p_ssop_values[]) = {
# define SSOP_FOLDS 0x2000 # define SSOP_FOLDS 0x2000
# define SSOP_CURSOR 0x4000 # define SSOP_CURSOR 0x4000
# define SSOP_TABPAGES 0x8000 # define SSOP_TABPAGES 0x8000
# define SSOP_TERMINAL 0x10000
# define SSOP_SKIP_RTP 0x20000
EXTERN char_u *p_sh; // 'shell' EXTERN char_u *p_sh; // 'shell'
EXTERN char_u *p_shcf; // 'shellcmdflag' EXTERN char_u *p_shcf; // 'shellcmdflag'