Merge pull request #2544 from nickofolas/autocomplete-partial-executable

Autocomplete partial executables
This commit is contained in:
hydroflame 2022-01-11 11:13:45 -05:00 committed by GitHub
commit 9da46668c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -183,7 +183,7 @@ export async function determineAllPossibilitiesForTabCompletion(
* has input ./partialexecutablename so autocomplete the script or program.
* Put './' in front of each script/executable
*/
if (isCommand("./") && index == -1) {
if (input.startsWith("./") && index == -1) {
//All programs and scripts
for (let i = 0; i < currServ.scripts.length; ++i) {
allPos.push("./" + currServ.scripts[i].filename);
@ -193,6 +193,11 @@ export async function determineAllPossibilitiesForTabCompletion(
for (let i = 0; i < homeComputer.programs.length; ++i) {
allPos.push("./" + homeComputer.programs[i]);
}
//Contracts on current server
for (let i = 0; i < currServ.contracts.length; ++i) {
allPos.push("./" + currServ.contracts[i].fn)
}
return allPos;
}
@ -286,7 +291,8 @@ export async function determineAllPossibilitiesForTabCompletion(
}
async function scriptAutocomplete(): Promise<string[] | undefined> {
if (!isCommand("run") && !isCommand("tail") && !isCommand("kill")) return;
if (!isCommand("run") && !isCommand("tail") && !isCommand("kill") && !input.startsWith("./")) return;
if (input.startsWith("./")) input = "run " + input.slice(2);
const commands = ParseCommands(input);
if (commands.length === 0) return;
const command = ParseCommand(commands[commands.length - 1]);