Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edit prediction: Don't show and discard completion if toggled off in the buffer #24927

Merged

Conversation

itsaphel
Copy link
Contributor

Discards an inline completion when it's toggled to off (using, say, a keyboard shortcut). This matches the behaviour in VS Code and JetBrains, and I think is a bit more intuitive.

(#24895)

Release Notes:

  • N/A

This comment was marked as resolved.

@itsaphel

This comment was marked as resolved.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 15, 2025

This comment was marked as resolved.

@danilo-leal
Copy link
Contributor

danilo-leal commented Feb 19, 2025

Hey, thanks for the PR! I read your discussion post and am wondering if what you want isn't just the "This Buffer" binding? You can toggle that on and off at any time to have predictions stop showing temporarily for a given buffer.

Screenshot 2025-02-19 at 8 31 16 PM

@itsaphel
Copy link
Contributor Author

itsaphel commented Feb 20, 2025

@danilo-leal hmm, that is the binding I have set. Maybe I'm doing something wrong?

Here's a video to better illustrate (for clarity: my key presses are shown in the black overlay):

zed.mov
  • At the start of the video, "This Buffer" is enabled, and edit predictions are shown (as expected)
  • When the keybinding (or menu option) is used to toggle off, the existing edit prediction stays visible. (not expected!)
    • I need to remove/insert characters (or perform some kind of update) for it to go away, at which point it (correctly) doesn't reappear
  • When I toggle "This Buffer" back on, an edit prediction is immediately shown (as expected)

ie: I feel like there's an asymmetry in when the edit prediction is refreshed. When toggling off, it doesn't go away without a text update. With toggling on, it appears immediately. I feel like the desired behaviour should be when toggling off, any visible edit prediction should immediately disappear.

@danilo-leal
Copy link
Contributor

Uhm... that makes sense, yeah, thanks for the clarification! Tagging @agu-z for an additional pair of eyes on the code.

@danilo-leal danilo-leal changed the title Discard inline completion when it's toggled to off edit prediction: Don't show and discard completion if toggled off in the buffer Feb 20, 2025
@danilo-leal danilo-leal requested a review from agu-z February 20, 2025 19:04
Copy link
Contributor

@agu-z agu-z left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for your contribution 🥳

@agu-z agu-z merged commit 191a1d7 into zed-industries:main Feb 20, 2025
13 checks passed
@itsaphel itsaphel deleted the discard-inline-completion-on-toggle branch February 21, 2025 10:52
@itsaphel
Copy link
Contributor Author

Thanks both!

@danilo-leal the other thing I wanted to suggest was persisting the user's last setting for "Show Edit Predictions for this buffer". At least, when I restart Zed my preference is forgotten. I think it's also reset while using Zed (maybe switching between files? can't quite remember). Would this be sensible to do, do you think? (or indeed, is it already currently supported?)

@danilo-leal
Copy link
Contributor

@itsaphel that's indeed a non-persistent setting; I mean, it will persist in a buffer that you don't close, but once you do and re-open it again, it should reset to the default. We've gone back and forth as far as supporting the persistence, and the last place we got to was that it wasn't worth it because if you want to persistently not have edit predictions for a single file, you can use the .edit_prediction.disabled_globs setting to exclude that file from ever receiving suggestions. But... I'm open to changing my mind :) Have you tried this setting flow? Would that suffice to you? If not, how would you like this persistence to work?

@itsaphel
Copy link
Contributor Author

@danilo-leal hmm, so for a bit of context, my workflow is roughly as follows:

Sometimes I switch to a bit of work for which edit predictions are distracting and/or poor. eg: writing comments, documentation, etc -- for these, the "This Buffer" option would work pretty well. Other examples are writing more complicated bits of logic, or just wanting to think through something myself without hints, and this taask spans across files.

In JetBrains IDEs, I've quite liked how Copilot's toggle works. It's a global, persistent "Enable/Disable Completions" option. I think the equivalent in Zed is [Show Edit Predictions For] All Files (not sure if it's persistent, but from brief experimentation it seems to deliver roughly the same functionality)? If so, and if it'd be possible to assign a keybinding to that, I'd find that useful.

@danilo-leal
Copy link
Contributor

Sweet, appreciate you clarifying it! Yeah, the "All Files" option is persistent and global (i.e., regardless of buffer, window, or language). So I think reaching for that is what you want! And having a keybinding is a great idea—we should do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants