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

<C-W>o causes "Autocommands caused command to abort" error #1087

Closed dengzhizhi closed 4 months ago

dengzhizhi commented 4 months ago

" Refresh each time we call leaderf let g:Lf_UseMemoryCache = 0

" Open a new window in the current tab (I don't need this because I am using bufferline) " let g:Lf_JumpToExistingWindow = 0

" Ignore certain files and directories when searching files let g:Lf_WildIgnore = { \ 'dir': ['.git', 'pycache', '.DS_Store'], \ 'file': ['.exe', '.dll', '.so', '.o', '.pyc', '.jpg', '.png', \ '.gif', '.svg', '.ico', '.db', '.tgz', '.tar.gz', '.gz', \ '.zip', '.bin', '.pptx', '.xlsx', '.docx', '.pdf', '.tmp', \ '.wmv', '.mkv', '.mp4', '.rmvb', '.ttf', '.ttc', '.otf', \ '.mp3', '.aac', '.orig', '.min.js', '*-combined.js'] }

" Default Rg config let g:Lf_RgConfig = [ \"--max-columns=500", \"--glob=!tags", \"--glob=!tags.", \"--glob=!.min.js", \"--glob=!.git/" ]

" Store the last rg search pattern to register r let g:Lf_RgStorePattern = "r"

" No default limit for search result to allow all files are show in " LeaderfFile let g:Lf_MaxCount=200000

" Do not show fancy icons for Linux server. if g:is_linux let g:Lf_ShowDevIcons = 0 endif

" Only fuzzy-search files names let g:Lf_DefaultMode = 'Regex'

let g:Lf_MruFileExclude = ['*.so'] let g:Lf_MruMaxFiles = 9999

" Do not use version control tool to list files under a directory since " submodules are not searched by default. let g:Lf_UseVersionControlTool = 0

" Use rg as the default search tool let g:Lf_DefaultExternalTool = "rg"

" show dot files let g:Lf_ShowHidden = 1

" preview in popup let g:Lf_PreviewInPopup = 1

" set up working directory as current pwd so that I can fine tune search " scope let g:Lf_WorkingDirectoryMode = 'c'

" Change keybinding in LeaderF prompt mode, use ctrl-n and ctrl-p to navigate items. let g:Lf_CommandMap = {'': [''], '': ['']}

let g:Lf_PreviewCode = 0 let g:Lf_PreviewResult = { \ 'File': 0, \ 'Buffer': 0, \ 'Mru': 0, \ 'Tag': 0, \ 'BufTag': 0, \ 'Function': 0, \ 'Line': 0, \ 'Colorscheme': 0, \ 'Rg': 0, \ 'Gtags': 0 }

let g:Lf_FolderAcceptSelectionCmd = 'Dirbuf'

### Describe your question, feature request, or bug.
After performing a `--stayOpen` _rg_ search and use `<Enter>` to open the target file, attempting to close the search result window with `<c-w>o` will cause an _Autocommands caused command to abort_ error. 

### Steps to reproduce
1. Run command: `Leaderf! rg --regexMode --hidden --stayOpen -e "require"` ("require" can be changed to another search keyword)
2. _The result window shows up as a split window in the bottom_, press `<Enter>` on a result entry, the targeted file will open in the top split window, and get the focus.
3. In the targeted file window, use `<c-w>o` to close other windows

### Actual behaviour
The result window will take up all the space and the targeted file window will disappear. Pressing `<ESC>` can close the search result window and bring back the target file buffer. However `Leaderf! rg --recall` will show the following error message and the result list will be gone.

Error detected while processing function leaderf#Any#start[4]..leaderf#LfPy[1]..provider#python3#Call: line 18: Error invoking 'python_execute' on channel 4 (python3-script-host): Traceback (most recent call last): File "", line 1, in File "/Users/zd/.local/share/nvim/lazy/LeaderF/autoload/leaderf/python/leaderf/anyExpl.py", line 838, in start the_args.start(arguments, *args, kwargs) File "/Users/zd/.local/share/nvim/lazy/LeaderF/autoload/leaderf/python/leaderf/anyExpl.py", line 756, in _default_action manager.startExplorer(win_pos[2:], *args, *kwargs) File "/Users/zd/.local/share/nvim/lazy/LeaderF/autoload/leaderf/python/leaderf/rgExpl.py", line 1187, in startExplorer super(RgExplManager, self).startExplorer(win_pos, args, kwargs) File "/Users/zd/.local/share/nvim/lazy/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 2757, in startExplorer or pattern[0] == "'" and pattern[-1] == "'"): ^^^^^^^^^^^^^^^^^ File "/Users/zd/.local/share/nvim/lazy/LeaderF/autoload/leaderf/python/leaderf/rgExpl.py", line 959, in _bangEnter instance.window.cursor = (instance.cursorRow, 0) ^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pynvim/api/window.py", line 27, in cursor return self.request('nvim_win_set_cursor', pos) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pynvim/api/common.py", line 58, in request return self._session.request(name, self, *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pynvim/api/nvim.py", line 182, in request res = self._session.request(name, args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pynvim/msgpack_rpc/session.py", line 102, in request raise self.error_wrapper(err) pynvim.api.common.NvimError: Cursor position outside buffer



### Expected behaviour
`<c-w>o` in the targeted file window should close the result window without error and the result window can be recalled.
dengzhizhi commented 4 months ago

I have tried disabling all other plugins and my other vim configs, only with the LeaderF plugin and the above LeaderF related configuration, still had the same issue.

Yggdroot commented 4 months ago

Fixed.

dengzhizhi commented 3 months ago

Works like a charm. Thanks for the quick fix.