From 131fabbf92293c0334b24d6cb29744213a7a0ff4 Mon Sep 17 00:00:00 2001 From: AmirSa12 Date: Sun, 28 Dec 2025 08:48:24 +0330 Subject: [PATCH 1/2] fix: fallback to file completion --- src/t.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/t.ts b/src/t.ts index 8dabcaa..4c8f382 100644 --- a/src/t.ts +++ b/src/t.ts @@ -140,6 +140,7 @@ export class RootCommand extends Command { commands = new Map(); completions: Completion[] = []; directive = ShellCompDirective.ShellCompDirectiveDefault; + private isCompletingFlags = false; constructor() { super('', ''); @@ -385,7 +386,13 @@ export class RootCommand extends Command { } private complete(toComplete: string) { - this.directive = ShellCompDirective.ShellCompDirectiveNoFileComp; + // only disable file completion when completing flags + // allow file fallback for commands/positional args + if (this.isCompletingFlags) { + this.directive = ShellCompDirective.ShellCompDirectiveNoFileComp; + } else { + this.directive = ShellCompDirective.ShellCompDirectiveDefault; + } const seen = new Set(); this.completions @@ -431,6 +438,7 @@ export class RootCommand extends Command { const lastPrevArg = previousArgs[previousArgs.length - 1]; if (this.shouldCompleteFlags(lastPrevArg, toComplete)) { + this.isCompletingFlags = true; this.handleFlagCompletion( matchedCommand, previousArgs, @@ -438,6 +446,7 @@ export class RootCommand extends Command { lastPrevArg ); } else { + this.isCompletingFlags = false; if (lastPrevArg?.startsWith('-') && toComplete === '' && endsWithSpace) { let option = this.findOption(this, lastPrevArg); if (!option) { @@ -467,9 +476,9 @@ export class RootCommand extends Command { setup(name: string, executable: string, shell: string) { assert( shell === 'zsh' || - shell === 'bash' || - shell === 'fish' || - shell === 'powershell', + shell === 'bash' || + shell === 'fish' || + shell === 'powershell', 'Unsupported shell' ); From aeadaa5f6d76802757e64efe313175e2158ddc98 Mon Sep 17 00:00:00 2001 From: AmirSa12 Date: Sun, 28 Dec 2025 08:50:10 +0330 Subject: [PATCH 2/2] prettier --- src/t.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/t.ts b/src/t.ts index 4c8f382..acc0080 100644 --- a/src/t.ts +++ b/src/t.ts @@ -476,9 +476,9 @@ export class RootCommand extends Command { setup(name: string, executable: string, shell: string) { assert( shell === 'zsh' || - shell === 'bash' || - shell === 'fish' || - shell === 'powershell', + shell === 'bash' || + shell === 'fish' || + shell === 'powershell', 'Unsupported shell' );