diff options
author | Miodec <[email protected]> | 2024-10-16 14:28:49 +0200 |
---|---|---|
committer | Miodec <[email protected]> | 2024-10-16 14:28:49 +0200 |
commit | 9f7aeac5af64938c321ebac8aa076d2e1144fd50 (patch) | |
tree | f30648b6ada6dc2404bc50f664dbfddea19771c5 | |
parent | 063a6901a61ede9d58bb51eb07d64083bd7b5bbb (diff) | |
download | monkeytype-9f7aeac5af64938c321ebac8aa076d2e1144fd50.tar.gz monkeytype-9f7aeac5af64938c321ebac8aa076d2e1144fd50.zip |
impr(commandline): when using single list mode, press the up arrow to repeat previous command
-rw-r--r-- | frontend/src/ts/commandline/commandline.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/frontend/src/ts/commandline/commandline.ts b/frontend/src/ts/commandline/commandline.ts index f8b0c58e5..acceb130b 100644 --- a/frontend/src/ts/commandline/commandline.ts +++ b/frontend/src/ts/commandline/commandline.ts @@ -34,6 +34,7 @@ let inputModeParams: InputModeParams = { }; let subgroupOverride: CommandsSubgroup | null = null; let isAnimating = false; +let lastSingleListModeInputValue = ""; function removeCommandlineBackground(): void { $("#commandLine").addClass("noBackground"); @@ -509,6 +510,9 @@ async function runActiveCommand(): Promise<void> { command.exec?.({ commandlineModal: modal, }); + if (Config.singleListCommandLine === "on") { + lastSingleListModeInputValue = inputValue; + } const isSticky = command.sticky ?? false; if (!isSticky) { void AnalyticsController.log("usedCommandLine", { command: command.id }); @@ -574,6 +578,14 @@ function updateInput(setInput?: string): void { } else { iconElement.innerHTML = '<i class="fas fa-search"></i>'; element.placeholder = "Search..."; + + let length = inputValue.length; + if (setInput !== undefined) { + length = setInput.length; + } + setTimeout(() => { + element.setSelectionRange(length, length); + }, 0); } } @@ -631,6 +643,18 @@ const modal = new AnimatedModal({ (e.ctrlKey && (e.key.toLowerCase() === "k" || e.key.toLowerCase() === "p")) ) { + if ( + Config.singleListCommandLine === "on" && + inputValue === "" && + lastSingleListModeInputValue !== "" + ) { + inputValue = lastSingleListModeInputValue; + updateInput(); + await filterSubgroup(); + await showCommands(); + await updateActiveCommand(); + return; + } e.preventDefault(); await decrementActiveIndex(); } |