wfxr / forgit

:zzz: A utility tool powered by fzf for using git interactively.
MIT License
4.32k stars 136 forks source link

feat: add a keybind to open current file in editor #313

Closed wfxr closed 1 year ago

wfxr commented 1 year ago

Check list

Description

Add a keybind alt-e to allow open current file in default editor. This will facilitate doing diff and modify loop.

Type of change

Test environment

wfxr commented 1 year ago

Great idea, this could massively improve my workflow! I've requested a minor improvement though.

Done.

carlfriedrich commented 1 year ago

@wfxr Great addition, works for me!

@sandr01d Great idea as well! However, refreshing does not work correctly for me. For some reason, the fzf screen is not fully redrawn after quitting the editor, so that I get a mixture of shell promts and fzf. Any idea why this might be the case?

And some further idea: consider you edit the file and revert all the changes, then the file should not appear in the fzf dialog at all afterwards. Maybe this can be achieved with the reload() action of fzf? Haven't tried it, because I do not have time right now. But maybe someone of you might check that?

wfxr commented 1 year ago

@sandr01d Great idea as well! However, refreshing does not work correctly for me. For some reason, the fzf screen is not fully redrawn after quitting the editor, so that I get a mixture of shell promts and fzf. Any idea why this might be the case?

@carlfriedrich Press CTRL-L to flush the buffer usually works when I sometimes have a similar problem when resizing the window.

And some further idea: consider you edit the file and revert all the changes, then the file should not appear in the fzf dialog at all afterwards. Maybe this can be achieved with the reload() action of fzf? Haven't tried it, because I do not have time right now. But maybe someone of you might check that?

I tried and couldn't find a way to get reload() action to work for this purpose. Maybe we can improve it in a future pr?

EDIT

I have changed my mind, and tend to keep the file list as fzf started, even if changes on a specified file are reverted. This gives us the opportunity to select and edit it again easily. So IMO @sandr01d's refresh-preview improvement is good enough. What do you think?

sandr01d commented 1 year ago

@sandr01d Great idea as well! However, refreshing does not work correctly for me. For some reason, the fzf screen is not fully redrawn after quitting the editor, so that I get a mixture of shell promts and fzf. Any idea why this might be the case?

@carlfriedrich I can not reproduce this. Does this happen only with the refresh-preview or also without it?

I have changed my mind, and tend to keep the file list as fzf started, even if changes on a specified file are reverted. This gives us the opportunity to select and edit it again easily. So IMO @sandr01d's refresh-preview improvement is good enough. What do you think?

I definitively see the use case here. Might be a bit confusing for some users though. Maybe we could be transparent about it and indicate that the file has no changes anymore in the preview, similar as we do here:

https://github.com/wfxr/forgit/blob/ec1bd214683d1244f2512222dee11ac467e4ed17/bin/git-forgit#LL588C1-L594C6

carlfriedrich commented 1 year ago

@carlfriedrich I can not reproduce this. Does this happen only with the refresh-preview or also without it?

@sandr01d It actually happens with and without it, so adding it is good in either way.

@carlfriedrich Press CTRL-L to flush the buffer usually works when I sometimes have a similar problem when resizing the window.

@wfxr That works indeed, thanks for the hint!

I have changed my mind, and tend to keep the file list as fzf started, even if changes on a specified file are reverted. This gives us the opportunity to select and edit it again easily. So IMO @sandr01d's refresh-preview improvement is good enough. What do you think?

I see your point and agree with you.