Skip to content

input: drop stale completion responses and allow refreshing the popup - #111

Open
feigeCode wants to merge 2 commits into
input-gutter-markers-decorationsfrom
input-completion-refresh
Open

input: drop stale completion responses and allow refreshing the popup#111
feigeCode wants to merge 2 commits into
input-gutter-markers-decorationsfrom
input-completion-refresh

Conversation

@feigeCode

Copy link
Copy Markdown
Owner

Problem

Two separate issues with async completion:

  1. Stale responses win. Completion requests are async, but when a response lands nothing
    says it still matches the buffer it was requested for. Type fast — or let an LSP respond
    slowly — and an older response can overwrite the popup produced by a newer request.
  2. Late metadata has no way back in. Some sources resolve metadata asynchronously after
    the document settles. There's no call to ask for the popup to be recomputed without
    faking an edit.

What this adds

  • Every document carries a monotonic revision and a completion epoch, both bumped from
    a new InputModeKind::document_did_change hook that fires on any real content mutation
    (via the model hook, so masking and programmatic edits are covered too). The revision only
    advances when the text actually differs — no-op edits don't invalidate anything.
  • A landed completion response now checks revision, epoch, cursor, trigger offset and query
    before it is applied. If any of them moved, the response is dropped rather than applied.
  • refresh_completion_popup() — re-requests popup completion without touching the document,
    for sources that become ready late.

document_did_change is a no-op default on the trait, so existing modes are unaffected.

Depends on

Builds on the range-decoration / gutter work in longbridge#3040 — it shares the document-mutation
plumbing. I kept them as two PRs because they solve different problems; happy to squash them
if you'd rather review one diff.

Validation

Same set as that PR, on top of it:

  • cargo check --workspace --all-targets clean.
  • cargo clippy --workspace --all-targets -- --deny warnings clean.
  • cargo fmt --all -- --check clean.
  • cargo test --workspace --exclude gpui-shell --features gpui-component-story/test-support
    passes.

Release Notes:

  • N/A

feigeCode and others added 2 commits September 11, 2026 11:07
Editors can now show feature-owned markers in a reserved gutter lane,
geometric Fill/Frame decorations over UTF-8 ranges, and non-document
inline widgets at an offset. All three follow text edits and are exposed
through InputBaseState setters plus an Editor builder for the marker
renderer; markers report clicks through InputEvent::GutterMarkerMouseDown.

Co-Authored-By: Claude <noreply@anthropic.com>
Editor documents now carry a monotonic revision and completion epoch,
bumped on every content mutation through the model hook. Completion
responses check both plus cursor, trigger offset and query when they land
so a stale response can no longer overwrite a newer request. A public
refresh_completion_popup re-requests popup completion without editing,
for asynchronous metadata sources that become ready late.

Co-Authored-By: Claude <noreply@anthropic.com>
@feigeCode
feigeCode force-pushed the input-gutter-markers-decorations branch from 0fae175 to b74d954 Compare September 11, 2026 23:11
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