mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
eval: Add ability to set the unnamed register with setreg
This commit is contained in:
parent
a00b03d03f
commit
9a91ce4fa6
@ -6710,6 +6710,8 @@ setreg({regname}, {value} [, {options}])
|
||||
used as the width of the selection - if it is not specified
|
||||
then the width of the block is set to the number of characters
|
||||
in the longest line (counting a <Tab> as 1 character).
|
||||
If {options} contains "u" or '"', then the unnamed register is
|
||||
set to point to register {regname}.
|
||||
|
||||
If {options} contains no register settings, then the default
|
||||
is to use character mode unless {value} ends in a <NL> for
|
||||
|
@ -5100,7 +5100,8 @@ bool garbage_collect(bool testing)
|
||||
do {
|
||||
yankreg_T reg;
|
||||
char name = NUL;
|
||||
reg_iter = op_register_iter(reg_iter, &name, ®);
|
||||
bool is_unnamed = false;
|
||||
reg_iter = op_register_iter(reg_iter, &name, ®, &is_unnamed);
|
||||
if (name != NUL) {
|
||||
ABORTING(set_ref_dict)(reg.additional_data, copyID);
|
||||
}
|
||||
@ -14792,6 +14793,7 @@ static void f_setreg(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
regname = '"';
|
||||
}
|
||||
|
||||
bool set_unnamed = false;
|
||||
if (argvars[2].v_type != VAR_UNKNOWN) {
|
||||
const char *stropt = tv_get_string_chk(&argvars[2]);
|
||||
if (stropt == NULL) {
|
||||
@ -14820,6 +14822,10 @@ static void f_setreg(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'u': case '"': { // unnamed register
|
||||
set_unnamed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -14872,6 +14878,10 @@ free_lstval:
|
||||
append, yank_type, block_len);
|
||||
}
|
||||
rettv->vval.v_number = 0;
|
||||
|
||||
if (set_unnamed) {
|
||||
op_register_set_previous(regname);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -5853,3 +5853,19 @@ const yankreg_T *op_register_get(const char name)
|
||||
}
|
||||
return &y_regs[i];
|
||||
}
|
||||
|
||||
/// Set the previous yank register
|
||||
///
|
||||
/// @param[in] name Register name.
|
||||
///
|
||||
/// @return true on success, false on failure.
|
||||
bool op_register_set_previous(const char name)
|
||||
{
|
||||
int i = op_reg_index(name);
|
||||
if (i == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
y_previous = &y_regs[i];
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user