mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 17:41:40 -05:00
Avoid unnecessary suffix
message.
In insert mode, each keypress will send a suffix message through Proxy and the suffix == "". Which is useless and rather heavy. Avoid that.
This commit is contained in:
parent
84ae795f34
commit
5f5fe2e671
1 changed files with 13 additions and 4 deletions
|
@ -106,6 +106,7 @@ function* ParserController() {
|
|||
|
||||
while (true) {
|
||||
let exstr = ""
|
||||
let previousSuffix = null
|
||||
let keyEvents: KeyEventLike[] = []
|
||||
try {
|
||||
while (true) {
|
||||
|
@ -145,6 +146,11 @@ function* ParserController() {
|
|||
contentState.mode = "normal"
|
||||
}
|
||||
|
||||
const newMode = contentState.mode
|
||||
if (newMode !== currentMode) {
|
||||
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
|
||||
|
@ -172,17 +178,20 @@ function* ParserController() {
|
|||
if (response.exstr) {
|
||||
exstr = response.exstr
|
||||
break
|
||||
} else {
|
||||
} else if (!["input", "insert", "ignore"].includes(newMode)) {
|
||||
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue