Merge pull request #2232 from mozbugbox/insert-mode-fixes

Insert mode fixes
This commit is contained in:
Oliver Blanthorn 2020-03-24 16:08:18 +00:00 committed by GitHub
commit 8a5411432b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View file

@ -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

View file

@ -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)