Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tag stack after BTags and Tags commands #1567

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion autoload/fzf/vim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1042,15 +1042,32 @@ function! s:btags_source(tag_cmds)
return map(s:align_lists(map(lines, 'split(v:val, "\t")')), 'join(v:val, "\t")')
endfunction

function! s:end_tagstack_with(tagname, from_position)
let winid = win_getid()
let stack = gettagstack(winid)
let item = {
\ 'bufnr': a:from_position[0],
\ 'from': a:from_position,
\ 'tagname': a:tagname}
let stack['items'] = [item]
return settagstack(winid, stack, 't')
endfunction

function! s:btags_sink(lines)
if len(a:lines) < 2
return
endif
let tagname = ''
let from_position = [bufnr()] + getcurpos()[1:]
call s:action_for(a:lines[0])
let qfl = []
for line in a:lines[1:]
call s:execute_silent(split(line, "\t")[2])
let parts = split(line, "\t")
call s:execute_silent(parts[2])
call add(qfl, {'filename': expand('%'), 'lnum': line('.'), 'text': getline('.')})
if empty(tagname)
let tagname = trim(parts[0])
endif
endfor

if len(qfl) > 1
Expand All @@ -1061,6 +1078,9 @@ function! s:btags_sink(lines)
else
normal! zvzz
endif
if !empty(tagname)
call s:end_tagstack_with(tagname, from_position)
endif
endfunction

" query, [tag commands], [spec (dict)], [fullscreen (bool)]
Expand Down Expand Up @@ -1096,6 +1116,8 @@ function! s:tags_sink(lines)
" Remember the current position
let buf = bufnr('')
let view = winsaveview()
let tagname = ''
let from_position = [buf] + getcurpos()[1:]

let qfl = []
let [key; list] = a:lines
Expand All @@ -1117,6 +1139,9 @@ function! s:tags_sink(lines)
endif
call s:execute_silent(excmd)
call add(qfl, {'filename': expand('%'), 'lnum': line('.'), 'text': getline('.')})
if empty(tagname)
let tagname = trim(parts[0])
endif
catch /^Vim:Interrupt$/
break
catch
Expand All @@ -1141,6 +1166,9 @@ function! s:tags_sink(lines)
else
normal! ^zvzz
endif
if !empty(tagname)
call s:end_tagstack_with(tagname, from_position)
endif
endfunction

function! fzf#vim#tags(query, ...)
Expand Down