Skip to content

Commit 2cf81ea

Browse files
committed
ai-command: store last 15 commands
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent 060c125 commit 2cf81ea

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

ai-command/ai-command.qml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,23 @@ Script {
2323
return;
2424
}
2525

26-
let command = script.inputDialogGetText("AI Command", "Please enter a command");
26+
let pastCommands = JSON.parse(script.getPersistentVariable('aiCommand/pastCommands', '[]'));
27+
let command = script.inputDialogGetItem("AI Command", "Please enter a command", pastCommands, 0, true);
2728

2829
if (command === '') {
2930
return;
3031
}
3132

33+
// Remove any existing occurrences of command
34+
pastCommands = pastCommands.filter(cmd => cmd !== command);
35+
36+
// Add command to the beginning
37+
pastCommands.unshift(command);
38+
39+
// Trim the array to the last 15 entries
40+
pastCommands = pastCommands.slice(0, 15);
41+
42+
script.setPersistentVariable('aiCommand/pastCommands', JSON.stringify(pastCommands));
3243
const text = script.noteTextEditSelectedText();
3344
const aiResult = script.aiComplete(
3445
"Execute the following command on the Markdown text afterwards, just output the result. " +

ai-command/info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"script": "ai-command.qml",
55
"authors": ["@pbek"],
66
"platforms": ["linux", "macos", "windows"],
7-
"version": "0.1.0",
7+
"version": "0.1.1",
88
"minAppVersion": "24.11.4",
99
"description" : "This script allows just send a written command to the AI completer to replace the selected text, but showing the differences first."
1010
}

0 commit comments

Comments
 (0)