Skip to content

Reset flag state before completion#83

Open
M09Ic wants to merge 1 commit into
reeflective:mainfrom
M09Ic:pr/console-completion-flag-state
Open

Reset flag state before completion#83
M09Ic wants to merge 1 commit into
reeflective:mainfrom
M09Ic:pr/console-completion-flag-state

Conversation

@M09Ic

@M09Ic M09Ic commented Jun 27, 2026

Copy link
Copy Markdown

Background

Console completion reuses cobra command trees. Flags parsed by an earlier completion or execution can leave Changed, values, and ArgsLenAtDash state behind, which can influence later completion results for the same command tree.

Approach

  • Locate the command being completed from the current input words.
  • Reset that command's flag values and Changed state before invoking carapace completion.
  • Reset ArgsLenAtDash on the target command and its parents.
  • Keep this scoped to the completion path.

Tests

  • Added coverage that a previously changed bool flag is restored before completion.
  • Added coverage that ArgsLenAtDash is restored after a previous parse containing --.
  • Ran go test ./...

@M09Ic M09Ic force-pushed the pr/console-completion-flag-state branch from 9152b2b to d62f7dd Compare June 27, 2026 01:53
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