mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
clipboard: adjust v:register when clipboard=unnamed
Helped-By: Nicolas Hillegeer <nicolas@hillegeer.com> Helped-By: Michael Reed <m.reed@mykolab.com>
This commit is contained in:
parent
e584fe0057
commit
941b02af4c
@ -914,7 +914,7 @@ getcount:
|
|||||||
&& !oap->op_type
|
&& !oap->op_type
|
||||||
&& (idx < 0 || !(nv_cmds[idx].cmd_flags & NV_KEEPREG))) {
|
&& (idx < 0 || !(nv_cmds[idx].cmd_flags & NV_KEEPREG))) {
|
||||||
clearop(oap);
|
clearop(oap);
|
||||||
set_reg_var(0);
|
set_reg_var(get_default_register_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the length of mapped chars again after typing a count, second
|
/* Get the length of mapped chars again after typing a count, second
|
||||||
|
@ -5310,7 +5310,28 @@ static void free_register(struct yankreg *reg)
|
|||||||
y_current = curr;
|
y_current = curr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return target register
|
/// Check if the default register (used in an unnamed paste) should be a
|
||||||
|
/// clipboard register. This happens when `clipboard=unnamed[plus]` is set
|
||||||
|
/// and a provider is available.
|
||||||
|
///
|
||||||
|
/// @returns the name of of a clipboard register that should be used, or `NUL` if none.
|
||||||
|
int get_default_register_name(void)
|
||||||
|
{
|
||||||
|
int name = NUL;
|
||||||
|
adjust_clipboard_name(&name, true, false);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Determine if register `*name` should be used as a clipboard.
|
||||||
|
/// In an unnammed operation, `*name` is `NUL` and will be adjusted to `'*'/'+'` if
|
||||||
|
/// `clipboard=unnamed[plus]` is set.
|
||||||
|
///
|
||||||
|
/// @param name The name of register, or `NUL` if unnamed.
|
||||||
|
/// @param quiet Suppress error messages
|
||||||
|
/// @param writing if we're setting the contents of the clipboard
|
||||||
|
///
|
||||||
|
/// @returns the yankreg that should be used, or `NULL`
|
||||||
|
/// if the register isn't a clipboard or provider isn't available.
|
||||||
static struct yankreg* adjust_clipboard_name(int *name, bool quiet, bool writing) {
|
static struct yankreg* adjust_clipboard_name(int *name, bool quiet, bool writing) {
|
||||||
if (*name == '*' || *name == '+') {
|
if (*name == '*' || *name == '+') {
|
||||||
if(!eval_has_provider("clipboard")) {
|
if(!eval_has_provider("clipboard")) {
|
||||||
|
@ -72,6 +72,7 @@ end
|
|||||||
describe('the unnamed register', function()
|
describe('the unnamed register', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
it('works without provider', function()
|
it('works without provider', function()
|
||||||
|
eq('"', eval('v:register'))
|
||||||
basic_register_test()
|
basic_register_test()
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@ -227,6 +228,13 @@ describe('clipboard usage', function()
|
|||||||
a line]])
|
a line]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('supports v:register and getreg() without parameters', function()
|
||||||
|
eq('*', eval('v:register'))
|
||||||
|
execute("let g:test_clip['*'] = [['some block',''], 'b']")
|
||||||
|
eq('some block', eval('getreg()'))
|
||||||
|
eq('\02210', eval('getregtype()'))
|
||||||
|
end)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('supports :put', function()
|
it('supports :put', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user