-
-
Notifications
You must be signed in to change notification settings - Fork 49
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
Fern wrongly overwrites a new, non-fern buffer in certain situation.
Reproduce steps
- Prepare this
repro.vim
set nocompatible
" Please modify this path.
set runtimepath^=~/.cache/vim/pack/minpac/opt/vim-fern/
autocmd VimEnter * ++once call timer_start(10, {-> s:repro()})
function s:repro() abort
Fern /
split
enew
endfunction- Run Vim with
vim -u repro.vim - The current buffer (bufnr must be 2) has a file tree display although it's a anonymous, non-fern buffer.
Environment
- Vim 9.1.842
- Neovim v0.11.0-dev-1108+g5a86360400
The cause of this bug
- At the
splitcommand at line 2 ins:reprofunction, fern's auto duplication feature will create new fern buffer and trigger asynchronous viewer draws. At this time, the draws are not done yet and the new buffer is empty.
+----------------------------------------+
| bufnr:2 |
| bufname:fern://... |
+----------------------------------------+
| bufnr:1 |
| bufname:fern://... |
+----------------------------------------+
enewcommand at line 3 ins:reprofunction opens a new empty buffer. However, sinceenewreuse the current buffer if it's not modified, the current buffer will be a non-fern buffer with keeping its bufnr same to one that the previously created fern buffer had.
+----------------------------------------+
| bufnr:2 |
| bufname:(anonymous) |
+----------------------------------------+
| bufnr:1 |
| bufname:fern://... |
+----------------------------------------+
- Since the bufnr is same, fern.vim's drawer will draw its contents to current buffer though it's no longer a fern buffer.
+----------------------------------------+
| bufnr:2 |
| bufname:(anonymous, wrongly written) |
+----------------------------------------+
| bufnr:1 |
| bufname:fern://... |
+----------------------------------------+
(EDIT: Fix buffer positions in figures)
lambdalisue
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working