Skip to content

fix: complete path arguments before later options - #248

Open
tomatotomata wants to merge 3 commits into
tqdm:mainfrom
tomatotomata:codex/fix-bash-middle-command
Open

fix: complete path arguments before later options#248
tomatotomata wants to merge 3 commits into
tqdm:mainfrom
tomatotomata:codex/fix-bash-middle-command

Conversation

@tomatotomata

Copy link
Copy Markdown

What changed

When Bash is completing a custom path argument and the next token already starts with -, the generated completer now keeps the path completer active. This covers editing a command such as ... -d -w and prevents the later option from being inserted as the path value.

Verification

  • python -m compileall -q shtab
  • git diff --check
  • Added a regression test covering a directory argument followed by another option.

I could not run the full pytest suite on this Windows checkout because the repository's POSIX pty test helper requires termios, and the local environment also has incompatible pytest recording plugins. Let me know what you think.

@casperdcl casperdcl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure what your intention is. Is it related to #116?

In any case the test is failing.

@tomatotomata
tomatotomata force-pushed the codex/fix-bash-middle-command branch from 7fc7894 to 5df353b Compare August 10, 2026 17:23
@tomatotomata

Copy link
Copy Markdown
Author

I traced this back to #116. The generated Bash function was keeping the path completer active, but it was still passing the already-typed option token (-w) into that completer, so it could not list the directory entries.

Commit 5df353b keeps the path completer selected and passes an empty word when the current token starts with -. That makes the middle-of-command case complete the pending -d path argument while leaving later options in place. The existing regression now returns folder for COMP_WORDS=(test -d -w); COMP_CWORD=2.

Validation on this checkout:

  • focused Bash completion scenario: passed
  • python -m compileall -q shtab: passed
  • git diff --check: passed

The full pytest suite still cannot start on this Windows checkout because its POSIX pty helper imports termios. Let me know what you think of this narrower fix.

@casperdcl casperdcl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this currently breaks examples/pathcomplete.py:

pathcomplete -<TAB>   # doesn't list --options
pathcomplete . -<TAB> # correctly lists --options

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.20%. Comparing base (1fac16c) to head (9d6d320).
⚠️ Report is 18 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #248      +/-   ##
==========================================
+ Coverage   84.71%   85.20%   +0.48%     
==========================================
  Files           3        3              
  Lines         471      473       +2     
  Branches       93       93              
==========================================
+ Hits          399      403       +4     
- Misses         38       39       +1     
+ Partials       34       31       -3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants