TERMINAL: Fix autocompletion when running scripts with the "./" command (#900)

This commit is contained in:
François Gannaz 2023-10-30 17:32:11 +01:00 committed by GitHub
parent 6f67224146
commit 87e2f5c23b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

@ -277,12 +277,18 @@ export async function getTabCompletionPossibilities(terminalText: string, baseDi
return possibilities;
default:
if (!onCommand) {
const options = await scriptAutocomplete();
if (options) {
addGeneric({ iterable: options, usePathing: false });
}
}
return possibilities;
}
async function scriptAutocomplete(): Promise<string[] | undefined> {
let inputCopy = commandArray.join(" ");
if (commandLength === 1) inputCopy = "run " + inputCopy;
if (commandLength >= 1 && commandArray[0] !== "run") inputCopy = "run " + inputCopy;
const commands = parseCommands(inputCopy);
if (commands.length === 0) return;
const command = parseCommand(commands[commands.length - 1]);

@ -233,6 +233,9 @@ export function TerminalInput(): React.ReactElement {
// Autocomplete
if (event.key === KEY.TAB) {
if (event.altKey || event.ctrlKey) {
return;
}
event.preventDefault();
if (searchResults.length) {
saveValue(searchResults[searchResultsIndex]);