mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-08 13:11:19 +08:00
impr(commandline): when using single list mode, press the up arrow to repeat previous command
This commit is contained in:
parent
063a6901a6
commit
9f7aeac5af
1 changed files with 24 additions and 0 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue