mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 09:31:41 -05:00
Simplify page key buffer consumption
This commit is contained in:
parent
dbe5a8e8a6
commit
d7f0435a5a
1 changed files with 9 additions and 14 deletions
|
@ -175,22 +175,17 @@ export function focus() {
|
||||||
return
|
return
|
||||||
if (bufferedPageKeys.length !== 0) {
|
if (bufferedPageKeys.length !== 0) {
|
||||||
const currentClInputValue = commandline_state.clInput.value;
|
const currentClInputValue = commandline_state.clInput.value;
|
||||||
// Native events are assumed to be characters added at the end of clInput.
|
let initialClInputValue = commandline_state.initialClInputValue;
|
||||||
const clInputNativeEventKeysReceived = commandline_state.initialClInputValue.length > currentClInputValue.length
|
|
||||||
logger.debug("Consuming buffered page keys", bufferedPageKeys,
|
logger.debug("Consuming buffered page keys", bufferedPageKeys,
|
||||||
"initialClInputValue = " + commandline_state.initialClInputValue,
|
"initialClInputValue = " + initialClInputValue,
|
||||||
"currentClInputValue = " + currentClInputValue);
|
"currentClInputValue = " + currentClInputValue);
|
||||||
if (clInputNativeEventKeysReceived) {
|
// Native events are assumed to be characters added at the end of clInput.
|
||||||
// Insert page keys at the end.
|
// If the user edits the command (initial clInput value) before the buffered page keys are received, we are out of luck.
|
||||||
commandline_state.clInput.value += bufferedPageKeys.join("")
|
|
||||||
} else {
|
|
||||||
let initialClInputValueLength = commandline_state.initialClInputValue.length;
|
|
||||||
// Insert page keys just after the command.
|
// Insert page keys just after the command.
|
||||||
commandline_state.clInput.value =
|
commandline_state.clInput.value =
|
||||||
currentClInputValue.substring(0, initialClInputValueLength)
|
initialClInputValue
|
||||||
+ bufferedPageKeys.join("")
|
+ bufferedPageKeys.join("")
|
||||||
+ currentClInputValue.substring(initialClInputValueLength)
|
+ currentClInputValue.substring(initialClInputValue.length)
|
||||||
}
|
|
||||||
// Update completion.
|
// Update completion.
|
||||||
clInputValueChanged()
|
clInputValueChanged()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue