mirror of
https://github.com/vale981/tridactyl
synced 2025-03-04 17:11:40 -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
|
||||
if (bufferedPageKeys.length !== 0) {
|
||||
const currentClInputValue = commandline_state.clInput.value;
|
||||
// Native events are assumed to be characters added at the end of clInput.
|
||||
const clInputNativeEventKeysReceived = commandline_state.initialClInputValue.length > currentClInputValue.length
|
||||
let initialClInputValue = commandline_state.initialClInputValue;
|
||||
logger.debug("Consuming buffered page keys", bufferedPageKeys,
|
||||
"initialClInputValue = " + commandline_state.initialClInputValue,
|
||||
"initialClInputValue = " + initialClInputValue,
|
||||
"currentClInputValue = " + currentClInputValue);
|
||||
if (clInputNativeEventKeysReceived) {
|
||||
// Insert page keys at the end.
|
||||
commandline_state.clInput.value += bufferedPageKeys.join("")
|
||||
} else {
|
||||
let initialClInputValueLength = commandline_state.initialClInputValue.length;
|
||||
// Native events are assumed to be characters added at the end of clInput.
|
||||
// If the user edits the command (initial clInput value) before the buffered page keys are received, we are out of luck.
|
||||
// Insert page keys just after the command.
|
||||
commandline_state.clInput.value =
|
||||
currentClInputValue.substring(0, initialClInputValueLength)
|
||||
initialClInputValue
|
||||
+ bufferedPageKeys.join("")
|
||||
+ currentClInputValue.substring(initialClInputValueLength)
|
||||
}
|
||||
+ currentClInputValue.substring(initialClInputValue.length)
|
||||
// Update completion.
|
||||
clInputValueChanged()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue