aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-01-04 07:17:54 +0800
committerGitHub <noreply@github.com>2023-01-03 15:17:54 -0800
commit5529b07316b75913188c44698aed6c0f866c5da9 (patch)
tree5b5bbe1effb12ec1a08538268ca4bbcfef36d149
parentd56c603caf348ba97b8428c9fcb812f1182e07e9 (diff)
downloadrneovim-5529b07316b75913188c44698aed6c0f866c5da9.tar.gz
rneovim-5529b07316b75913188c44698aed6c0f866c5da9.tar.bz2
rneovim-5529b07316b75913188c44698aed6c0f866c5da9.zip
fix(clipboard): show provider warning when not during batch changes #21451
It is strange that Ex commands that explicitly interact with the clipboard show provider warning, but Normal mode commands do not.
-rw-r--r--src/nvim/ops.c2
-rw-r--r--test/functional/provider/clipboard_spec.lua52
2 files changed, 49 insertions, 5 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index d2dba41959..ccfd3ab834 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -6433,7 +6433,7 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing)
}
if (!eval_has_provider("clipboard")) {
- if (batch_change_count == 1 && !quiet
+ if (batch_change_count <= 1 && !quiet
&& (!clipboard_didwarn || (explicit_cb_reg && !redirecting()))) {
clipboard_didwarn = true;
// Do NOT error (emsg()) here--if it interrupts :redir we get into
diff --git a/test/functional/provider/clipboard_spec.lua b/test/functional/provider/clipboard_spec.lua
index 401dc84ccc..2c5185a974 100644
--- a/test/functional/provider/clipboard_spec.lua
+++ b/test/functional/provider/clipboard_spec.lua
@@ -106,8 +106,53 @@ describe('clipboard', function()
basic_register_test()
end)
- it('`:redir @+>` with invalid g:clipboard shows exactly one error #7184',
- function()
+ it('using "+ in Normal mode with invalid g:clipboard always shows error', function()
+ insert('a')
+ command("let g:clipboard = 'bogus'")
+ feed('"+yl')
+ screen:expect([[
+ ^a |
+ {0:~ }|
+ {0:~ }|
+ clipboard: No provider. Try ":checkhealth" or ":h clipboard". |
+ ]])
+ feed('"+p')
+ screen:expect([[
+ a^a |
+ {0:~ }|
+ {0:~ }|
+ clipboard: No provider. Try ":checkhealth" or ":h clipboard". |
+ ]])
+ end)
+
+ it('using clipboard=unnamedplus with invalid g:clipboard shows error once', function()
+ insert('a')
+ command("let g:clipboard = 'bogus'")
+ command('set clipboard=unnamedplus')
+ feed('yl')
+ screen:expect([[
+ ^a |
+ {0:~ }|
+ {0:~ }|
+ clipboard: No provider. Try ":checkhealth" or ":h clipboard". |
+ ]])
+ feed(':<CR>')
+ screen:expect([[
+ ^a |
+ {0:~ }|
+ {0:~ }|
+ : |
+ ]])
+ feed('p')
+ screen:expect([[
+ a^a |
+ {0:~ }|
+ {0:~ }|
+ : |
+ ]])
+ end)
+
+ it('`:redir @+>` with invalid g:clipboard shows exactly one error #7184', function()
command("let g:clipboard = 'bogus'")
feed_command('redir @+> | :silent echo system("cat CONTRIBUTING.md") | redir END')
screen:expect([[
@@ -118,8 +163,7 @@ describe('clipboard', function()
]])
end)
- it('`:redir @+>|bogus_cmd|redir END` + invalid g:clipboard must not recurse #7184',
- function()
+ it('`:redir @+>|bogus_cmd|redir END` + invalid g:clipboard must not recurse #7184', function()
command("let g:clipboard = 'bogus'")
feed_command('redir @+> | bogus_cmd | redir END')
screen:expect{grid=[[