Skip to content

copilot: Clear completions upon discard#40185

Merged
benbrandt merged 4 commits intozed-industries:mainfrom
timvermeulen:clear-copilot-completions-upon-discard
Mar 17, 2026
Merged

copilot: Clear completions upon discard#40185
benbrandt merged 4 commits intozed-industries:mainfrom
timvermeulen:clear-copilot-completions-upon-discard

Conversation

@timvermeulen
Copy link
Copy Markdown
Contributor

Closes #37836

This behavior was already fixed for Supermaven in #37047, but is still present in Copilot. What's actually happening:

  • Receive a multi-line edit prediction
  • Dismiss it with escape
  • Clicking anywhere in the editor below the cursor calls Editor::select which starts out by calling Editor::hide_context_menu -> Editor::update_visible_edit_prediction, bringing back the prediction that was just dismissed and updating the editor's display map
  • The subsequent selection logic in Editor::select now operates using a display map that is inconsistent with what the user saw when clicking
    • If the click was anywhere where the prediction inlay used to be, Editor::select thinks the user clicked on the inlay and does nothing, and the inlay reappears
    • If the click was below where the prediction inlay used to be, the inlay is immediately removed again but the cursor is moved to the wrong position because the inlay temporarily added a vertical offset to all lines after it in the buffer

Ultimately, Editor::select should be handling the user input using the same display map that the user saw when making the input. This can obviously be solved in multiple ways, I chose to clear the current completions in CopilotCompletionProvider::discard such that any subsequent calls to Editor::update_visible_edit_prediction doesn't immediately nullify the dismissal of the edit prediction by the user.

Note that this also changes the behavior that occurs after dismissing an edit prediction, moving to a different position in the buffer, and then returning: currently, this resurfaces the dismissed edit prediction (which the test_copilot test exercises), and after this change it doesn’t. This current behavior didn't seem desirable to me because it doesn't happen when using Zeta or Supermaven, but if we want to keep it, then we could fix the incorrect selection behavior some other way.

Release Notes:

  • Fixed bug that resurfaced dismissed Copilot edit predictions when moving the cursor around

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 14, 2025
@timvermeulen timvermeulen changed the title Clear Copilot completions upon discard copilot: Clear completions upon discard Oct 14, 2025
@SomeoneToIgnore SomeoneToIgnore added the area:ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features label Oct 14, 2025
@github-actions github-actions bot added the community champion Issues filed by our amazing community champions! 🫶 label Nov 3, 2025
@JosephTLyons
Copy link
Copy Markdown
Collaborator

Sorry for the delay here @timvermeulen, I'll grab someone from the AI team to review. Thank you!

@rtfeldman rtfeldman removed their assignment Feb 13, 2026
Copy link
Copy Markdown
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

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

Thanks!

@Veykril
Copy link
Copy Markdown
Member

Veykril commented Mar 17, 2026

clippy is unhappy (and you might need to rebase for the rest of CI to work)

@Veykril Veykril assigned Veykril and unassigned osiewicz Mar 17, 2026
@benbrandt benbrandt enabled auto-merge (squash) March 17, 2026 09:44
@benbrandt benbrandt merged commit 4bc324c into zed-industries:main Mar 17, 2026
29 checks passed
@github-project-automation github-project-automation bot moved this from Community Champion PRs to Done in Quality Week – December 2025 Mar 17, 2026
Veykril pushed a commit that referenced this pull request Apr 2, 2026
Follow-up of #40185

Release Notes:

- N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features cla-signed The user has signed the Contributor License Agreement community champion Issues filed by our amazing community champions! 🫶

Projects

Development

Successfully merging this pull request may close these issues.

Multi-line edit predictions don't work well with mouse selection

9 participants