Shougo / defx.nvim

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

Cursor moves down significantly when opening a folder in defx file explorer #334

Closed hexh250786313 closed 1 year ago

hexh250786313 commented 1 year ago

Problems summary

I'm experiencing an issue where, when I open a folder in the Defx file browser, the current cursor position moves down significantly. This problem seems to occur only in Neovim's 0.10 nightly version. In 0.91, it behaves correctly. I suspect this might be due to recent changes in Neovim. To illustrate this issue more clearly, I've recorded a video.

Expected

No moving when toggle a folder.

Environment Information

Provide a minimal init.vim/vimrc with less than 50 lines (Required!)

" mini.vim
set runtimepath^=/path/to/defx.nvim

function! DEFX_MY_SETTINGS() abort
  nnoremap <silent><buffer><expr> o     defx#do_action('open_tree', 'toggle')
endfunction

autocmd FileType defx exec 'call DEFX_MY_SETTINGS()'
# gen.sh
#!/bin/bash

for folder in {1..2}; do
  mkdir "folder$folder"
  cd "folder$folder"
  for file in {1..100}; do
    touch "file$file.txt"
  done
  cd ..
done

The reproduce ways from neovim/Vim starting (Required!)

  1. make some folders
  2. open neovim
  3. :Defx
  4. open folder1
  5. let folder2 stay at the middle of screen(zz it)
  6. open and close folder2 and you can see its moving

Screen shot

https://github.com/Shougo/defx.nvim/assets/26080416/bde6938c-5594-4faf-ba3d-1ba807a216e3

hexh250786313 commented 1 year ago

@Shougo Thank you very much for your dedication. Even though Defx is no longer receiving new features, it remains my favorite file browser. I hope it continues to work flawlessly on all Vim versions

Shougo commented 1 year ago

I don't reproduce it in NVIM v0.10.0-dev-2400+gd27214331. Please use the latest version.

And I have finished defx.nvim development. You should use ddu-ui-filer instead.

hexh250786313 commented 1 year ago

@Shougo I use NVIM v0.10.0-dev-1031+gc431d820e which is the latest nightly version. And I tried build nvim from source and the issue can be reproduced also.

Shougo commented 1 year ago

NVIM v0.10.0-dev-1031+gc431d820e is not the latest version. It seems old.

% git log c431d    
commit c431d820e7be1c511d3d16e89cdffaa21b7909fa
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Mon Sep 4 08:49:50 2023 +0800

    vim-patch:9.0.1856: issues with formatting positional arguments (#25013)

    Problem:  issues with formatting positional arguments
    Solution: fix them, add tests and documentation

    closes: vim/vim#12140
    closes: vim/vim#12985

    Tentatively fix message_test. Check NULL ptr.

    https://github.com/vim/vim/commit/aa90d4f031f73a34aaef5746931ea746849a2231

    Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>

And I tried build nvim from source and the issue can be reproduced also.

Really? Why I cannot reproduce the problem? Please upload the version number.

Shougo commented 1 year ago

Please test your configuration is really minimal. I have checked defx's code and I have not found normal!.

Shougo commented 1 year ago

OK. I have reproduced.

hexh250786313 commented 1 year ago

@Shougo I test the neovim commits one by one. This issue may be caused by https://github.com/neovim/neovim/commit/4c69279f97e566277a33b81146b26b7ca20de4f3

Shougo commented 1 year ago

Fixed.