aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/autoload/health.vim2
-rw-r--r--runtime/autoload/provider/clipboard.vim6
-rw-r--r--test/functional/clipboard/clipboard_provider_spec.lua31
3 files changed, 27 insertions, 12 deletions
diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim
index f875c8b797..bd99a0e104 100644
--- a/runtime/autoload/health.vim
+++ b/runtime/autoload/health.vim
@@ -90,7 +90,7 @@ endfunction
" Changes ':h clipboard' to ':help |clipboard|'.
function! s:help_to_link(s) abort
- return substitute(a:s, '\v:h%[elp] ([^|][^"\r\n]+)', ':help |\1|', 'g')
+ return substitute(a:s, '\v:h%[elp] ([^|][^"\r\n ]+)', ':help |\1|', 'g')
endfunction
" Format a message for a specific report item
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim
index 0d36dfcf78..8fe53c495a 100644
--- a/runtime/autoload/provider/clipboard.vim
+++ b/runtime/autoload/provider/clipboard.vim
@@ -57,14 +57,14 @@ endfunction
function! provider#clipboard#Executable() abort
if exists('g:clipboard')
if type({}) isnot# type(g:clipboard)
- \ || type({}) isnot# get(g:clipboard, 'copy', v:null)
- \ || type({}) isnot# get(g:clipboard, 'paste', v:null)
+ \ || type({}) isnot# type(get(g:clipboard, 'copy', v:null))
+ \ || type({}) isnot# type(get(g:clipboard, 'paste', v:null))
let s:err = 'clipboard: invalid g:clipboard'
return ''
endif
let s:copy = get(g:clipboard, 'copy', { '+': v:null, '*': v:null })
let s:paste = get(g:clipboard, 'paste', { '+': v:null, '*': v:null })
- let s:cache_enabled = get(g:clipboard, 'cache_enabled', 1)
+ let s:cache_enabled = get(g:clipboard, 'cache_enabled', 0)
return get(g:clipboard, 'name', 'g:clipboard')
elseif has('mac') && executable('pbcopy')
let s:copy['+'] = 'pbcopy'
diff --git a/test/functional/clipboard/clipboard_provider_spec.lua b/test/functional/clipboard/clipboard_provider_spec.lua
index 08055f61d8..e6544a8e2e 100644
--- a/test/functional/clipboard/clipboard_provider_spec.lua
+++ b/test/functional/clipboard/clipboard_provider_spec.lua
@@ -5,6 +5,7 @@ local Screen = require('test.functional.ui.screen')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local feed_command, expect, eq, eval = helpers.feed_command, helpers.expect, helpers.eq, helpers.eval
local command = helpers.command
+local meths = helpers.meths
local function basic_register_test(noblock)
insert("some words")
@@ -90,7 +91,7 @@ describe('clipboard', function()
end)
it('`:redir @+>` with invalid g:clipboard shows error exactly once', function()
- local screen = Screen.new(72, 8)
+ local screen = Screen.new(72, 5)
screen:attach()
command("let g:clipboard = 'bogus'")
feed_command('redir @+> | :silent echo system("cat CONTRIBUTING.md") | redir END')
@@ -99,12 +100,26 @@ describe('clipboard', function()
~ |
~ |
~ |
- ~ |
- ~ |
- ~ |
clipboard: No provider. Try ":CheckHealth" or ":h clipboard". |
]], nil, {{bold = true, foreground = Screen.colors.Blue}})
end)
+
+ it('invalid g:clipboard', function()
+ command("let g:clipboard = 'bogus'")
+ eq('', eval('provider#clipboard#Executable()'))
+ eq('clipboard: invalid g:clipboard', eval('provider#clipboard#Error()'))
+ end)
+
+ it('valid g:clipboard', function()
+ -- provider#clipboard#Executable() only checks the structure.
+ meths.set_var('clipboard', {
+ ['name'] = 'clippy!',
+ ['copy'] = { ['+'] = 'any command', ['*'] = 'some other' },
+ ['paste'] = { ['+'] = 'any command', ['*'] = 'some other' },
+ })
+ eq('clippy!', eval('provider#clipboard#Executable()'))
+ eq('', eval('provider#clipboard#Error()'))
+ end)
end)
describe('clipboard', function()
@@ -124,16 +139,16 @@ describe('clipboard', function()
assert(eval("g:clip_called_set") > 100)
end)
- it('`:redir @">` does not invoke clipboard', function()
- -- :redir to a non-clipboard register, with `:set clipboard=unnamed`.
- -- Does _not_ propagate to the clipboard (complies with Vim behavior).
+ it('`:redir @">` does NOT invoke clipboard', function()
+ -- :redir to a non-clipboard register, with `:set clipboard=unnamed` does
+ -- NOT propagate to the clipboard. This is consistent with Vim.
command("set clipboard=unnamedplus")
eq(0, eval("g:clip_called_set"))
feed_command('redir @"> | :silent echo system("cat CONTRIBUTING.md") | redir END')
eq(0, eval("g:clip_called_set"))
end)
- it('has independent "* and unnamed registers per default', function()
+ it('has independent "* and unnamed registers by default', function()
insert("some words")
feed('^"*dwdw"*P')
expect('some ')