diff --git a/src/content.ts b/src/content.ts index c96f8bde..57646300 100644 --- a/src/content.ts +++ b/src/content.ts @@ -302,7 +302,7 @@ config.getAsync("modeindicator").then(mode => { dom.isTextEditable(document.activeElement) && !["input", "ignore"].includes(mode) ) { - statusIndicator.textContent = "insert" + result = "insert" // this doesn't work; statusIndicator.style is full of empty string // statusIndicator.style.borderColor = "green !important" // need to fix loss of focus by click: doesn't do anything here. @@ -310,7 +310,7 @@ config.getAsync("modeindicator").then(mode => { mode === "insert" && !dom.isTextEditable(document.activeElement) ) { - statusIndicator.textContent = "normal" + result = "normal" // statusIndicator.style.borderColor = "lightgray !important" } else { result = mode diff --git a/src/content/controller_content.ts b/src/content/controller_content.ts index 1dc9376e..2fceac9e 100644 --- a/src/content/controller_content.ts +++ b/src/content/controller_content.ts @@ -106,6 +106,7 @@ function* ParserController() { while (true) { let exstr = "" + let previousSuffix = null let keyEvents: KeyEventLike[] = [] try { while (true) { @@ -145,6 +146,12 @@ function* ParserController() { contentState.mode = "normal" } + const newMode = contentState.mode + if (newMode !== currentMode) { + keyEvents = [] + previousSuffix = null + } + // Accumulate key events. The parser will cut this // down whenever it's not a valid prefix of a known // binding, so it can't grow indefinitely unless you @@ -175,14 +182,18 @@ function* ParserController() { } else { keyEvents = response.keys // show current keyEvents as a suffix of the contentState - contentState.suffix = keyEvents + const suffix = keyEvents .map(x => PrintableKey(x)) .join("") - logger.debug("suffix: ", contentState.suffix) + if (previousSuffix !== suffix) { + contentState.suffix = suffix + previousSuffix = suffix + } + logger.debug("suffix: ", suffix) } } - controller.acceptExCmd(exstr) contentState.suffix = "" + controller.acceptExCmd(exstr) } catch (e) { // Rumsfeldian errors are caught here logger.error("An error occurred in the content controller: ", e)