-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Truncate line when accepting inline suggestions for Supermaven #13884
Truncate line when accepting inline suggestions for Supermaven #13884
Conversation
Configures inline completions to delete the remaining text on the given line. Closes #13039.
We require contributors to sign our Contributor License Agreement, and we don't have @kevmo314 on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
@cla-bot check |
The cla-bot has been summoned, and re-checked this pull request! |
@kevmo314 i think you put the wrong video in the description. it doesn't really show anything |
I've updated the screen recording, not sure what happened there. |
@kevmo314 Thanks for taking this on, this has been driving me crazy! I don't think we should add a Firstly, it seems to be almost? always the case that the generated suffix already exists on the line. It looks like in find_relevant_completion we already remove the prefix that the user has already typed. I think we should update that code to remove any suffix that already exists. That would avoid this weird completion state: I think we can do that with something like: let mut end_of_line = state.prefix_anchor.to_point(buffer);
end_of_line.column = buffer.line_len(point.row);
for char in buffer.reversed_chars_for_range(state.prefix_anchor..buffer.anchor_after(end_of_line))
{
if let Some(prefix) = trimmed_completion.strip_suffix(char) {
trimmed_completion = prefix;
} else{
break;
}
} If Supermaven is regularly generating suggestions where the suffix doesn't match, we can keep a fix similar to yours; but instead of passing back an If you want to pair on getting this over the line, feel free to book time here: https://calendly.com/conradirwin/pairing. |
I don't quite follow how that would work. In your screenshot, the completion text ends with We can't really guarantee the suffix matches at any regular cadence although @super-jacob can speak more to that probably. Returning an |
Ah, I suppose it would match |
🤦 How did I miss that :D. Let's go with the range approach for now then. |
@kevmo314 can you please resolve conflicts? |
@ConradIrwin I've been stuck on this for a bit, how do I get the end of the line in the |
You should be able to do something like this:
If you want to pair on getting this over the line: https://calendly.com/conradirwin/pairing |
What if instead we do not just a suffix comparison, but a full-on diff and display it instead? |
cc @ConradIrwin |
This seems like the right direction but orthogonal to this change? In particular, to apply this diff one would need to implement the line truncation/deletion range behavior still. |
Can we implement them together? I think it would be best for everyone |
I'd like to figure out this PR first in its current scope because it's blocking the use of Supermaven in Zed all together. The rendering seems worthwhile but doesn't really block the use of Supermaven. |
@ConradIrwin I got the build working with the anchors approach. Works now :) Recording.2024-07-19.173713.mp4 |
0647fee
to
820e91b
Compare
@kevmo314 awesome! I just pushed up some cleanup to reduce the change in the editor crate. Will merge when green. |
✅ |
…ndustries#13884) Configures inline completions to delete the remaining text on the given line. This doesn't affect the github copilot inline completion provider since it seems to only generate suggestions if the cursor is at the end of the line but fixes the usability issues related to Supermaven. https://github.com/user-attachments/assets/1b8bc9a3-4666-4665-a436-96e4beee01bb Release Notes: - Fixed zed-industries#13039 --------- Co-authored-by: Antonio Scandurra <[email protected]> Co-authored-by: Conrad Irwin <[email protected]>
Configures inline completions to delete the remaining text on the given line. This doesn't affect the github copilot inline completion provider since it seems to only generate suggestions if the cursor is at the end of the line but fixes the usability issues related to Supermaven.
Recording.2024-07-19.173713.mp4
Release Notes: