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.
This commit is contained in:
Junegunn Choi
2026-09-27 20:59:01 +09:00
parent d538da05b6
commit 88b0ae41c8
+14 -4
View File
@@ -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])