Avoid adding unnecessary spans when syntax highlighting
This commit is contained in:
parent
790c0dabcf
commit
86d396cf8b
2 changed files with 14 additions and 12 deletions
|
|
@ -154,7 +154,7 @@ winit = { git = "https://github.com/iced-rs/winit.git", rev = "c52db2045d0a2f1b8
|
|||
|
||||
[patch.crates-io.cosmic-text]
|
||||
git = "https://github.com/hecrj/cosmic-text.git"
|
||||
rev = "cb83458e7d0b84ef37c5beb72dda5046d7d343a6"
|
||||
branch = "editor-fixes"
|
||||
|
||||
[patch.crates-io.rangemap]
|
||||
git = "https://github.com/hecrj/rangemap.git"
|
||||
|
|
|
|||
|
|
@ -569,17 +569,19 @@ impl editor::Editor for Editor {
|
|||
for (range, highlight) in highlighter.highlight_line(line.text()) {
|
||||
let format = format_highlight(&highlight);
|
||||
|
||||
list.add_span(
|
||||
range,
|
||||
cosmic_text::Attrs {
|
||||
color_opt: format.color.map(text::to_color),
|
||||
..if let Some(font) = format.font {
|
||||
text::to_attributes(font)
|
||||
} else {
|
||||
attributes
|
||||
}
|
||||
},
|
||||
);
|
||||
if format.color.is_some() || format.font.is_some() {
|
||||
list.add_span(
|
||||
range,
|
||||
cosmic_text::Attrs {
|
||||
color_opt: format.color.map(text::to_color),
|
||||
..if let Some(font) = format.font {
|
||||
text::to_attributes(font)
|
||||
} else {
|
||||
attributes
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let _ = line.set_attrs_list(list);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue