Shougo / defx.nvim

:file_folder: The dark powered file explorer implementation for neovim/Vim8
MIT License
1.17k stars 86 forks source link

Buffer does not exist when opening file #276

Closed fnatte closed 3 years ago

fnatte commented 3 years ago

Problems summary

I should start by saying that this was introduced by c5b0eaa606af67fccd0d0e972ae5e8f16678ef9e. It never happends in ce2a0321400ab3057d6ae03e0866541adb50a642.

Up on opening a file using nnoremap <silent><buffer><expr> l defx#is_directory() ? defx#do_action('open_tree') : defx#do_action('open') I sometimes get a "Buffer ... does not exist" error. If I just hit enter I can continue, and the file is opened correctly. I'm having some difficulty finding a consitent way to reproduce this error.

I have yet to figure out how to reproduce consistently with minimal config. The error occur very frequently when working with somewhat larger folder/file sizes and my full nvim config.

This is the same problem as reported in #274 a couple of days ago.

Expected

No error should occur when opening files.

Environment Information

Output of :checkhealth

``` health#defx#check ======================================================================== ## defx.nvim - OK: has("python3") was successful - OK: Python 3.6.1+ was successful health#nvim#check ======================================================================== ## Configuration - OK: no issues found ## Performance - OK: Build type: Release ## Remote Plugins - OK: Up to date ## terminal - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~ ## tmux - OK: escape-time: 0ms - INFO: $TERM: screen-256color health#provider#check ======================================================================== ## Clipboard (optional) - OK: Clipboard tool found: xclip ## Python 2 provider (optional) - WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics. - ERROR: Python provider error: - ADVICE: - provider/pythonx: Could not load Python 2: /usr/bin/python2 does not have the "neovim" module. :help |provider-python| /usr/bin/python2.7 does not have the "neovim" module. :help |provider-python| python2.6 not found in search path or not executable. /usr/bin/python is Python 3.9 and cannot provide Python 2. - INFO: Executable: Not found ## Python 3 provider (optional) - INFO: `g:python3_host_prog` is not set. Searching for python3 in the environment. - INFO: Executable: /usr/bin/python3 - INFO: Python version: 3.9.0 - INFO: pynvim version: 0.4.2 - OK: Latest pynvim is installed. ## Ruby provider (optional) - INFO: Ruby: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux] - WARNING: `neovim-ruby-host` not found. - ADVICE: - Run `gem install neovim` to ensure the neovim RubyGem is installed. - Run `gem environment` to ensure the gem bin directory is in $PATH. - If you are using rvm/rbenv/chruby, try "rehashing". - See :help |g:ruby_host_prog| for non-standard gem installations. ## Node.js provider (optional) - INFO: Node.js: v15.3.0 - INFO: Neovim node.js host: /usr/lib/node_modules/neovim/bin/cli.js - WARNING: Package "neovim" is out-of-date. Installed: 4.5.0, latest: 4.9.0 - ADVICE: - Run in shell: npm install -g neovim - Run in shell (if you use yarn): yarn global add neovim ```

Minimal init.vim/vimrc

function! DoRemote(arg)
    UpdateRemotePlugins
endfunction

call plug#begin()

Plug 'Shougo/defx.nvim', { 'do': ':UpdateRemotePlugins' }
nnoremap <C-n> :Defx -listed -resume<CR>

call plug#end()

autocmd FileType defx call s:defx_my_settings()
function! s:defx_my_settings() abort
        " Define mappings
        nnoremap <silent><buffer><expr> l defx#is_directory() ?
                \ defx#do_action('open_tree') : defx#do_action('open')
endfunction

Reproduce

  1. mkdir -p 123/456 && touch 123/456/789.txt && touch test.txt
  2. nvim -u init.vim .
  3. Hit ctrl-n, open a file with l
  4. Repeat step 3 until error occurs

Log file

Contents of nvim.log_py3_rplugin

``` 2020-12-05 12:14:06,432 [INFO @ session.py:request:101] 950784 - 'Received error: [0, 'Vim:E86: Buffer 123 does not exist'] 2020-12-05 12:14:06,434 [WARNING @ session.py:handler:200] 950784 - error response from request '_defx_do_action [['open', [], {'columns': 'mark:indent:icon:filename:type', 'winrelative': 'editor', 'auto_cd': False, 'prev_bufnr': 3, 'root_marker': '[in] ', 'resume': False, 'close': False, 'auto_recursive_level': 0, 'sort': 'filename', 'listed': False, 'new': False, 'ignored_files': '.*', 'focus': True, 'direction': '', 'visual_end': 0, 'winheight': 30, 'profile': False, 'preview_height': 12, 'buffer_name': 'default', 'winwidth': 90, 'filtered_files': '', 'split': 'no', 'preview_width': 40, 'visual_start': 0, 'cursor': 6, 'prev_last_bufnr': 3, 'search': '', 'prev_winid': 1000, 'wincol': 22, 'winrow': 16, 'session_file': '', 'floating_preview': False, 'vertical_preview': False, 'show_ignored_files': False, 'drives': [], 'toggle': False}]]': Traceback (most recent call last): File "/usr/lib/python3.9/site-packages/pynvim/plugin/host.py", line 102, in _wrap_function return fn(*args) File "/home/matteus/.config/nvim/plugged/defx.nvim/rplugin/python3/defx/__init__.py", line 39, in do_action self._rplugin.do_action(args) File "/home/matteus/.config/nvim/plugged/defx.nvim/rplugin/python3/defx/rplugin.py", line 39, in do_action view.do_action(args[0], args[1], args[2]) File "/home/matteus/.config/nvim/plugged/defx.nvim/rplugin/python3/defx/view.py", line 130, in do_action ret = action.do_action(self, defx, action_name, context) File "/home/matteus/.config/nvim/plugged/defx.nvim/rplugin/python3/defx/action.py", line 62, in do_action action.func(view, defx, context) File "/home/matteus/.config/nvim/plugged/defx.nvim/rplugin/python3/defx/kind/file.py", line 435, in _open view.restore_previous_buffer(view._prev_bufnr) File "/home/matteus/.config/nvim/plugged/defx.nvim/rplugin/python3/defx/view.py", line 412, in restore_previous_buffer self._vim.call('setreg', '#', File "/usr/lib/python3.9/site-packages/pynvim/api/nvim.py", line 299, in call return self.request('nvim_call_function', name, args, **kwargs) File "/usr/lib/python3.9/site-packages/pynvim/api/nvim.py", line 182, in request res = self._session.request(name, *args, **kwargs) File "/usr/lib/python3.9/site-packages/pynvim/msgpack_rpc/session.py", line 102, in request raise self.error_wrapper(err) pynvim.api.common.NvimError: Vim:E86: Buffer 123 does not exist During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.9/site-packages/pynvim/msgpack_rpc/session.py", line 195, in handler rv = self._request_cb(name, args) File "/usr/lib/python3.9/site-packages/pynvim/api/nvim.py", line 210, in filter_request_cb result = request_cb(name, args) File "/usr/lib/python3.9/site-packages/pynvim/plugin/host.py", line 124, in _on_request rv = handler(*args) File "/usr/lib/python3.9/site-packages/pynvim/plugin/host.py", line 107, in _wrap_function raise ErrorResponse(msg) pynvim.msgpack_rpc.session.ErrorResponse: error caught in request handler '_defx_do_action [['open', [], {'columns': 'mark:indent:icon:filename:type', 'winrelative': 'editor', 'auto_cd': False, 'prev_bufnr': 3, 'root_marker': '[in] ', 'resume': False, 'close': False, 'auto_recursive_level': 0, 'sort': 'filename', 'listed': False, 'new': False, 'ignored_files': '.*', 'focus': True, 'direction': '', 'visual_end': 0, 'winheight': 30, 'profile': False, 'preview_height': 12, 'buffer_name': 'default', 'winwidth': 90, 'filtered_files': '', 'split': 'no', 'preview_width': 40, 'visual_start': 0, 'cursor': 6, 'prev_last_bufnr': 3, 'search': '', 'prev_winid': 1000, 'wincol': 22, 'winrow': 16, 'session_file': '', 'floating_preview': False, 'vertical_preview': False, 'show_ignored_files': False, 'drives': [], 'toggle': False}]]': Traceback (most recent call last): File "/home/matteus/.config/nvim/plugged/defx.nvim/rplugin/python3/defx/__init__.py", line 39, in do_action self._rplugin.do_action(args) File "/home/matteus/.config/nvim/plugged/defx.nvim/rplugin/python3/defx/rplugin.py", line 39, in do_action view.do_action(args[0], args[1], args[2]) File "/home/matteus/.config/nvim/plugged/defx.nvim/rplugin/python3/defx/view.py", line 130, in do_action ret = action.do_action(self, defx, action_name, context) File "/home/matteus/.config/nvim/plugged/defx.nvim/rplugin/python3/defx/action.py", line 62, in do_action action.func(view, defx, context) File "/home/matteus/.config/nvim/plugged/defx.nvim/rplugin/python3/defx/kind/file.py", line 435, in _open view.restore_previous_buffer(view._prev_bufnr) File "/home/matteus/.config/nvim/plugged/defx.nvim/rplugin/python3/defx/view.py", line 412, in restore_previous_buffer self._vim.call('setreg', '#', File "/usr/lib/python3.9/site-packages/pynvim/api/nvim.py", line 299, in call return self.request('nvim_call_function', name, args, **kwargs) File "/usr/lib/python3.9/site-packages/pynvim/api/nvim.py", line 182, in request res = self._session.request(name, *args, **kwargs) File "/usr/lib/python3.9/site-packages/pynvim/msgpack_rpc/session.py", line 102, in request raise self.error_wrapper(err) pynvim.api.common.NvimError: Vim:E86: Buffer 123 does not exist ```

Shougo commented 3 years ago

I have tested it, but I don't reproduce your error!

Shougo commented 3 years ago

Please use the latest version.

fnatte commented 3 years ago

I'm afraid 2079ed512be755e85bb2fa879f7f1fff93418f55 didn't help, but I still cant reproduce it consistently. So I'm clueless atm.

Shougo commented 3 years ago

The problem is fixed?

laughingman-hass commented 3 years ago

Hi, I'm seeing this issue on the latest version. I've included the full stack below. I can keep re-produce it by the following steps.

I don't know if this is also filename related, as it seems it happen when I open a test file similarly named as the file that is already open. for example 10-concurrency/website_checker.go opened first and then error raised when opening 10-concurrency/website_checker_test.go.

error caught in async handler '_defx_async_action [['open', [], {'columns': 'indent:icons:filename:indent:git', 'winrelative': 'editor', 'auto_cd': False, 'prev_bufnr': 2, 'root_marker': '[in] ', 'resume': False,
 'close': False, 'auto_recursive_level': 0, 'sort': 'filename', 'listed': False, 'new': False, 'ignored_files': '.*', 'focus': True, 'direction': '', 'visual_end': 0, 'winheight': 30, 'profile': False, 'preview_h
eight': 12, 'buffer_name': 'default', 'winwidth': 90, 'filtered_files': '', 'split': 'no', 'preview_width': 40, 'visual_start': 0, 'cursor': 3, 'prev_last_bufnr': -1, 'search': '', 'prev_winid': 1001, 'wincol': 2
6, 'winrow': 18, 'session_file': '', 'floating_preview': False, 'vertical_preview': False, 'show_ignored_files': False, 'drives': [], 'toggle': False}]]'
Traceback (most recent call last):
  File "/Users/hass/.config/nvim/pack/packer/opt/defx.nvim/rplugin/python3/defx/__init__.py", line 43, in async_action
    self._rplugin.do_action(args)
  File "/Users/hass/.config/nvim/pack/packer/opt/defx.nvim/rplugin/python3/defx/rplugin.py", line 39, in do_action
    view.do_action(args[0], args[1], args[2])
  File "/Users/hass/.config/nvim/pack/packer/opt/defx.nvim/rplugin/python3/defx/view.py", line 130, in do_action
    ret = action.do_action(self, defx, action_name, context)
  File "/Users/hass/.config/nvim/pack/packer/opt/defx.nvim/rplugin/python3/defx/action.py", line 62, in do_action
    action.func(view, defx, context)
  File "/Users/hass/.config/nvim/pack/packer/opt/defx.nvim/rplugin/python3/defx/kind/file.py", line 435, in _open
    view.restore_previous_buffer(view._prev_bufnr)
  File "/Users/hass/.config/nvim/pack/packer/opt/defx.nvim/rplugin/python3/defx/view.py", line 412, in restore_previous_buffer
    self._vim.call('setreg', '#',
  File "/Users/hass/Library/Python/3.9/lib/python/site-packages/pynvim/api/nvim.py", line 299, in call
    return self.request('nvim_call_function', name, args, **kwargs)
  File "/Users/hass/Library/Python/3.9/lib/python/site-packages/pynvim/api/nvim.py", line 182, in request
    res = self._session.request(name, *args, **kwargs)
  File "/Users/hass/Library/Python/3.9/lib/python/site-packages/pynvim/msgpack_rpc/session.py", line 104, in request
    raise self.error_wrapper(err)
pynvim.api.common.NvimError: Vim:E86: Buffer 10 does not exist
Shougo commented 3 years ago

Really? Really? Really? I don't know why the error is occurred.

Shougo commented 3 years ago

I have added the check and it should work.

Shougo commented 3 years ago

Reproduced. It is filename related problem.

I don't know if this is also filename related, as it seems it happen when I open a test file similarly named as the file that is already open. for example 10-concurrency/website_checker.go opened first and then error raised when opening 10-concurrency/website_checker_test.go.

Thanks.

Shougo commented 3 years ago

Fixed.

laughingman-hass commented 3 years ago

perfect! can confirm it's fixed! 😄