justinmk / vim-dirvish

Directory viewer for Vim :zap:
Other
1.19k stars 64 forks source link

Empty screen when re-enter the same directory #102

Closed yous closed 6 years ago

yous commented 6 years ago

This is a minial vimrc to reproduce:

set nocompatible

call plug#begin()
Plug 'justinmk/vim-dirvish'
call plug#end()

How to reproduce:

  1. Open an existing file
  2. Hit -
  3. Re-open that file by hitting Enter
  4. Hit -

Directories are properly displayed when I execute :Dirvish % at step 4.

Vim version:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 28 2017 06:16:39)
macOS version
Included patches: 1-1350
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    -tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    -gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
-clientserver      +job               +perl              +vertsplit
+clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           +python            +vreplace
+conceal           +linebreak         -python3           +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       -lua               +ruby              -X11
+dialog_con        +menu              +scrollbind        -xfontset
+diff              +mksession         +signs             -xim
+digraphs          +modify_fname      +smartindent       -xpm
-dnd               +mouse             +startuptime       -xsmp
-ebcdic            -mouseshape        +statusline        -xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              -mouse_gpm         +syntax            
+ex_extra          -mouse_jsbterm     +tag_binary        
+extra_search      +mouse_netterm     +tag_old_static    
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework AppKit   -mmacosx-version-min=10.13 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.26.1/lib/perl5/5.26.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -F/usr/local/opt/python/Frameworks -framework Python   -lruby.2.4.2 -lobjc
hauleth commented 6 years ago

This can be resolved by refreshing view using R but this is annoying.

hauleth commented 6 years ago

This bug was introduced in latest commit 2c69d6c62c7212908f3f8db434b56b2992e27921, so pinning to 264ea014d302ea8b4c05c7bda072184a47395149 should temporarily solve the problem.

justinmk commented 6 years ago

Thanks all.

dwayneyuen commented 6 years ago

I still have this issue even though I have the latest update using PlugUpdate. Please let me know if you'd like more details.

hauleth commented 6 years ago

It seemed to be fixed for a while, but is still happening.

justinmk commented 6 years ago

Er... using the same steps as above? After restarting vim?

dwayneyuen commented 6 years ago

I've restarted vim, run PlugUpdate, and tried manually git pulling in the plugin directory. I can replicate the behavior in multiple ways:

justinmk commented 6 years ago

If you change s:buf_modified() to return 0 (and restart vim...) is the problem fixed?

https://github.com/justinmk/vim-dirvish/blob/202e37dce540d648c5f113c217c95085cd41c0a9/autoload/dirvish.vim#L125

In one of the empty dirvish buffers, what does this show:

:echo b:dirvish
:echo b:changedtick
dwayneyuen commented 6 years ago

Making the change to buf_modified fixes the issue.

Running those commands (before the change):

:echo b:dirvish
{'altbuf': -1, '_dir': 'DIR_NAME_WAS_HERE', '_c': 5, 'prevbuf': 1}
:echo b:changedtick
24

After the change, _c and b:changedtick are both 11

yous commented 6 years ago

Here's mine:

:echo b:dirvish
{'altbuf': -1, '_dir': '/path/to/dir/', '_c': 3, 'lastpath': '/path/to/dir/file', 'prevbuf': 1}
:echo b:changedtick
4

Changing s:buf_modified() makes _c and b:changedtick to be the same.

justinmk commented 6 years ago

Oh, do you have 'hidden' option set ?

hauleth commented 6 years ago

No. I like behaviour of nohidden.

-- Łukasz Jan Niemier

Wiadomość napisana przez Justin M. Keyes notifications@github.com w dniu 12.12.2017, o godz. 12:31:

Oh, do you have 'hidden' option set ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

dwayneyuen commented 6 years ago

I don't have hidden set either

justinmk commented 6 years ago

If you have :autocmd FileType dirvish ... handlers setup, can you show them here? Also are you using g:dirvish_relative_paths=1 ?

dwayneyuen commented 6 years ago

I have:

autocmd FileType dirvish silent keeppatterns g@\v/.*\.o|.*\.pyc|.*\.so/?$@d
let g:dirvish_relative_paths = 0

I can replicate the behavior with both of these commented out, or with g:dirvish_relative_paths set to 1.

justinmk commented 6 years ago

Does 17ee209a12884dd6c4c89482b223962a32279389 help?

dwayneyuen commented 6 years ago

Doesn't seem to :(. Ran PlugUpdate which pulled in new changes (also checked manually).

:echo b:dirvish
{'altbuf': -1, '_dir': '/Users/dwayneyuen/', '_c': 4, 'prevbuf': 1}

:echo b:changedtick
5
justinmk commented 6 years ago

Could you put :echom b:changedtick at the beginning of s:do_open(), to see if it changes somewhere after that?

dwayneyuen commented 6 years ago

Sure. :)

1) vi . -> 2 2) - -> 4 3) <enter> -> 3

Same values if I <enter> then - (2, 4, 3).

justinmk commented 6 years ago

thanks, but we also need to know :echo b:dirvish b:changedtick after the buffer is loaded (i.e., do it at the :-prompt). Else there's nothing to compare it. Sorry that wasn't clear.

hauleth commented 6 years ago

@justinmk I have no auto commands.

:echo b:dirvish b:changedtick
{'altbuf': -1, '_dir': '/Users/hauleth/Workspace/hauleth/dotfiles/nvim/', '_c': 20, 'lastpath': '/Users/hauleth/Workspace/hauleth/dotfiles/nvim/init.vim', 'prevbuf': 2} 20

EDIT: ok, for me I haven't encountered it for some time.

dwayneyuen commented 6 years ago

Ah, gotcha.

1) vi . - before: 2, after: {'altbuf': -1, '_dir': '/Users/dwayneyuen/', '_c': 4, 'prevbuf': -1} 4 2) - - before: 4, after: {'altbuf': -1, '_dir': '/Users/', '_c': 3, 'lastpath': '/Users/dwayneyuen/', 'prevbuf': 1} 3 3) <enter> - before: 3, after: {'altbuf': -1, '_dir': '/Users/dwayneyuen/', '_c': 4, 'prevbuf': 1} 5

dwayneyuen commented 6 years ago

I'm running on MacOS High Sierra.

justinmk commented 6 years ago

I can repro it. Will take a look.

justinmk commented 6 years ago

Even with hidden, vim unloads a nobuflisted (or maybe buftype=nofile) buffer if it is not showing in a window.

dwayneyuen commented 6 years ago

https://github.com/justinmk/vim-dirvish/commit/e4b3c4b62d0ddb2d24aa8f9fcf3820f6d6de4ebf fixes the issue for me. Thanks for your help and the amazingly quick turnaround!