mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-10-11 23:50:15 +08:00
Drop a tag address part cut short by a tab
:BTags reads the address field on its own, so ctags writing a tab inside a pattern leaves it unterminated: '--excmd=combine' gives '5;/^int', whose fragment matched line 7 instead of 5, silently and with a quickfix item to match. Keep the parts that did parse, so the line number still stands. An unterminated pattern is still taken on its own, being the whole address in a helptags file.
This commit is contained in:
1 file changed
+15
-8
+15
-8
@@ -550,19 +550,26 @@ endfunction
|
|||||||
" Address of a tag, given the rest of the line after the file name. Only the
|
" 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,
|
" 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
|
" chained with ';' for '--excmd=combine' and cut at the ';"' terminator as
|
||||||
" Vim's find_extra() does. The last pattern can be left unterminated, as a
|
" Vim's find_extra() does. Returns an empty string for anything else, which is
|
||||||
" field holding a tab arrives cut short; it then runs to the end of the line,
|
" then not run.
|
||||||
" taking any '|' or ';' with it, so it cannot chain a command. 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. Such a fragment matches the wrong line, so keep only the parts before
|
||||||
|
" it, and accept an unterminated pattern alone, which is the whole address in a
|
||||||
|
" helptags file. Running to the end of the line, it takes any '|' or ';' with it,
|
||||||
|
" so it cannot chain a command either.
|
||||||
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)
|
||||||
" :BTags aligns its columns, so its field arrives padded
|
" :BTags aligns its columns, so its field arrives padded
|
||||||
let rest = s:strip(a:rest)
|
let rest = s:strip(a:rest)
|
||||||
let address = matchstr(rest,
|
let chain = '^'.s:tag_address_part.'\%(;'.s:tag_address_part.'\)*'
|
||||||
\ '^'.s:tag_address_part.'\%(;'.s:tag_address_part.'\)*\ze\%(;"\|$\)')
|
let address = matchstr(rest, chain.'\ze\%(;"\|$\)')
|
||||||
return empty(address) ? matchstr(rest,
|
if !empty(address)
|
||||||
\ '^\%('.s:tag_address_part.';\)*'.s:tag_address_open.'$') : address
|
return address
|
||||||
|
endif
|
||||||
|
let address = matchstr(rest, chain.'\ze;[/?]')
|
||||||
|
return empty(address) ? matchstr(rest, '^'.s:tag_address_open.'$') : address
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" [key, [filename, [stay_on_edit: 0]]]
|
" [key, [filename, [stay_on_edit: 0]]]
|
||||||
|
|||||||
Reference in new issue
Block a user