Yggdroot / LeaderF

An efficient fuzzy finder that helps to locate files, buffers, mrus, gtags, etc. on the fly for both vim and neovim.
Apache License 2.0
2.14k stars 178 forks source link

cache refresh does not work #862

Closed robertbu closed 2 years ago

robertbu commented 2 years ago

let g:Lf_ShortcutF = '\<c-p>' let g:Lf_ShortcutB = '\<c-b>' let g:Lf_WildIgnore = { \ 'dir' : ['build*'] } let g:Lf_CtagsFuncOpts = { \ 'c': '-I $HOME/.ctags_token --extras=+q --c-kinds=+lpx --c++-kinds=+lpx --fields=+ailmnzS' } noremap \<c-n> :LeaderfMru

Describe your question, feature request, or bug.

Press \<F5> to refresh cache seems to have no effect. I changed some file name with "git mv". However, when using searching files, I still got the old file name. Setting "g:Lf_UseCache = 0" does work. Also tried the command

:exec g:Lf_py "fileExplManager.refresh()"

It gives me some error message as shown below:

Traceback (most recent call last): File "", line 1, in File "/home/robert/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manag er.py", line 2071, in refresh self._search(self._content) File "/home/robert/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manag er.py", line 1082, in _search self._fuzzySearch(content, is_continue, step) File "/home/robert/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manag er.py", line 1498, in _fuzzySearch self._getInstance().setBuffer(self._result_content[:self._initial_count]) File "/home/robert/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/insta nce.py", line 1165, in setBuffer orig_row = self._window_object.cursor[0] vim.error: attempt to refer to deleted window

Anyway, it's a great plugin. Thank you.

Steps to reproduce

Actual behaviour

Expected behaviour

Yggdroot commented 2 years ago

Because you are using git, and your command is git ls-files "." && git ls-files --others --exclude-standard -x "build*" ".".

You can set let g:Lf_UseVersionControlTool = 1.

robertbu commented 2 years ago

Thank you for your quick response. git ls-files gives the new file name. And echo g:Lf_UseVersionControlTool gives 1 already.

Yggdroot commented 2 years ago

Sorry for mistake. set let g:Lf_UseVersionControlTool = 0

robertbu commented 2 years ago

Actually I've tried that. Now g:Lf_Debug_Cmd utilize the command 'find', instead of 'git'. However, :exec g:Lf_py "fileExplManager.refresh()" still give the error:

Traceback (most recent call last): File "", line 1, in File "/home/robert/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manag er.py", line 2071, in refresh self._search(self._content) File "/home/robert/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manag er.py", line 1082, in _search self._fuzzySearch(content, is_continue, step) File "/home/robert/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manag er.py", line 1498, in _fuzzySearch self._getInstance().setBuffer(self._result_content[:self._initial_count]) File "/home/robert/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/insta nce.py", line 1165, in setBuffer orig_row = self._window_object.cursor[0] vim.error: attempt to refer to deleted window

I think the problem is not that g:Lf_DebugCmd gives the old file name. Actually it gives the correct new file name. It should be that the cache is not updated. I checked the cache file at $HOME/.LfCache/python2/file/cache*. Only the old file name lies in the cache file.

Yggdroot commented 2 years ago

If g:Lf_UseCache == 0, the file won't be written to cache.

robertbu commented 2 years ago

Yes, if I set g:Lf_UseCache = 0, that works. LeaderF gives the new file name. This is the way I choose now. Anyhow, I'm wondering why cache does not work. Any hint to find the root cause? Googling "vim.error: attempt to refer to deleted window" does not give many information.

Yggdroot commented 2 years ago

:exec g:Lf_py "fileExplManager.refresh()" is only available when the LeaderF window is open, otherwise, vim.error: attempt to refer to deleted window is raised.

I don't know why, I think F5 should work.

robertbu commented 2 years ago

With LeaderF Window opened, the refresh command succeeds. Thanks. And I tried \<F5> in another git project, with LeaderF window opened, \<F5> works too. However, the cache file for the project at $HOME/.LfCache/python2/file/ is gone. g:Lf_UseCache is 1. Quite confused.

Yggdroot commented 2 years ago

The cache file is written only when the command of searching files takes more than 1.5 seconds.

robertbu commented 2 years ago

Thanks for your response