Skip to content

editor: Add to option to keep completion menu at original position. - #2549

Open
palaska wants to merge 1 commit into
longbridge:mainfrom
spiraldb:spiral/completion-anchor
Open

editor: Add to option to keep completion menu at original position.#2549
palaska wants to merge 1 commit into
longbridge:mainfrom
spiraldb:spiral/completion-anchor

Conversation

@palaska

@palaska palaska commented Jul 8, 2026

Copy link
Copy Markdown

Description

The completion popover recomputes its position from the live caret bounds on every render, so it slides right as you type the query, reading as jittery.

This pins the popover to where the completion session opened and keeps it there until the session ends (hide) or a new one begins, matching the behavior of editors like VS Code and Zed.

Screenshot

Before
sticky suggestion before

After
sticky suggestion after

Break Changes

None

How to Test

  1. cargo run --example editor
  2. In the editor, type a word that triggers the completion popover (e.g. start typing so the menu appears).
  3. Keep typing to extend the word.

Before: the popover slides right, tracking the caret.
After: the popover stays pinned where the completion opened.

Dismissing (Esc) and re-triggering elsewhere re-pins it at the new location.

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate.
  • Passed cargo run for story tests related to the changes.
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific)

The completion menu recomputed its origin() from the live caret bounds on
every render, so the popover slid right as the query grew — reading as
draggy/stuttery. Freeze the anchor for the lifetime of a completion
session (cleared on hide / new trigger).
@palaska
palaska force-pushed the spiral/completion-anchor branch from f652b4f to c962383 Compare July 8, 2026 13:50
@ScottCUSA

ScottCUSA commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

VS Code and Zed's completion popovers follow the cursor like your Before example.

Not to say gpui-component's couldn't be better, the other editor's auto-close the popover after you finish a word, or there are no matches, then re-open when you start typing a second word.

@palaska

palaska commented Jul 8, 2026

Copy link
Copy Markdown
Author

Zed's completion popover follows the cursor like your Before example.

Though maybe a little closer, and it auto-closes after you hit space to finish a word, then re-opens when you start typing a second word.

Hmm thats true actually. Yeah it felt jittery and laggy probably because as you said it doesn't follow the cursor as closely as the others so the after behavior felt much nicer to me.

If you prefer keeping the old behavior, I guess I can make this gated by a config. Feel free to close this if you don't think it's necessary :)

@huacnlee

Copy link
Copy Markdown
Member

I'd like this feature, but I'd like this to as an option and default to before version.

@huacnlee huacnlee changed the title fix(input): pin completion popover instead of following the caret editor: Add to option to keep completion menu at original position. Jul 10, 2026
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.

3 participants