Skip to content

Commit

Permalink
fix(ui): only check args if the input is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxuum committed Nov 11, 2024
1 parent 86684e2 commit 37a9c03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions packages/ui/src/components/terminal/suggestion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ListArgument {
kind: "list";
options: ReadonlyDeep<ArgumentOptions>;
type: ListArgumentType<unknown>;
input: string[];
input?: string[];
}

export type Argument = SingleArgument | ListArgument;
Expand Down Expand Up @@ -67,19 +67,20 @@ export function getArgumentSuggestion(arg: Argument, textPart?: string) {

const typeSuggestions = singleArg
? arg.type.suggestions?.(arg.input ?? "", Players.LocalPlayer)
: arg.type.suggestions?.(arg.input, Players.LocalPlayer);
: arg.type.suggestions?.(arg.input ?? [], Players.LocalPlayer);
if (typeSuggestions !== undefined) {
for (const text of typeSuggestions) {
suggestions.push(text);
}
}

let errorText: string | undefined;
if (!arg.type.expensive) {
const input = arg.input;
if (!arg.type.expensive && input !== undefined) {
const [success, err] = pcall(() => {
const transformResult = singleArg
? arg.type.transform(arg.input ?? "", Players.LocalPlayer)
: arg.type.transform(arg.input, Players.LocalPlayer);
? arg.type.transform(input as string, Players.LocalPlayer)
: arg.type.transform(input as string[], Players.LocalPlayer);
if (transformResult.ok) return;
errorText = transformResult.value;
});
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/terminal/terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export function Terminal() {
kind: "list",
options: currentArg,
type: argType,
input: textParts,
input: textParts.size() > 1 ? textParts : undefined,
},
argTextPart,
);
Expand Down

0 comments on commit 37a9c03

Please sign in to comment.