From 6f625bbfe996f79317ffdfee747cad880f6e82fe Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Fri, 8 Jul 2016 08:00:18 +0200 Subject: [PATCH] Make it possible to escape from stuck "auto insert mode" With this commit, `` resets `vim.focusType` to 'none', in case we somehow have gotten stuck with 'editable'. The button now also runs the `esc` command, making it a true escape hatch: Clicking it not only lets you escape from other modes back to Normal mode, but also blurs stuff and makes sure that `vim.focusType` is 'none'. --- extension/lib/button.coffee | 4 ++++ extension/lib/commands.coffee | 2 ++ 2 files changed, 6 insertions(+) diff --git a/extension/lib/button.coffee b/extension/lib/button.coffee index 9ec29d4..d9addb3 100644 --- a/extension/lib/button.coffee +++ b/extension/lib/button.coffee @@ -38,6 +38,10 @@ injectButton = (vimfx) -> window = button.ownerGlobal return unless vim = vimfx.getCurrentVim(window) + # If we somehow have gotten stuck with `vim.focusType == 'editable'`, + # allow the buttton to reset to 'none'. + vimfx.modes.normal.commands.esc.run({vim}) + if vim.mode == 'normal' help.toggleHelp(window, vimfx) else diff --git a/extension/lib/commands.coffee b/extension/lib/commands.coffee index 0bbc4b5..4d9618b 100644 --- a/extension/lib/commands.coffee +++ b/extension/lib/commands.coffee @@ -852,6 +852,8 @@ commands.esc = ({vim}) -> unless help.getSearchInput(vim.window)?.getAttribute('focused') help.removeHelp(vim.window) + vim._setFocusType('none') # Better safe than sorry. + module.exports = { -- 2.39.3