liuchengxu / vista.vim

:cactus: Viewer & Finder for LSP symbols and tags
https://liuchengxu.github.io/vista.vim
MIT License
1.88k stars 89 forks source link

Potential bug in `Run()` of `nvim_lsp.vim` #438

Closed lizhemingi closed 1 year ago

lizhemingi commented 1 year ago

Describe the bug From second time run Vista finder nvim_lsp in a new file will give the stale output which is the result of last file.

Environment:

Steps to reproduce given the above info

  1. open a new code file let's say a.rs, and run Vista finder nvim_lsp, this will give the right output.
  2. open another code file let's say b.rs, and run Vista finder nvim_lsp, this will give the output same with a.rs, and it's not the correct output of b.rs.
  3. keep on b.rs and run another time Vista finder nvim_lsp, this time will give the correct output of b.rs.
  4. after first file, every new file will give the stale output of first run Vista finder nvim_lsp and second run is correct.

Expected behavior Every run of Vista finder nvim_lsp will give the right output.

Screenshot or gif (if possible) Run on https://github.com/liuchengxu/vim-clap

  1. open crates/matcher/src/substring.rs and run Vista finder nvim_lsp image
  2. open crates/matcher/src/mod.rs and run Vista finder nvim_lsp image
  3. keep on crates/matcher/src/mod.rs and run another time Vista finder nvim_lsp image

Potential root cause

  1. Every time a new file is opened and run Vista finder nvim_lsp, cache will be empty so a vista#executive#nvim_lsp#Run and then s:Run will be call.
  2. I think it's designed to call s:RunAsync() and wait for at least the data has been written or we can say vista#executive#nvim_lsp#SetData has been call.
  3. But g:vista_executive_nvim_lsp_fetching is not reset to true in s:Run before call s:RunAsync(), so from second time we call s:Run, it will not be blocked to wait for s:RunAsync finish, so the s:data in nvim_lsp.vim will be stale.

If you agree with the potential bug I found, I can send a pr to fix it. Looking forward to your response. Thank you.

lizhemingi commented 1 year ago

@liuchengxu Hi, could you please take a look at this issue ?

liuchengxu commented 1 year ago

I'm not actively using nvim_lsp, but it looks reasonable to me with a quick look, feel free to send a PR.