Remove all virtual text when drawing sticky nodes

SoraTenshi 1 year ago
parent f45c3b8e5b
commit 1068e0beef
No known key found for this signature in database

@ -234,6 +234,12 @@ impl TextAnnotations {
self.line_annotations.clear(); self.line_annotations.clear();
} }
/// Removes all inline annotations, useful if you don't want to draw
/// any virtual text.
pub fn clear_inline_annotations(&mut self) {
self.inline_annotations.clear();
}
pub(crate) fn next_inline_annotation_at( pub(crate) fn next_inline_annotation_at(
&self, &self,
char_idx: usize, char_idx: usize,

@ -824,13 +824,17 @@ impl EditorView {
// get the len of bytes of the text that will be written (the "definition" line) // get the len of bytes of the text that will be written (the "definition" line)
let line = text.line(node.line); let line = text.line(node.line);
let tab_width_count = line.chars().filter(|c| *c == '\t').count(); let tab_count = line.chars().filter(|c| *c == '\t').count();
let already_written = let already_written =
(line.len_bytes() + tab_width_count.saturating_mul(doc.tab_width() - 1)) as u16; (line.len_bytes() + tab_count.saturating_mul(doc.tab_width() - 1)) as u16;
let dots = "..."; let dots = "...";
let mut cleared_virtual_text_annotations = doc_annotations.clone();
cleared_virtual_text_annotations.clear_line_annotations();
cleared_virtual_text_annotations.clear_inline_annotations();
// if the definition of the function contains multiple lines // if the definition of the function contains multiple lines
if node.has_context_end { if node.has_context_end {
let last_line = text.byte_to_line(node.byte_range.end); let last_line = text.byte_to_line(node.byte_range.end);
@ -857,12 +861,13 @@ impl EditorView {
); );
new_offset.anchor = text.byte_to_char(node.byte_range.end); new_offset.anchor = text.byte_to_char(node.byte_range.end);
let highlights = Self::doc_syntax_highlights(doc, new_offset.anchor, 1, theme); let highlights = Self::doc_syntax_highlights(doc, new_offset.anchor, 1, theme);
render_text( render_text(
&mut renderer, &mut renderer,
text, text,
new_offset, new_offset,
&doc.text_format(additional_area.width, Some(theme)), &doc.text_format(additional_area.width, Some(theme)),
doc_annotations, &cleared_virtual_text_annotations,
highlights, highlights,
theme, theme,
line_decoration, line_decoration,
@ -900,7 +905,7 @@ impl EditorView {
text, text,
new_offset, new_offset,
&doc.text_format(line_context_area.width, Some(theme)), &doc.text_format(line_context_area.width, Some(theme)),
doc_annotations, &cleared_virtual_text_annotations,
highlights, highlights,
theme, theme,
line_decoration, line_decoration,

Loading…
Cancel
Save