edit predictions: Preview jumps by animating cursor to target (#24604)

https://github.com/user-attachments/assets/977d08fb-a2b1-4826-9d95-8f35c6cb9f13




Release Notes:

- N/A

---------

Co-authored-by: Danilo <danilo@zed.dev>
Co-authored-by: Smit <smit@zed.dev>
Co-authored-by: Max <max@zed.dev>
This commit is contained in:
Agus Zubiaga 2025-02-11 11:19:51 -03:00 committed by GitHub
parent 5778e1e6f0
commit 22e2b8e832
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 611 additions and 170 deletions

View file

@ -113,6 +113,7 @@ impl Editor {
target_bottom = target_top + 1.;
} else {
let selections = self.selections.all::<Point>(cx);
target_top = selections
.first()
.unwrap()
@ -144,6 +145,29 @@ impl Editor {
target_top = newest_selection_top;
target_bottom = newest_selection_top + 1.;
}
if self.edit_prediction_preview.is_active() {
if let Some(completion) = self.active_inline_completion.as_ref() {
match completion.completion {
crate::InlineCompletion::Edit { .. } => {}
crate::InlineCompletion::Move { target, .. } => {
let target_row = target.to_display_point(&display_map).row().as_f32();
if target_row < target_top {
target_top = target_row;
} else if target_row >= target_bottom {
target_bottom = target_row + 1.;
}
let selections_fit = target_bottom - target_top <= visible_lines;
if !selections_fit {
target_top = target_row;
target_bottom = target_row + 1.;
}
}
}
}
}
}
let margin = if matches!(self.mode, EditorMode::AutoHeight { .. }) {