telescope.nvim
telescope.nvim copied to clipboard
restore buffers after git_reset_branch function
After undoing commits with telescope's git_reset_branch
function, the buffers do not reload and still show the old state. Therefore I added a restore_buffers
function in actions/utils.lua, that does exactly that:
- reloading all the buffers with
vim.cmd("bufdo e")
- turn syntax on again with
vim.cmd("syntax on")
(becausebufdo
may turn off syntax to increase speed) - show previously shown buffer with
vim.cmd("b" .. currentBuff)
(because with multiple buffers opened,bufdo
will change the view and not return back to the previously shown buffer)
The restore_buffers
function could also be used in other git functions. Which is why I added it to the utils module.
Interesting fix. I have auto-read enabled so when the file on disk changes the buffer gets updated but this seems to be better way to avoid some errors, in particular, I'm interested to know what will happen in the following cases:
- buffers open but not saved yet.
- buffers open but no longer exists after a git command
Additionally, what other function do u think we should have this in.
Thanks for the detailed explanation
Hi tami5 Thanks for your answer.
I have no clue yet about how to treat the situations you mentioned.
Here are other functions that (I think) could make usage of the restore_buffer function: git_switch_branch git_apply_stash git_checkout git_merge_branch git_rebase_branch git_reset_branch
I tried set autoread in vimrc, but it didn't work as expected: After git_switch_branch, the buffer still showed old branch state. Only after clicking outside the terminal window and clicking back into it, the buffer showed the new state. Maybe it's a setting of my terminal?
best regards
Any update ?