Skip to content

fix: stop completing a root command argument again after it has been given - #159

Open
MgmClientGuy0 wants to merge 1 commit into
bombshell-dev:mainfrom
MgmClientGuy0:fix/root-positional-index
Open

MgmClientGuy0 wants to merge 1 commit into
bombshell-dev:mainfrom
MgmClientGuy0:fix/root-positional-index

Conversation

@MgmClientGuy0

Copy link
Copy Markdown

What does this PR do?

Currently, once a root command positional argument is typed, the same argument is suggested again afterwards instead of moving to the next argument. You can see it in the demo, which currently prints "my-app" again after the "my-app" argument was already given. This affects all positions, not just the first.

pnpm tsx examples/demo.t.ts complete -- my-app ""

In contrast, for sub-commands, the argument is not repeated:

pnpm tsx examples/demo.t.ts complete -- copy src/ ""

handlePositionalCompletion currently finds the argument index by subtracting the command name words from the typed words. For the root command value is '', and ''.split(' ') has length 1, which is incorrect.

This does not conflict with #155 and they have the same type of fix for a different reason, see here.

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • All tests pass (pnpm test)
  • Files are formatted (pnpm format)
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset

AI-generated code disclosure

  • This PR includes AI-generated code
  • Code was generated with Claude Opus 5.5. I have reviewed and understood every line. PRs and potential comments are written by human.

…given

`handlePositionalCompletion` subtracts the command's name words from the
typed words to find the argument index. The root command's value is '',
and ''.split(' ') has length 1, so one argument too few was counted:
after `my-cli my-app <TAB>` the root's first argument was completed again.
@changeset-bot

changeset-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ab96586

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bomb.sh/tab Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant