From f3226a7d6b10548d2b9f45eb6077399a9df51c21 Mon Sep 17 00:00:00 2001 From: gitusp Date: Fri, 2 Oct 2020 13:59:09 +0900 Subject: [PATCH 1/2] Change normal and visual* mode behavior more strict This change was made to prevent accidentally input a random character like "w" or "b". --- content_scripts/ui.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/content_scripts/ui.js b/content_scripts/ui.js index f990756..4d2b6e0 100644 --- a/content_scripts/ui.js +++ b/content_scripts/ui.js @@ -231,8 +231,21 @@ UI = { this.keyQueue = []; this.cancelEvent(e); Commands.commands[commandName].fn(); + return; } } + + // Cancel the event if the mode matches "normal" or "visual*", + // to prevent accidentally input an unassigned character like "w" or "b". + // Ensure that the key is not pressed with ctrl or meta, + // not to mask Google Sheets' default shortcuts such as ⌘-F. + if ( + !e.ctrlKey && + !e.metaKey && + ["normal", "visual", "visualLine", "visualColumn"].includes(this.mode) + ) { + this.cancelEvent(e); + } }, // modifiers: optiona; an object with these boolean properties: meta, shift, control. From c7e151792962c6963b373a1d43985eb2b7f877f8 Mon Sep 17 00:00:00 2001 From: gitusp Date: Fri, 2 Oct 2020 14:36:23 +0900 Subject: [PATCH 2/2] Assign arrow keys explicitly Since 7acf795 change the behavior to ignore all the unassigned keys. --- content_scripts/commands.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/content_scripts/commands.js b/content_scripts/commands.js index 96f8f6f..7122ccd 100644 --- a/content_scripts/commands.js +++ b/content_scripts/commands.js @@ -92,6 +92,10 @@ Commands = { "j": "moveDown", "h": "moveLeft", "l": "moveRight", + "up": "moveUp", + "down": "moveDown", + "left": "moveLeft", + "right": "moveRight", // Row & column movement "": "moveRowsDown",