fix(clipboard): prefer xsel #20918

Problem:
xclip is not actively maintained compared to xsel, and it has a bug:

    $ touch a
    $ xsel -ib < a
    $ xsel -ob
    $ xclip -o -selection clipboard
    Error: target STRING not available

Years ago, the situation was reversed.
We originally preferred xsel 46bd3c0f77
but then swapped to xclip 799d9c3215
to work around https://github.com/neovim/neovim/issues/7237#issuecomment-443440633

Solution:
Prefer xsel again.

close #20862
ref #9302
ref https://github.com/astrand/xclip/issues/38
This commit is contained in:
wzy 2022-11-07 11:46:58 +08:00 committed by GitHub
parent d337814906
commit b042f6d902
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,18 +97,18 @@ function! provider#clipboard#Executable() abort
let s:copy['*'] = ['wl-copy', '--foreground', '--primary', '--type', 'text/plain']
let s:paste['*'] = ['wl-paste', '--no-newline', '--primary']
return 'wl-copy'
elseif !empty($DISPLAY) && executable('xclip')
let s:copy['+'] = ['xclip', '-quiet', '-i', '-selection', 'clipboard']
let s:paste['+'] = ['xclip', '-o', '-selection', 'clipboard']
let s:copy['*'] = ['xclip', '-quiet', '-i', '-selection', 'primary']
let s:paste['*'] = ['xclip', '-o', '-selection', 'primary']
return 'xclip'
elseif !empty($DISPLAY) && executable('xsel') && s:cmd_ok('xsel -o -b')
let s:copy['+'] = ['xsel', '--nodetach', '-i', '-b']
let s:paste['+'] = ['xsel', '-o', '-b']
let s:copy['*'] = ['xsel', '--nodetach', '-i', '-p']
let s:paste['*'] = ['xsel', '-o', '-p']
return 'xsel'
elseif !empty($DISPLAY) && executable('xclip')
let s:copy['+'] = ['xclip', '-quiet', '-i', '-selection', 'clipboard']
let s:paste['+'] = ['xclip', '-o', '-selection', 'clipboard']
let s:copy['*'] = ['xclip', '-quiet', '-i', '-selection', 'primary']
let s:paste['*'] = ['xclip', '-o', '-selection', 'primary']
return 'xclip'
elseif executable('lemonade')
let s:copy['+'] = ['lemonade', 'copy']
let s:paste['+'] = ['lemonade', 'paste']