0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.0913: code for resetting v:register is duplicated

Problem:    Code for resetting v:register is duplicated.
Solution:   Add reset_reg_var().
This commit is contained in:
Bram Moolenaar
2020-06-06 15:58:03 +02:00
parent 11f1ffd182
commit 439c036ed0
5 changed files with 24 additions and 17 deletions

View File

@@ -244,7 +244,9 @@ evalvars_init(void)
set_vim_var_nr(VV_ECHOSPACE, sc_col - 1); 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) #if defined(EXITFREE) || defined(PROTO)
@@ -2191,6 +2193,22 @@ set_argv_var(char **argv, int argc)
set_vim_var_list(VV_ARGV, l); set_vim_var_list(VV_ARGV, l);
} }
/*
* 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. * Set v:register if needed.
*/ */

View File

@@ -826,12 +826,7 @@ vim_main2(void)
// done after the clipboard is available and all initial commands that may // done after the clipboard is available and all initial commands that may
// modify the 'clipboard' setting have run; i.e. just before entering the // modify the 'clipboard' setting have run; i.e. just before entering the
// main loop. // main loop.
{ reset_reg_var();
int default_regname = 0;
adjust_clip_reg(&default_regname);
set_reg_var(default_regname);
}
#endif #endif
#if defined(FEAT_DIFF) #if defined(FEAT_DIFF)

View File

@@ -1080,16 +1080,7 @@ getcount:
{ {
clearop(oap); clearop(oap);
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
{ reset_reg_var();
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);
}
#endif #endif
} }

View File

@@ -46,6 +46,7 @@ void set_vim_var_string(int idx, char_u *val, int len);
void set_vim_var_list(int idx, list_T *val); void set_vim_var_list(int idx, list_T *val);
void set_vim_var_dict(int idx, dict_T *val); void set_vim_var_dict(int idx, dict_T *val);
void set_argv_var(char **argv, int argc); void set_argv_var(char **argv, int argc);
void reset_reg_var(void);
void set_reg_var(int c); void set_reg_var(int c);
char_u *v_exception(char_u *oldval); char_u *v_exception(char_u *oldval);
char_u *v_throwpoint(char_u *oldval); char_u *v_throwpoint(char_u *oldval);

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
913,
/**/ /**/
912, 912,
/**/ /**/