Show inline completion popover for hard to spot single edits (#23385)
If a suggested edit is a single character insert or a single line deletion, we'll show the diff popover to make it stand out more. Release Notes: - N/A Co-authored-by: Danilo <danilo@zed.dev>
This commit is contained in:
parent
d40177c2ae
commit
e2c7934783
1 changed files with 24 additions and 1 deletions
|
@ -3419,7 +3419,9 @@ impl EditorElement {
|
|||
return None;
|
||||
}
|
||||
|
||||
if all_edits_insertions_or_deletions(edits, &editor_snapshot.buffer_snapshot) {
|
||||
if !hard_to_spot_single_edit(&edits, &editor_snapshot.buffer_snapshot)
|
||||
&& all_edits_insertions_or_deletions(edits, &editor_snapshot.buffer_snapshot)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -3428,6 +3430,7 @@ impl EditorElement {
|
|||
else {
|
||||
return None;
|
||||
};
|
||||
|
||||
let line_count = text.lines().count() + 1;
|
||||
|
||||
let longest_row =
|
||||
|
@ -5198,6 +5201,26 @@ fn header_jump_data(
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if there's a single edit, that's either a single character
|
||||
/// insertion or a single line deletion.
|
||||
fn hard_to_spot_single_edit(
|
||||
edits: &[(Range<Anchor>, String)],
|
||||
snapshot: &MultiBufferSnapshot,
|
||||
) -> bool {
|
||||
if let [(range, new_text)] = edits {
|
||||
match new_text.len() {
|
||||
0 => {
|
||||
let range = range.to_point(&snapshot);
|
||||
range.start.row == range.end.row
|
||||
}
|
||||
1 => true,
|
||||
_ => false,
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn all_edits_insertions_or_deletions(
|
||||
edits: &Vec<(Range<Anchor>, String)>,
|
||||
snapshot: &MultiBufferSnapshot,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue