-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Hi,
Thank you for this wonderful plugin. Your plugins are essential to my development workflow.
The has('clipboard') check in s:BrowserOpen() does not account for clipboard-providers, which was introduced in Vim v9.1.2081. As a result, :GBrowse! unintentionally skips copying the URL to the clipboard when clipboard-providers is configured.
vim-fugitive/autoload/fugitive.vim
Lines 7432 to 7441 in 61b51c0
| function! s:BrowserOpen(url, mods, echo_copy) abort | |
| let [_, main, query, anchor; __] = matchlist(a:url, '^\([^#?]*\)\(?[^#]*\)\=\(#.*\)\=') | |
| let url = main . tr(query, ' ', '+') . anchor | |
| let url = substitute(url, '[ <>\|"]', '\="%".printf("%02X",char2nr(submatch(0)))', 'g') | |
| let mods = s:Mods(a:mods) | |
| if a:echo_copy | |
| if has('clipboard') | |
| let @+ = url | |
| endif | |
| return 'echo '.string(url) |
I'm using Lima to run a virtual environment on macOS, and I copy to the host clipboard from the guest via a socket connection using clipboard-providers.
According to the documentation, has('unnamedplus') should detect this, but it did not work in my environment. So I have the following workaround that works for me, though it may not be the most elegant solution:
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
index 7f2f6026756b..23c30bc77153 100644
--- a/autoload/fugitive.vim
+++ b/autoload/fugitive.vim
@@ -7435,7 +7435,7 @@ function! s:BrowserOpen(url, mods, echo_copy) abort
let url = substitute(url, '[ <>\|"]', '\="%".printf("%02X",char2nr(submatch(0)))', 'g')
let mods = s:Mods(a:mods)
if a:echo_copy
- if has('clipboard')
+ if has('clipboard') || (has('clipboard_provider') && exists('v:clipproviders') && !empty(v:clipproviders))
let @+ = url
endif
return 'echo '.string(url)Would you consider adding support for clipboard-providers? If the above approach is acceptable, I would be happy to submit a PR.
Thanks.
`vim --version` outputs
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jan 09 2026 00:00:00)
Included patches: 1-2068
Modified by <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
Huge version without GUI. Features included (+) or not (-):
+acl
+arabic
+autocmd
+autochdir
-autoservername
-balloon_eval
+balloon_eval_term
-browse
++builtin_terms
+byte_offset
+channel
+cindent
+clientserver
-clipboard
+clipboard_provider
+cmdline_compl
+cmdline_hist
+cmdline_info
+comments
+conceal
+cryptv
+cscope
+cursorbind
+cursorshape
+dialog_con
+diff
+digraphs
-dnd
-ebcdic
+emacs_tags
+eval
+ex_extra
+extra_search
-farsi
+file_in_path
+find_in_path
+float
+folding
-footer
+fork()
+gettext
-hangul_input
+iconv
+insert_expand
+ipv6
+job
+jumplist
+keymap
+lambda
+langmap
+libcall
+linebreak
+lispindent
+listcmds
+localmap
+lua/dyn
+menu
+mksession
+modify_fname
+mouse
-mouseshape
+mouse_dec
+mouse_gpm
-mouse_jsbterm
+mouse_netterm
+mouse_sgr
-mouse_sysmouse
+mouse_urxvt
+mouse_xterm
+multi_byte
+multi_lang
-mzscheme
+netbeans_intg
+num64
+packages
+path_extra
+perl/dyn
+persistent_undo
+popupwin
+postscript
+printer
+profile
-python
+python3/dyn-stable
+quickfix
+reltime
+rightleft
+ruby/dyn
+scrollbind
+signs
+smartindent
+socketserver
+sodium
-sound
+spell
+startuptime
+statusline
-sun_workshop
+syntax
+tabpanel
+tag_binary
-tag_old_static
-tag_any_white
-tcl
+termguicolors
+terminal
+terminfo
+termresponse
+textobjects
+textprop
+timers
+title
-toolbar
+user_commands
+vartabs
+vertsplit
+vim9script
+viminfo
+virtualedit
+visual
+visualextra
+vreplace
-wayland
-wayland_clipboard
-wayland_focus_steal
+wildignore
+wildmenu
+windows
+writebackup
-X11
+xattr
-xfontset
-xim
-xpm
-xsmp
-xterm_clipboard
-xterm_save
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
3rd user vimrc file: "~/.config/vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -std=c17 -DSYS_VIMRC_FILE=/etc/vimrc -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,--enable-new-dtags -Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -Wl,--build-id=sha1 -Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes -L/usr/local/lib -o vim -lm -lselinux -lncurses -lsodium -lacl -lattr -lgpm