Only show accept callout if suggestion is all insertions/deletions (#23461)
Release Notes: - N/A
This commit is contained in:
parent
55721c65d4
commit
636df12b74
1 changed files with 23 additions and 21 deletions
|
@ -3410,28 +3410,30 @@ impl EditorElement {
|
|||
return None;
|
||||
}
|
||||
|
||||
if let (true, Some((range, _))) = (single_line, edits.first()) {
|
||||
let mut element = inline_completion_tab_indicator("Accept", None, cx);
|
||||
|
||||
let target_display_point = range.end.to_display_point(editor_snapshot);
|
||||
let target_line_end = DisplayPoint::new(
|
||||
target_display_point.row(),
|
||||
editor_snapshot.line_len(target_display_point.row()),
|
||||
);
|
||||
let origin = self.editor.update(cx, |editor, cx| {
|
||||
editor.display_to_pixel_point(target_line_end, editor_snapshot, cx)
|
||||
})?;
|
||||
|
||||
element.prepaint_as_root(
|
||||
text_bounds.origin + origin + point(PADDING_X, px(0.)),
|
||||
AvailableSpace::min_size(),
|
||||
cx,
|
||||
);
|
||||
|
||||
return Some(element);
|
||||
}
|
||||
|
||||
if all_edits_insertions_or_deletions(edits, &editor_snapshot.buffer_snapshot) {
|
||||
if *single_line {
|
||||
let range = &edits.first()?.0;
|
||||
let target_display_point = range.end.to_display_point(editor_snapshot);
|
||||
|
||||
let target_line_end = DisplayPoint::new(
|
||||
target_display_point.row(),
|
||||
editor_snapshot.line_len(target_display_point.row()),
|
||||
);
|
||||
let origin = self.editor.update(cx, |editor, cx| {
|
||||
editor.display_to_pixel_point(target_line_end, editor_snapshot, cx)
|
||||
})?;
|
||||
|
||||
let mut element = inline_completion_tab_indicator("Accept", None, cx);
|
||||
|
||||
element.prepaint_as_root(
|
||||
text_bounds.origin + origin + point(PADDING_X, px(0.)),
|
||||
AvailableSpace::min_size(),
|
||||
cx,
|
||||
);
|
||||
|
||||
return Some(element);
|
||||
}
|
||||
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue