Skip to content

Refetch on explicit close when input differs from anchor#2104

Merged
curtisman merged 1 commit intomicrosoft:mainfrom
curtisman:escape
Mar 30, 2026
Merged

Refetch on explicit close when input differs from anchor#2104
curtisman merged 1 commit intomicrosoft:mainfrom
curtisman:escape

Conversation

@curtisman
Copy link
Copy Markdown
Member

@curtisman curtisman commented Mar 30, 2026

Summary

  • When the user presses Escape to dismiss the completion menu, if there is typed text beyond the current anchor, issue a background refetch with the full current input
  • The menu is only reopened if the backend returns a different startIndex (anchor advanced), indicating the grammar found a new parse point — same anchor means the user already dismissed those exact completions, so reopening is suppressed
  • Four conditions skip the refetch entirely (result guaranteed identical): IDLE session, input === anchor, noMatchPolicy=accept (closed set), noMatchPolicy=slide (wildcard boundary)

Changes

  • partialCompletionSession.ts: new explicitHide() public method + explicitCloseAnchor field + conditional-reopen guard in startNewSession callback
  • partial.ts: new private explicitHide() method; handleSpecialKeys Escape path wired to it instead of raw searchMenu.hide()
  • grammarE2E.spec.ts: 4 new tests covering no-refetch for closed-set keywords, no-refetch when input equals anchor, refetch with same anchor suppresses reopen, and refetch with full entity advances anchor and reveals next-level completions

🤖 Generated with Claude Code

When the user presses Escape to dismiss the completion menu, if there is
typed text beyond the current anchor, issue a background refetch with the
full current input.  The menu is only reopened if the backend returns a
different startIndex (anchor position changed), indicating the grammar
found a new parse point.  If the anchor is unchanged the completions
would be the same ones the user just dismissed, so reopening is
suppressed.

Conditions where the refetch is skipped (result guaranteed identical):
- IDLE: no active session
- input === anchor: no prefix typed beyond anchor
- noMatchPolicy "accept": closed set, no new completions possible
- noMatchPolicy "slide": wildcard boundary, refetch shifts anchor only

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@curtisman curtisman enabled auto-merge March 30, 2026 20:00
@curtisman curtisman added this pull request to the merge queue Mar 30, 2026
Merged via the queue into microsoft:main with commit 9055e90 Mar 30, 2026
13 of 15 checks passed
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