edit predictions: Fix popover hint not scrolling horizontally (#24602)
Release Notes: - N/A
This commit is contained in:
parent
eaab7da2d8
commit
7c00eec08b
1 changed files with 15 additions and 4 deletions
|
@ -3630,6 +3630,16 @@ impl EditorElement {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Adjust text origin for horizontal scrolling (in some cases here)
|
||||||
|
let start_point =
|
||||||
|
text_bounds.origin - gpui::Point::new(scroll_pixel_position.x, Pixels(0.0));
|
||||||
|
|
||||||
|
// Clamp left offset after extreme scrollings
|
||||||
|
let clamp_start = |point: gpui::Point<Pixels>| gpui::Point {
|
||||||
|
x: point.x.max(text_bounds.origin.x),
|
||||||
|
y: point.y,
|
||||||
|
};
|
||||||
|
|
||||||
match &active_inline_completion.completion {
|
match &active_inline_completion.completion {
|
||||||
InlineCompletion::Move { target, .. } => {
|
InlineCompletion::Move { target, .. } => {
|
||||||
if editor.edit_prediction_requires_modifier() {
|
if editor.edit_prediction_requires_modifier() {
|
||||||
|
@ -3686,6 +3696,7 @@ impl EditorElement {
|
||||||
)?;
|
)?;
|
||||||
let size = element.layout_as_root(AvailableSpace::min_size(), window, cx);
|
let size = element.layout_as_root(AvailableSpace::min_size(), window, cx);
|
||||||
let offset = point((text_bounds.size.width - size.width) / 2., PADDING_Y);
|
let offset = point((text_bounds.size.width - size.width) / 2., PADDING_Y);
|
||||||
|
|
||||||
element.prepaint_at(text_bounds.origin + offset, window, cx);
|
element.prepaint_at(text_bounds.origin + offset, window, cx);
|
||||||
Some(element)
|
Some(element)
|
||||||
} else if (target_display_point.row().as_f32() + 1.) > scroll_bottom {
|
} else if (target_display_point.row().as_f32() + 1.) > scroll_bottom {
|
||||||
|
@ -3701,6 +3712,7 @@ impl EditorElement {
|
||||||
(text_bounds.size.width - size.width) / 2.,
|
(text_bounds.size.width - size.width) / 2.,
|
||||||
text_bounds.size.height - size.height - PADDING_Y,
|
text_bounds.size.height - size.height - PADDING_Y,
|
||||||
);
|
);
|
||||||
|
|
||||||
element.prepaint_at(text_bounds.origin + offset, window, cx);
|
element.prepaint_at(text_bounds.origin + offset, window, cx);
|
||||||
Some(element)
|
Some(element)
|
||||||
} else {
|
} else {
|
||||||
|
@ -3711,7 +3723,6 @@ impl EditorElement {
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let target_line_end = DisplayPoint::new(
|
let target_line_end = DisplayPoint::new(
|
||||||
target_display_point.row(),
|
target_display_point.row(),
|
||||||
editor_snapshot.line_len(target_display_point.row()),
|
editor_snapshot.line_len(target_display_point.row()),
|
||||||
|
@ -3719,8 +3730,9 @@ impl EditorElement {
|
||||||
let origin = self.editor.update(cx, |editor, _cx| {
|
let origin = self.editor.update(cx, |editor, _cx| {
|
||||||
editor.display_to_pixel_point(target_line_end, editor_snapshot, window)
|
editor.display_to_pixel_point(target_line_end, editor_snapshot, window)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
element.prepaint_as_root(
|
element.prepaint_as_root(
|
||||||
text_bounds.origin + origin + point(PADDING_X, px(0.)),
|
clamp_start(start_point + origin + point(PADDING_X, px(0.))),
|
||||||
AvailableSpace::min_size(),
|
AvailableSpace::min_size(),
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
|
@ -3780,12 +3792,11 @@ impl EditorElement {
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
element.prepaint_as_root(
|
element.prepaint_as_root(
|
||||||
text_bounds.origin + origin + point(PADDING_X, px(0.)),
|
clamp_start(start_point + origin + point(PADDING_X, px(0.))),
|
||||||
AvailableSpace::min_size(),
|
AvailableSpace::min_size(),
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
||||||
return Some(element);
|
return Some(element);
|
||||||
}
|
}
|
||||||
EditDisplayMode::Inline => return None,
|
EditDisplayMode::Inline => return None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue