diff options
author | 2023-09-17 23:15:38 +0200 | |
---|---|---|
committer | 2023-09-17 23:15:38 +0200 | |
commit | 86d396cf8bede8155bdd4a7d3f115a0108c67297 (patch) | |
tree | eb1d769dd4a0fc8d86714134f5a016751302fd96 /graphics/src | |
parent | 790c0dabcf0a50a2466e47daeb4f1e149b2ede5a (diff) | |
download | iced-86d396cf8bede8155bdd4a7d3f115a0108c67297.tar.gz iced-86d396cf8bede8155bdd4a7d3f115a0108c67297.tar.bz2 iced-86d396cf8bede8155bdd4a7d3f115a0108c67297.zip |
Avoid adding unnecessary spans when syntax highlighting
Diffstat (limited to 'graphics/src')
-rw-r--r-- | graphics/src/text/editor.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs index 47c210bd..95061c3c 100644 --- a/graphics/src/text/editor.rs +++ b/graphics/src/text/editor.rs @@ -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); |