Skip to content

Commit d7ffc37

Browse files
authored
editor: Improve text color in document color highlight (#39372)
Release Notes: - Improved text color in LSP document color highlight. ---- Because highlight ranges are implemented using a paint background, there's no way to control the text color. I've been thinking about this problem for a long time, want to solve it. ~~Today, I come up with a new idea. Re-rendering the document color text at the top should solve this problem.~~ #### Update 10/6: > The previous version is not good, when we have soft wrap text, that version will not work correct. Now use exists `bg_segments_per_row` feature to fix text color. ## Before <img width="563" height="540" alt="image" src="https://github.com/user-attachments/assets/99722253-0cab-4d2a-a5d1-7f28393bcaed" /> ## After <img width="544" height="527" alt="image" src="https://github.com/user-attachments/assets/a1bf6cdb-0e9c-435d-b14a-6ee9159a63d9" />
1 parent b798376 commit d7ffc37

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

crates/editor/src/element.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8931,10 +8931,20 @@ impl Element for EditorElement {
89318931
cx,
89328932
);
89338933

8934+
let merged_highlighted_ranges =
8935+
if let Some((_, colors)) = document_colors.as_ref() {
8936+
&highlighted_ranges
8937+
.clone()
8938+
.into_iter()
8939+
.chain(colors.clone())
8940+
.collect()
8941+
} else {
8942+
&highlighted_ranges
8943+
};
89348944
let bg_segments_per_row = Self::bg_segments_per_row(
89358945
start_row..end_row,
89368946
&selections,
8937-
&highlighted_ranges,
8947+
&merged_highlighted_ranges,
89388948
self.style.background,
89398949
);
89408950

0 commit comments

Comments
 (0)