Skip to content

Keep a cursor on the executable out of argument completion - #144

Merged
carldebilly merged 1 commit into
mainfrom
dev/cdb/completion-executable-cursor
Oct 22, 2026
Merged

carldebilly merged 1 commit into
mainfrom
dev/cdb/completion-executable-cursor

Conversation

@carldebilly

Copy link
Copy Markdown
Member

Fixes #141.

What changes

  • Cursor on the executable. With advanced input enabled, the shell completion bridge clamped a cursor before the argument region to the start of the arguments (Math.Max(0, cursor - start)), then rebuilt the request with the cursor after the executable. A cursor inside or at the end of the executable token was therefore offered command candidates (app at offset 1 offered query) where plain completion offers none. Such a cursor now gets plain completion, and input callbacks do not run for it: adapters and validators only ever see the arguments.
  • Boundary. "On the executable" includes its end, as plain completion counts it (app at offset 3). A cursor past it, even in the spaces before the arguments, still goes through adaptation and validation, so an Invalid result there still leaves nothing to complete.
  • Docs. docs/advanced-input.md says the bridge answers a cursor on the executable as plain completion, without running callbacks.

Verification

  • Given_AdvancedInput_ServiceAndCursor:
    • When_AdvancedInputIsEnabled_Then_CompletionAroundTheExecutableMatchesPlainCompletion: ten cursor positions (before, inside and at the end of the executable, leading whitespace, the argument boundary, the separating spaces, after a partial command) in Bash, Zsh, PowerShell, Fish and Nu. Each compares an identity adapter and an always-valid validator against pinned plain completion.
    • When_InputValidationRefusesTheArguments_Then_NothingPastTheExecutableIsCompleted: an always-invalid validator in the separating spaces and after them.
    • When_TheCursorIsOnTheExecutable_Then_InputCallbacksDoNotRun: a throwing adapter is never invoked and writes no diagnostic.
  • Every row covering the fix failed before it, with a successful build; the callback test was also checked red with the guard disabled.
  • Full suite: 2399 passed, 0 failed (12 opt-in/OS-specific skips).

…letion

With advanced input enabled, shell completion clamped a cursor before
the argument region to the start of the arguments, then rebuilt the
request with the cursor after the executable. A cursor inside or at the
end of the executable token was therefore offered command candidates
that plain completion never offers there.

A cursor on the executable, its end included as plain completion counts
it, now gets plain completion without running input callbacks: they
only ever see the arguments. A cursor past it, even in the spaces
before the arguments, still goes through adaptation and validation.

Fixes #141
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-22T03:32:56.206141Z 9745eb9 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@carldebilly

Copy link
Copy Markdown
Member Author

@codex review

@autocarl autocarl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved exact head 9745eb9a095add8c8f8540016a90ef3a9f051599.

The executable cursor guard fixes #141 while preserving argument-region validation. Independent unchanged-source differential probes cover all cursor offsets over 19 lines and all five supported shell-engine modes: 4,275 observations per revision on head, merge base and current base. Identity/Valid completion now matches plain completion; callbacks do not run before/on the executable, including its end; Invalid and throwing callbacks remain enforced past it. Quoted/incomplete executable forms, leading whitespace, argument boundaries and positive command-completion controls were covered. Parent reran the analysis and checked its assertions. No introduced P0–P2 found. These are bridge-engine probes, not a claim that every native shell UI was exercised.

Parent Release solution build with -warnaserror: zero warnings/errors; full suite 2,408 passed, 0 failed, 3 expected skips. All applicable live CI checks pass. Worktree clean; no merge performed.

@carldebilly
carldebilly merged commit b9562b6 into main Oct 22, 2026
14 checks passed
@carldebilly
carldebilly deleted the dev/cdb/completion-executable-cursor branch October 22, 2026 11:28
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.

completion: do not remap a cursor inside the executable token to argument completion

2 participants