diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index 94dd7ad..25f447c 100755 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -547,21 +547,21 @@ function! s:sandboxed(cmd) return 'sandbox execute '.string(a:cmd) endfunction -" Address of a tag, given the rest of the line after the file name. Only the -" forms a tags file is meant to hold, a line number and a search pattern, -" chained with ';' for '--excmd=combine' and cut at the ';"' terminator as -" Vim's find_extra() does. Returns an empty string for anything else, which is -" then not run. +" Address of a tag, given the rest of the line after the file name, or, with +" 'whole' off, the address field alone as :BTags reads it. Only the forms a tags +" file is meant to hold, a line number and a search pattern, chained with ';' for +" '--excmd=combine' and cut at the ';"' terminator as Vim's find_extra() does. +" Returns an empty string for anything else, which is then not run. " -" A pattern holding a tab reaches :BTags cut short, since it reads the field on -" its own. Where earlier parts parsed, keep those and drop the fragment, since a -" line number beats half a pattern. A fragment on its own is indistinguishable -" from a helptags address such as '/*:Ag*', so it goes through unterminated, the -" way a builtin tag jump takes the same field. Running to the end of the line, it -" takes any '|' or ';' with it, so it cannot chain a command either. +" A pattern holding a tab reaches :BTags cut short. Where earlier parts parsed, +" keep those, since a line number beats half a pattern. A fragment on its own is +" an address only where the whole line is in hand, as in a helptags file, whose +" '/*:Ag*' carries no terminator. ctags always terminates, so on the field alone +" a fragment is the cut, and it would match some other line. Running to the end +" of the line it takes any '|' or ';' with it, so it cannot chain a command. let s:tag_address_part = '\%(\d\+\|/\%(\\.\|[^/\\]\)*/\|?\%(\\.\|[^?\\]\)*?\)' let s:tag_address_open = '\%(/\%(\\.\|[^/\\]\)*\|?\%(\\.\|[^?\\]\)*\)' -function! s:tag_address(rest) +function! s:tag_address(rest, whole) " :BTags aligns its columns, so its field arrives padded let rest = s:strip(a:rest) let chain = '^'.s:tag_address_part.'\%(;'.s:tag_address_part.'\)*' @@ -570,7 +570,10 @@ function! s:tag_address(rest) return address endif let address = matchstr(rest, chain.'\ze;[/?]') - return empty(address) ? matchstr(rest, '^'.s:tag_address_open.'$') : address + if !empty(address) + return address + endif + return a:whole ? matchstr(rest, '^'.s:tag_address_open.'$') : '' endfunction " [key, [filename, [stay_on_edit: 0]]] @@ -768,7 +771,7 @@ function! s:goto_entry(winid, bufnr, dir, kind, entry) abort if len(parts) < 3 return endif - let excmd = s:tag_address(join(parts[2:-2], '')[:-2]) + let excmd = s:tag_address(join(parts[2:-2], '')[:-2], 1) let relpath = parts[1][:-2] let path = relpath =~ (s:is_win ? '^[A-Z]:\' : '^/') \ ? relpath : join([fnamemodify(parts[-1], ':h'), relpath], '/') @@ -783,7 +786,7 @@ 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]) + let excmd = s:tag_address(parts[2], 0) if empty(excmd) return endif @@ -1703,7 +1706,7 @@ function! s:btags_sink(from, lines) for line in a:lines[1:] try let parts = split(line, "\t") - let excmd = s:tag_address(parts[2]) + let excmd = s:tag_address(parts[2], 0) if empty(excmd) throw 'Unsupported tag address: '.s:strip(parts[0]) endif @@ -1786,7 +1789,7 @@ function! s:tags_sink(from, lines) for line in list try let parts = split(line, '\t\zs') - let excmd = s:tag_address(join(parts[2:-2], '')[:-2]) + let excmd = s:tag_address(join(parts[2:-2], '')[:-2], 1) if empty(excmd) throw 'Unsupported tag address: '.s:strip(parts[0]) endif