mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-09-28 14:42:22 +08:00
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:
+14
-4
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user