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

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

Closed
2 of 6 tasks
dengzhizhi opened this issue Jul 4, 2024 · 3 comments
Closed
2 of 6 tasks

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

dengzhizhi opened this issue Jul 4, 2024 · 3 comments

Comments

@dengzhizhi
Copy link

  • vim or neovim?
    • vim
    • neovim
  • Output of vim --version or nvim --version:
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1692716794
  • Output of :echo has("python"): 0
  • Output of :echo has("python3"): 1
  • Output of :echo &pythondll(only vim, not neovim):
  • Output of :echo &pythonthreedll(only vim, not neovim):
  • Output of :py print(sys.version): 3.11.4 (v3.11.4:d2340ef257, Jun 6 2023, 19:15:51) [Clang 13.0.0 (clang-1300.0.29.30)]
  • Output of :py3 print(sys.version): Same as above
  • Output of :echo g:Lf_Debug_Cmd:
  • Output of :echo g:Lf_FilesFromCache:
  • Operating system:
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Configurations related to LeaderF in vimrc:
" Cache file for faster file search, use <F5> to refresh
let g:Lf_UseCache = 1

" 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 = {'<C-J>': ['<C-N>'], '<C-K>': ['<C-P>']}

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 "<string>", line 1, in <module>
  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 dengzhizhi changed the title <C-W>o causes Autocommands cuased command to abort error Jul 4, 2024
@dengzhizhi
Copy link
Author

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 added a commit that referenced this issue Jul 4, 2024
@Yggdroot
Copy link
Owner

Yggdroot commented Jul 4, 2024

Fixed.

@Yggdroot Yggdroot closed this as completed Jul 6, 2024
@dengzhizhi
Copy link
Author

Works like a charm. Thanks for the quick fix.

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