patch 8.2.0913: code for resetting v:register is duplicated
Problem: Code for resetting v:register is duplicated.
Solution: Add reset_reg_var().
diff --git a/src/evalvars.c b/src/evalvars.c
index e7a1b6d..8b3ce2e 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -244,7 +244,9 @@
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 @@
}
/*
+ * 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(®name);
+#endif
+ set_reg_var(regname);
+}
+
+/*
* Set v:register if needed.
*/
void
diff --git a/src/main.c b/src/main.c
index 201ed37..d66cd0c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -826,12 +826,7 @@
// 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)
diff --git a/src/normal.c b/src/normal.c
index f400141..e352354 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -1080,16 +1080,7 @@
{
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(®name);
-# endif
- set_reg_var(regname);
- }
+ reset_reg_var();
#endif
}
diff --git a/src/proto/evalvars.pro b/src/proto/evalvars.pro
index 0d2e7b4..97641b5 100644
--- a/src/proto/evalvars.pro
+++ b/src/proto/evalvars.pro
@@ -46,6 +46,7 @@
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);
diff --git a/src/version.c b/src/version.c
index ea3f6a4..2b9bd77 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 913,
+/**/
912,
/**/
911,