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"
/>
This commit is contained in:
Jason Lee
2025-10-21 21:35:40 +05:30
committed by GitHub
parent b79837695e
commit d7ffc37b14
+11 -1
View File
@@ -8931,10 +8931,20 @@ impl Element for EditorElement {
cx,
);
let merged_highlighted_ranges =
if let Some((_, colors)) = document_colors.as_ref() {
&highlighted_ranges
.clone()
.into_iter()
.chain(colors.clone())
.collect()
} else {
&highlighted_ranges
};
let bg_segments_per_row = Self::bg_segments_per_row(
start_row..end_row,
&selections,
&highlighted_ranges,
&merged_highlighted_ranges,
self.style.background,
);