From 88b0ae41c883319f5f26e678a2983a46afa6693c Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 27 Sep 2026 20:59:01 +0900 Subject: [PATCH] Check the address on the BTags paths too The sink and the CTRL-O Show callback passed the raw field into the Ex command. A custom tag command can emit any address, so put it through the same check as :Tags. The BTags source aligns its columns, hence the strip. --- autoload/fzf/vim.vim | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index d363475..fbb5b32 100755 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -549,9 +549,11 @@ endfunction let s:tag_address_part = '\%(\d\+\|/\%(\\.\|[^/\\]\)*/\|?\%(\\.\|[^?\\]\)*?\)' let s:tag_address_open = '\%(/\%(\\.\|[^/\\]\)*\|?\%(\\.\|[^?\\]\)*\)' function! s:tag_address(rest) - let address = matchstr(a:rest, + " :BTags aligns its columns, so its field arrives padded + let rest = s:strip(a:rest) + let address = matchstr(rest, \ '^'.s:tag_address_part.'\%(;'.s:tag_address_part.'\)*\ze\%(;"\|$\)') - return empty(address) ? matchstr(a:rest, '^'.s:tag_address_open.'$') : address + return empty(address) ? matchstr(rest, '^'.s:tag_address_open.'$') : address endfunction " [key, [filename, [stay_on_edit: 0]]] @@ -764,8 +766,12 @@ function! s:goto_entry(winid, bufnr, dir, kind, entry) abort if len(parts) < 3 || !bufexists(a:bufnr) return endif + let excmd = s:tag_address(parts[2]) + if empty(excmd) + return + endif let cmds = ['keepalt keepjumps hide buffer '.a:bufnr, - \ 'sandbox keepjumps '.parts[2], 'normal! zvzz'] + \ 'sandbox keepjumps '.excmd, 'normal! zvzz'] elseif a:kind ==# 'marks' " A lowercase mark is local to the buffer the run started on let mark = matchstr(entry, '^\s*\zs\S') @@ -1674,7 +1680,11 @@ function! s:btags_sink(from, lines) let qfl = [] for line in a:lines[1:] let parts = split(line, "\t") - call s:execute_tag_address(parts[2]) + let excmd = s:tag_address(parts[2]) + if empty(excmd) + continue + endif + call s:execute_tag_address(excmd) call add(qfl, {'filename': expand('%'), 'lnum': line('.'), 'text': getline('.')}) if empty(tagname) let tagname = s:strip(parts[0])