Closed nickjj closed 4 years ago
https://github.com/lambdalisue/fern.vim/issues/155
Are you sure the fern is the latest?
Also, I'm finding that if I move a file to a different directory that exists with fern and I save and get that error, fern sometimes tries to reveal the old location instead of the new one when toggling fern. I can't figure out how to reproduce this one yet but it happens a lot. It might be related so I'm including that info here.
I'm sorry but I don't get what you mean. Please create a new issue with a little bit easier English.
Are you sure the fern is the latest?
Yes, latest master. I just pulled it a few seconds ago to be sure.
Could not reproduce with
" vim -u ~/.vim/vimrc.min
if has('vim_starting')
set nocompatible
endif
nnoremap ; :
nnoremap : ;
set packpath=
set runtimepath+=~/.config/nvim/pack/minpac/start/fern.vim
filetype plugin indent on
syntax on
$ touch foo
vim -u ~/.vim/vimrc.min
:e foo
:Fern .
foo
and hit a
move
then bar
(move foo
to bar
):e bar
:w
So please provide minimal vimrc and reproducible steps.
Did you try it on Vim 8.2?
And did you try it after toggling / revealing the file instead of manually selecting it?
Please provide a step by step procedure. It's tough for me to find a correct procedure from a long English paragraph.
Did you try it on Vim 8.2?
This is it!
Fern related config:
" Disable netrw.
let g:loaded_netrw = 1
let g:loaded_netrwPlugin = 1
let g:loaded_netrwSettings = 1
let g:loaded_netrwFileHandlers = 1
augroup my-fern-hijack
autocmd!
autocmd BufEnter * ++nested call s:hijack_directory()
augroup END
function! s:hijack_directory() abort
let path = expand('%:p')
if !isdirectory(path)
return
endif
bwipeout %
execute printf('Fern %s', fnameescape(path))
endfunction
" Custom settings and mappings.
let g:fern#disable_default_mappings = 1
noremap <silent> <Leader>f :Fern . -drawer -reveal=% -toggle -width=35<CR><C-w>=
function! FernInit() abort
nmap <buffer><expr>
\ <Plug>(fern-my-open-expand-collapse)
\ fern#smart#leaf(
\ "\<Plug>(fern-action-open:select)",
\ "\<Plug>(fern-action-expand)",
\ "\<Plug>(fern-action-collapse)",
\ )
nmap <buffer> <CR> <Plug>(fern-my-open-expand-collapse)
nmap <buffer> <2-LeftMouse> <Plug>(fern-my-open-expand-collapse)
nmap <buffer> n <Plug>(fern-action-new-path)
nmap <buffer> d <Plug>(fern-action-remove)
nmap <buffer> m <Plug>(fern-action-move)
nmap <buffer> M <Plug>(fern-action-rename)
nmap <buffer> h <Plug>(fern-action-hidden-toggle)j
nmap <buffer> r <Plug>(fern-action-reload)
nmap <buffer> k <Plug>(fern-action-mark-toggle)j
nmap <buffer> b <Plug>(fern-action-open:split)
nmap <buffer> v <Plug>(fern-action-open:vsplit)
nmap <buffer><nowait> < <Plug>(fern-action-leave)
nmap <buffer><nowait> > <Plug>(fern-action-enter)
endfunction
augroup FernGroup
autocmd!
autocmd FileType fern call FernInit()
augroup END
Test set up:
mkdir -p /tmp/testfern/ok \
&& cd /tmp/testfern \
&& touch ok/1
vim .
Within Vim:
:e ok/1
Leader+f
m
Rename the file from `1` to `2`
Focus the new `2` file in the buffer
:w
Notice the E13 error
It seems BufWriteCmd
is not used in Vim 8.2. I've no idea why.
https://github.com/lambdalisue/fern.vim/blob/master/autoload/fern/scheme/file/bufutil.vim#L42
when set allows you to rename a file and then have the newly renamed file replace the old file in the buffer and retain things like syntax highlighting, jumps, etc.
https://github.com/lambdalisue/fern.vim/issues/129
I thought NERDTree retain the (modified & unsaved) content or whatever but it seems they just open a new file and close the old buffer. It's simple. We can do that easily.
In contrast to that, current fern retains modified & unsaved content or undo history or whatever while it uses exactly same buffer. So it can be an advantage if I could make it.
OK. Let's remove that feature first.
https://github.com/lambdalisue/fern.vim/pull/167
I think I've found a workaround. Please try the following @nickjj https://github.com/lambdalisue/fern.vim/pull/168
I haven't done an extensive test but in the repeatable work flow listed above, E13 no longer occurs and the file renames / saves correctly with the issue165-v2
branch. Nice work!
Hi,
It's reproduceable.
100% of the time after I move a file using fern, when I save the file with
:w
it will error out withE13 file exists, add ! to override
. Then I save the file withw!
and after that I don't have issues as long as I don't rename the file again.Perhaps this has to do with the recent issue / PR related to removing the old file in the buffer and swapping it with the newly renamed file?
Also, I'm finding that if I move a file to a different directory that exists with fern and I save and get that error, fern sometimes tries to reveal the old location instead of the new one when toggling fern. I can't figure out how to reproduce this one yet but it happens a lot. It might be related so I'm including that info here.