inline completion: Add syntax highlighting for edit prediction (#23361)
Closes #ISSUE Release Notes: - N/A --------- Co-authored-by: Antonio Scandurra <me@as-cii.com> Co-authored-by: Agus <agus@zed.dev>
This commit is contained in:
parent
75ae4dada4
commit
3dee32c43d
12 changed files with 796 additions and 485 deletions
|
@ -3390,7 +3390,9 @@ impl EditorElement {
|
|||
}
|
||||
InlineCompletion::Edit {
|
||||
edits,
|
||||
edit_preview,
|
||||
display_mode,
|
||||
snapshot,
|
||||
} => {
|
||||
if self.editor.read(cx).has_active_completions_menu() {
|
||||
return None;
|
||||
|
@ -3442,13 +3444,11 @@ impl EditorElement {
|
|||
EditDisplayMode::DiffPopover => {}
|
||||
}
|
||||
|
||||
let crate::InlineCompletionText::Edit { text, highlights } =
|
||||
crate::inline_completion_edit_text(editor_snapshot, edits, false, cx)
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
let highlighted_edits = edit_preview.as_ref().and_then(|edit_preview| {
|
||||
crate::inline_completion_edit_text(&snapshot, edits, edit_preview, false, cx)
|
||||
})?;
|
||||
|
||||
let line_count = text.lines().count() + 1;
|
||||
let line_count = highlighted_edits.text.lines().count() + 1;
|
||||
|
||||
let longest_row =
|
||||
editor_snapshot.longest_row_in_range(edit_start.row()..edit_end.row() + 1);
|
||||
|
@ -3466,15 +3466,14 @@ impl EditorElement {
|
|||
.width
|
||||
};
|
||||
|
||||
let styled_text =
|
||||
gpui::StyledText::new(text.clone()).with_highlights(&style.text, highlights);
|
||||
let styled_text = gpui::StyledText::new(highlighted_edits.text.clone())
|
||||
.with_highlights(&style.text, highlighted_edits.highlights);
|
||||
|
||||
let mut element = div()
|
||||
.bg(cx.theme().colors().editor_background)
|
||||
.border_1()
|
||||
.border_color(cx.theme().colors().border)
|
||||
.rounded_md()
|
||||
.px_1()
|
||||
.child(styled_text)
|
||||
.into_any();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue