mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-09-30 07:32:23 +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_part = '\%(\d\+\|/\%(\\.\|[^/\\]\)*/\|?\%(\\.\|[^?\\]\)*?\)'
|
||||||
let s:tag_address_open = '\%(/\%(\\.\|[^/\\]\)*\|?\%(\\.\|[^?\\]\)*\)'
|
let s:tag_address_open = '\%(/\%(\\.\|[^/\\]\)*\|?\%(\\.\|[^?\\]\)*\)'
|
||||||
function! s:tag_address(rest)
|
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\%(;"\|$\)')
|
\ '^'.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
|
endfunction
|
||||||
|
|
||||||
" [key, [filename, [stay_on_edit: 0]]]
|
" [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)
|
if len(parts) < 3 || !bufexists(a:bufnr)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
let excmd = s:tag_address(parts[2])
|
||||||
|
if empty(excmd)
|
||||||
|
return
|
||||||
|
endif
|
||||||
let cmds = ['keepalt keepjumps hide buffer '.a:bufnr,
|
let cmds = ['keepalt keepjumps hide buffer '.a:bufnr,
|
||||||
\ 'sandbox keepjumps '.parts[2], 'normal! zvzz']
|
\ 'sandbox keepjumps '.excmd, 'normal! zvzz']
|
||||||
elseif a:kind ==# 'marks'
|
elseif a:kind ==# 'marks'
|
||||||
" A lowercase mark is local to the buffer the run started on
|
" A lowercase mark is local to the buffer the run started on
|
||||||
let mark = matchstr(entry, '^\s*\zs\S')
|
let mark = matchstr(entry, '^\s*\zs\S')
|
||||||
@@ -1674,7 +1680,11 @@ function! s:btags_sink(from, lines)
|
|||||||
let qfl = []
|
let qfl = []
|
||||||
for line in a:lines[1:]
|
for line in a:lines[1:]
|
||||||
let parts = split(line, "\t")
|
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('.')})
|
call add(qfl, {'filename': expand('%'), 'lnum': line('.'), 'text': getline('.')})
|
||||||
if empty(tagname)
|
if empty(tagname)
|
||||||
let tagname = s:strip(parts[0])
|
let tagname = s:strip(parts[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user