]> granicus.if.org Git - vim/commitdiff
patch 8.2.2772: problems when restoring 'runtimepath' from a session file v8.2.2772
authorBram Moolenaar <Bram@vim.org>
Fri, 16 Apr 2021 17:58:22 +0000 (19:58 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 16 Apr 2021 17:58:22 +0000 (19:58 +0200)
Problem:    Problems when restoring 'runtimepath' from a session file.
Solution:   Add the "skiprtp" item in 'sessionoptions'.

runtime/doc/options.txt
src/option.c
src/option.h
src/optionstr.c
src/session.c
src/testdir/test_mksession.vim
src/version.c
src/vim.h

index eb607d9cd9ccfc4a6ceef60fecda0813a5f98cd0..5cb878a7b38c56963c012866593c381bcb636bd5 100644 (file)
@@ -6511,6 +6511,7 @@ A jump table for the options with a short description can be found at |Q_op|.
                        global values for local options)
           options      all options and mappings (also global values for local
                        options)
+          skiprtp      exclude 'runtimepath' from the options
           resize       size of the Vim window: 'lines' and 'columns'
           sesdir       the directory in which the session file is located
                        will become the current directory (useful with
index b9d7edbbb05122a951ec6960e50c22a1fd8a6d77..d7997b0646eda52fe73f81ea4a64ac07cdbb0bf1 100644 (file)
@@ -4615,6 +4615,9 @@ makeset(FILE *fd, int opt_flags, int local_only)
            if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp, p_cp))
                continue;
 
+           if ((opt_flags & OPT_SKIPRTP) && p->var == (char_u *)&p_rtp)
+               continue;
+
            round = 2;
            if (p->indir != PV_NONE)
            {
index 0b1183fecfa4643ebef2549fa4a5649788c34627..30053cc6c27c8e12f44a4da1954feb4a6c13d3e9 100644 (file)
@@ -864,6 +864,7 @@ EXTERN unsigned     ssop_flags;
 # define SSOP_CURSOR           0x4000
 # define SSOP_TABPAGES         0x8000
 # define SSOP_TERMINAL         0x10000
+# define SSOP_SKIP_RTP         0x20000
 #endif
 EXTERN char_u  *p_sh;          // 'shell'
 EXTERN char_u  *p_shcf;        // 'shellcmdflag'
index 521242dbcbcebac4526f654cd3c8e3e8f9933d73..91d0a69d18bbc0324c722a078367eea611a1cc0c 100644 (file)
@@ -34,10 +34,11 @@ static char *(p_fdo_values[]) = {"all", "block", "hor", "mark", "percent",
                                 "undo", "jump", NULL};
 #endif
 #ifdef FEAT_SESSION
-// Also used for 'viewoptions'!
+// Also used for 'viewoptions'!  Keep in sync with SSOP_ flags.
 static char *(p_ssop_values[]) = {"buffers", "winpos", "resize", "winsize",
     "localoptions", "options", "help", "blank", "globals", "slash", "unix",
-    "sesdir", "curdir", "folds", "cursor", "tabpages", "terminal", NULL};
+    "sesdir", "curdir", "folds", "cursor", "tabpages", "terminal", "skiprtp",
+    NULL};
 #endif
 // Keep in sync with SWB_ flags in option.h
 static char *(p_swb_values[]) = {"useopen", "usetab", "split", "newtab", "vsplit", "uselast", NULL};
index 6e73bb67661e5e3204a3c8528363abdf38221786..4475ca019ac033ebf45a069960b232b0d36f7202 100644 (file)
@@ -1224,9 +1224,17 @@ ex_mkrc(exarg_T  *eap)
        if (!view_session
                || (eap->cmdidx == CMD_mksession
                    && (*flagp & SSOP_OPTIONS)))
+#endif
+       {
+           int flags = OPT_GLOBAL;
+
+#ifdef FEAT_SESSION
+           if (eap->cmdidx == CMD_mksession && (*flagp & SSOP_SKIP_RTP))
+               flags |= OPT_SKIPRTP;
 #endif
            failed |= (makemap(fd, NULL) == FAIL
-                                  || makeset(fd, OPT_GLOBAL, FALSE) == FAIL);
+                                        || makeset(fd, flags, FALSE) == FAIL);
+       }
 
 #ifdef FEAT_SESSION
        if (!failed && view_session)
index fca1227d5fb09afa826f2a06c104c20738445cf3..8eed111a85dd268c68994ea8f640850cdad295a1 100644 (file)
@@ -131,6 +131,32 @@ func Test_mksession()
   set sessionoptions&
 endfunc
 
+def Test_mksession_skiprtp()
+  mksession! Xtest_mks.out
+  var found = 0
+  for line in readfile('Xtest_mks.out')
+    if line =~ 'set runtimepath'
+      found = 1
+      break
+    endif
+  endfor
+  assert_equal(1, found)
+  delete('Xtest_mks.out')
+
+  set sessionoptions+=skiprtp
+  mksession! Xtest_mks.out
+  found = 0
+  for line in readfile('Xtest_mks.out')
+    if line =~ 'set runtimepath'
+      found = 1
+      break
+    endif
+  endfor
+  assert_equal(0, found)
+  delete('Xtest_mks.out')
+  set sessionoptions&
+enddef
+
 func Test_mksession_winheight()
   new
   set winheight=10
index 44cf5ffd0c68cc5f53b06e09464c56b7caafc1ef..4bc84232da2805992d0d92baf91875235c2c52db 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2772,
 /**/
     2771,
 /**/
index 4c9e095a10d370e5877be9e0ecf7dc0d01a673a2..844627d638db05e08b7cadea43c21e0e61395549 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -1201,6 +1201,7 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
 #define OPT_NOWIN      0x20    // don't set window-local options
 #define OPT_ONECOLUMN  0x40    // list options one per line
 #define OPT_NO_REDRAW  0x80    // ignore redraw flags on option
+#define OPT_SKIPRTP    0x100   // "skiprtp" in 'sessionoptions'
 
 // Magic chars used in confirm dialog strings
 #define DLG_BUTTON_SEP '\n'