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:
parent
5778e1e6f0
commit
22e2b8e832
6 changed files with 611 additions and 170 deletions
|
@ -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 { .. }) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue