changeset 20721:70d561931721 v8.2.0913

patch 8.2.0913: code for resetting v:register is duplicated Commit: https://github.com/vim/vim/commit/439c036ed062de1c87cc7e3fe050a9569fb12089 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 6 15:58:03 2020 +0200 patch 8.2.0913: code for resetting v:register is duplicated Problem: Code for resetting v:register is duplicated. Solution: Add reset_reg_var().
author Bram Moolenaar <Bram@vim.org>
date Sat, 06 Jun 2020 16:00:04 +0200
parents 9160c85995fc
children 815649381f0f
files src/evalvars.c src/main.c src/normal.c src/proto/evalvars.pro src/version.c
diffstat 5 files changed, 24 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -244,7 +244,9 @@ evalvars_init(void)
 
     set_vim_var_nr(VV_ECHOSPACE,    sc_col - 1);
 
-    set_reg_var(0);  // default for v:register is not 0 but '"'
+    // Default for v:register is not 0 but '"'.  This is adjusted once the
+    // clipboard has been setup by calling reset_reg_var().
+    set_reg_var(0);
 }
 
 #if defined(EXITFREE) || defined(PROTO)
@@ -2192,6 +2194,22 @@ set_argv_var(char **argv, int argc)
 }
 
 /*
+ * Reset v:register, taking the 'clipboard' setting into account.
+ */
+    void
+reset_reg_var(void)
+{
+    int regname = 0;
+
+    // Adjust the register according to 'clipboard', so that when
+    // "unnamed" is present it becomes '*' or '+' instead of '"'.
+#ifdef FEAT_CLIPBOARD
+    adjust_clip_reg(&regname);
+#endif
+    set_reg_var(regname);
+}
+
+/*
  * Set v:register if needed.
  */
     void
--- a/src/main.c
+++ b/src/main.c
@@ -826,12 +826,7 @@ vim_main2(void)
     // done after the clipboard is available and all initial commands that may
     // modify the 'clipboard' setting have run; i.e. just before entering the
     // main loop.
-    {
-	int default_regname = 0;
-
-	adjust_clip_reg(&default_regname);
-	set_reg_var(default_regname);
-    }
+    reset_reg_var();
 #endif
 
 #if defined(FEAT_DIFF)
--- a/src/normal.c
+++ b/src/normal.c
@@ -1080,16 +1080,7 @@ getcount:
     {
 	clearop(oap);
 #ifdef FEAT_EVAL
-	{
-	    int regname = 0;
-
-	    // Adjust the register according to 'clipboard', so that when
-	    // "unnamed" is present it becomes '*' or '+' instead of '"'.
-# ifdef FEAT_CLIPBOARD
-	    adjust_clip_reg(&regname);
-# endif
-	    set_reg_var(regname);
-	}
+	reset_reg_var();
 #endif
     }
 
--- a/src/proto/evalvars.pro
+++ b/src/proto/evalvars.pro
@@ -46,6 +46,7 @@ void set_vim_var_string(int idx, char_u 
 void set_vim_var_list(int idx, list_T *val);
 void set_vim_var_dict(int idx, dict_T *val);
 void set_argv_var(char **argv, int argc);
+void reset_reg_var(void);
 void set_reg_var(int c);
 char_u *v_exception(char_u *oldval);
 char_u *v_throwpoint(char_u *oldval);
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    913,
+/**/
     912,
 /**/
     911,