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

lsp+fzf preview show incorrect line. #463

Open
lzh01 opened this issue Jul 3, 2023 · 1 comment
Open

lsp+fzf preview show incorrect line. #463

lzh01 opened this issue Jul 3, 2023 · 1 comment

Comments

@lzh01
Copy link

lzh01 commented Jul 3, 2023

In code

function! vista#finder#PrepareOpts(source, prompt) abort
let opts = {
\ 'source': a:source,
\ 'sink': function('vista#finder#fzf#sink'),
\ 'options': ['--prompt', a:prompt, '--nth', '..-2', '--delimiter', ':'] + get(g:, 'vista_fzf_opt', []),
\ }
if len(g:vista_fzf_preview) > 0
let idx = 0
let opt_preview_window_processed = v:false
while idx < len(g:vista_fzf_preview)
if g:vista_fzf_preview[idx] =~# '^\(left\|up\|right\|down\)'
let g:vista_fzf_preview[idx] = g:vista_fzf_preview[idx] . ':+{-1}-5'
let opt_preview_window_processed = v:true
endif
let idx = idx + 1
endwhile
if !opt_preview_window_processed
call extend(g:vista_fzf_preview, ['right:+{-1}-5'])
endif
let preview_opts = call('fzf#vim#with_preview', g:vista_fzf_preview).options
if has('win32')
" keeping old code around since we are not sure if / how preview works on windows
let preview_opts[-1] = preview_opts[-1][0:-3] . g:vista.source.fpath . (g:vista#renderer#enable_icon ? ':{2}' : ':{1}')
else
let object_name_index = g:vista#renderer#enable_icon ? '3' : '2'
let extract_line_number = printf(':$(echo {%s})', object_name_index)
let preview_opts[-1] = preview_opts[-1][0:-3] . fnameescape(g:vista.source.fpath) . extract_line_number
endif
call extend(opts.options, preview_opts)
endif
return opts
endfunction

It all depends on ':' as field separator, but when 'symbol' name or the line of code contains ':', the fzf preview can't get the correct line, will mostly end up showing from the start of the file.

For example, it can't handle lsp result line like

ClassA::varName:250 Variable yyy = "asdf:asdf";
function:275 Function ClassA::function() {

Tried to fix, but seems we have to use a different separator like '|' for the input.

@lzh01
Copy link
Author

lzh01 commented Jul 3, 2023

Also another issue for this part:

while idx < len(g:vista_fzf_preview)
if g:vista_fzf_preview[idx] =~# '^\(left\|up\|right\|down\)'
let g:vista_fzf_preview[idx] = g:vista_fzf_preview[idx] . ':+{-1}-5'
let opt_preview_window_processed = v:true
endif
let idx = idx + 1
endwhile

g:vista_fzf_preview got updated everytime we call a preview, and ':+{-1}-5' end up being added many times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant