Skip to content

Commit

Permalink
fix: exiting insert mode with "<esc><esc>"
Browse files Browse the repository at this point in the history
For me, the following bug was happening:
- I start yazi and see yazi in the floating terminal
- I press "<esc><esc>" (esc twice)
- pressing j does not make yazi move the focus to the next file. Instead
  the terminal seems to be in normal mode and the cursor moves down.

This only happens once in the neovim session.

It was possible to work around this issue by pressing `i` to seemingly
enter insert mode again 😄

This commit works around the issue by always entering insert mode when
the mode changes.

This seems like a pretty stupid solution, so let's hope it causes no
problems 🤞🏻
  • Loading branch information
mikavilpas committed Jun 16, 2024
1 parent 4318d03 commit bc2aabb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lua/yazi/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ function YaziFloatingWindow:open_and_display()
self:add_hacky_mouse_support(yazi_buffer)
end

vim.api.nvim_create_autocmd('ModeChanged', {
buffer = yazi_buffer,
callback = function()
-- HACK Sometimes pressing "<esc><esc>" exits insert mode the first time it's pressed.
-- Work around this by starting insert mode after the first time the mode changes.
vim.cmd('startinsert')
end,
})

vim.api.nvim_create_autocmd({ 'VimResized' }, {
buffer = yazi_buffer,
callback = function()
Expand Down

0 comments on commit bc2aabb

Please sign in to comment.