Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: removing open file mangles window selector functionality #512

Closed
brandon1024 opened this issue Oct 25, 2024 · 5 comments · Fixed by #517
Closed

bug: removing open file mangles window selector functionality #512

brandon1024 opened this issue Oct 25, 2024 · 5 comments · Fixed by #517
Labels
bug Something isn't working

Comments

@brandon1024
Copy link
Contributor

Issue Description

Whenever you remove a file (<plugin>(fern-action-remove)) that happens to be the only file open in a window, the file is deleted, the buffer is unloaded, the window is closed, and the fern window is adjusted to fill the screen. This works as expected.

However when this happens, the<plugin>(fern-action-open:select) mapping no longer works as expected. It offers to open files in the fern window too, though normally it doesn't offer this window to be used. I haven't figured out how to work around this, aside from reloading vim. A bit annoying.

You can see what I mean from the screenshot below. Usually it doens't offer to open in the Fern window.

image

@lambdalisue
Copy link
Owner

Please write a minimal vimrc and step by step procedure to reproduce that situation.

@brandon1024
Copy link
Contributor Author

I put together a minimal vimrc to help reproduce this. It'll create two files in your current working directory, test-1 and test-2.

set packpath=

" UPDATE WITH YOUR PATH
set runtimepath^=/home/brandon/.dotfiles/.vim/pack/plugins/opt/vim-fern

filetype plugin indent on
syntax on
"----------------------------------------------------------------

" Add extra settings here to reproduce the issue...

"----------------------------------------------------------------
echomsg "Reproducing lambdalisue/vim-fern Issue #512"
echomsg "See Further: https://github.com/lambdalisue/vim-fern/issues/512"
echomsg "To reproduce the issue, execute:"
echomsg "  :call Reproduce()"

let g:fern#window_selector_use_popup = 1

function! Reproduce() abort
	" create two empty files
	edit test-1 | write
	edit test-2 | write

	" open the fern window
	Fern . -toggle -drawer -width=50 -keep -wait -reveal=%

	" With the Fern window and 'test-2' open, remove file 'test-2'.
	execute "normal \<plug>(fern-action-remove=)y\<CR>"

	" Reopen 'test-1'.
	edit test-1

	" Show the Fern window again.
	Fern . -toggle -drawer -width=50 -keep -wait -reveal=%

	" Finally, open (select) 'test-1'.
	:exe "normal \<plug>(fern-action-open:select)"
endfunction

To reproduce:

$ vim -N -u ~/Downloads/vim-fern-512-reproduce.vim

" Reproduce the issue.
:call Reproduce()

You should see something like this:

image

@lambdalisue
Copy link
Owner

Reproduced. I'll investigate.

@lambdalisue
Copy link
Owner

@brandon1024 Could you try #517

@brandon1024
Copy link
Contributor Author

Fixed in #517 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants