mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
clipboard: test g:clipboard validation, fix a bug
Also fix `:help foo` highlighting in health.vim
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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 ')
|
||||
|
||||
Reference in New Issue
Block a user