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]
|
[patch.crates-io.cosmic-text]
|
||||||
git = "https://github.com/hecrj/cosmic-text.git"
|
git = "https://github.com/hecrj/cosmic-text.git"
|
||||||
rev = "cb83458e7d0b84ef37c5beb72dda5046d7d343a6"
|
branch = "editor-fixes"
|
||||||
|
|
||||||
[patch.crates-io.rangemap]
|
[patch.crates-io.rangemap]
|
||||||
git = "https://github.com/hecrj/rangemap.git"
|
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()) {
|
for (range, highlight) in highlighter.highlight_line(line.text()) {
|
||||||
let format = format_highlight(&highlight);
|
let format = format_highlight(&highlight);
|
||||||
|
|
||||||
list.add_span(
|
if format.color.is_some() || format.font.is_some() {
|
||||||
range,
|
list.add_span(
|
||||||
cosmic_text::Attrs {
|
range,
|
||||||
color_opt: format.color.map(text::to_color),
|
cosmic_text::Attrs {
|
||||||
..if let Some(font) = format.font {
|
color_opt: format.color.map(text::to_color),
|
||||||
text::to_attributes(font)
|
..if let Some(font) = format.font {
|
||||||
} else {
|
text::to_attributes(font)
|
||||||
attributes
|
} else {
|
||||||
}
|
attributes
|
||||||
},
|
}
|
||||||
);
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = line.set_attrs_list(list);
|
let _ = line.set_attrs_list(list);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue