Skip to content

Commit

Permalink
WinEnter: avoid re-init if buffer was modified by the user
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmk committed Dec 12, 2017
1 parent 202e37d commit 275320c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Features
- 2x faster than netrw
- Visual selection opens multiple files
- `:Shdo` generates a shell script on selected files
- `:Shdo!` generates a shell script on the Vim arglist
- `:Shdo!` generates a shell script on the local [arglist](https://neovim.io/doc/user/editing.html#arglist)
- Less code, fewer bugs (96% smaller than netrw)
- Compatible with Vim 7.2+

Expand Down
9 changes: 3 additions & 6 deletions autoload/dirvish.vim
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ function! s:on_bufenter() abort

if empty(getline(1)) && 1 == line('$')
Dirvish %
return
endif
if 0 == &l:cole
elseif 3 != &l:conceallevel && !s:buf_modified()
call s:win_init()
endif
endfunction
Expand Down Expand Up @@ -393,8 +391,7 @@ function! s:do_open(d, reload) abort
endif

if s:sl(bufname('%')) !=# d._dir "We have a bug or Vim has a regression.
echoerr 'expected buffer name: "'.d._dir.'" (actual: "'.bufname('%').'")'
return
throw 'expected buffer name: "'.d._dir.'" (actual: "'.bufname('%').'")'
endif

if -1 == bnr && exists("#BufNew") " Fire BufNew with the normalized file name.
Expand Down Expand Up @@ -422,7 +419,7 @@ function! s:should_reload() abort
if line('$') < 1000 || '' ==# glob(getline('$'),1)
return !s:buf_modified()
endif
redraw | echo 'dirvish: too many files; showing cached listing'
redraw | echo 'dirvish: showing cached listing ("R" to reload)'
return 0
endfunction

Expand Down

0 comments on commit 275320c

Please sign in to comment.