Merge pull request #14619 from janlazo/vim-8.2.2772

vim-patch:8.2.{2772,2778}
This commit is contained in:
Jan Edmund Lazo 2021-05-22 22:32:43 -04:00 committed by GitHub
commit 3fb3b548a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 65 additions and 6 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' and 'packpath' 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,11 +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))) {
failed |= (makemap(fd, NULL) == FAIL int flags = OPT_GLOBAL;
|| makeset(fd, OPT_GLOBAL, false) == FAIL);
if (p_hls && fprintf(fd, "%s", "set hlsearch\n") < 0) { if (eap->cmdidx == CMD_mksession && (*flagp & SSOP_SKIP_RTP)) {
failed = true; flags |= OPT_SKIPRTP;
} }
failed |= (makemap(fd, NULL) == FAIL
|| makeset(fd, flags, false) == FAIL);
} }
if (!failed && view_session) { if (!failed && view_session) {
@ -1002,6 +1004,9 @@ void ex_mkrc(exarg_T *eap)
< 0) { < 0) {
failed = true; failed = true;
} }
if (p_hls && fprintf(fd, "%s", "set hlsearch\n") < 0) {
failed = true;
}
if (no_hlsearch && fprintf(fd, "%s", "nohlsearch\n") < 0) { if (no_hlsearch && fprintf(fd, "%s", "nohlsearch\n") < 0) {
failed = true; failed = true;
} }

View File

@ -5232,6 +5232,11 @@ int makeset(FILE *fd, int opt_flags, int local_only)
continue; continue;
} }
if ((opt_flags & OPT_SKIPRTP)
&& (p->var == (char_u *)&p_rtp || p->var == (char_u *)&p_pp)) {
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'

View File

@ -0,0 +1,42 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local command = helpers.command
local funcs = helpers.funcs
local eq = helpers.eq
describe('mksession', function()
before_each(clear)
after_each(function()
os.remove('Xtest_mks.out')
end)
it('supports "skiprtp" value', function()
command('set sessionoptions&vi')
command('set rtp+=$HOME')
command('set pp+=$HOME')
command('mksession! Xtest_mks.out')
local found_rtp = 0
local found_pp = 0
for _, line in pairs(funcs.readfile('Xtest_mks.out', 'b')) do
if line:find('set runtimepath') then
found_rtp = found_rtp + 1
end
if line:find('set packpath') then
found_pp = found_pp + 1
end
end
eq(1, found_rtp)
eq(1, found_pp)
command('set sessionoptions+=skiprtp')
command('mksession! Xtest_mks.out')
local found_rtp_or_pp = 0
for _, line in pairs(funcs.readfile('Xtest_mks.out', 'b')) do
if line:find('set runtimepath') or line:find('set packpath') then
found_rtp_or_pp = found_rtp_or_pp + 1
end
end
eq(0, found_rtp_or_pp)
end)
end)