gpui: Impl Default for TextRun (#41084)

Release Notes:

- N/A

When I was implementing Input, I often used `TextRun`, but `background`,
`underline` and `strikethrough` were often not used.

So make change to simplify it.
This commit is contained in:
Jason Lee
2025-11-06 01:50:23 +00:00
committed by GitHub
parent 622d626a29
commit 64c8c19e1b
5 changed files with 27 additions and 62 deletions
+7 -22
View File
@@ -1701,9 +1701,7 @@ impl EditorElement {
len,
font,
color,
background_color: None,
strikethrough: None,
underline: None,
..Default::default()
}],
None,
)
@@ -3583,9 +3581,7 @@ impl EditorElement {
len: line.len(),
font: style.text.font(),
color: placeholder_color,
background_color: None,
underline: None,
strikethrough: None,
..Default::default()
};
let line = window.text_system().shape_line(
line.to_string().into(),
@@ -7440,9 +7436,7 @@ impl EditorElement {
len: column,
font: style.text.font(),
color: Hsla::default(),
background_color: None,
underline: None,
strikethrough: None,
..Default::default()
}],
None,
);
@@ -7465,9 +7459,7 @@ impl EditorElement {
len: text.len(),
font: self.style.text.font(),
color,
background_color: None,
underline: None,
strikethrough: None,
..Default::default()
};
window.text_system().shape_line(
text,
@@ -9568,9 +9560,7 @@ impl Element for EditorElement {
len: tab_len,
font: self.style.text.font(),
color: cx.theme().colors().editor_invisible,
background_color: None,
underline: None,
strikethrough: None,
..Default::default()
}],
None,
);
@@ -9584,9 +9574,7 @@ impl Element for EditorElement {
len: space_len,
font: self.style.text.font(),
color: cx.theme().colors().editor_invisible,
background_color: None,
underline: None,
strikethrough: None,
..Default::default()
}],
None,
);
@@ -11573,11 +11561,8 @@ mod tests {
fn generate_test_run(len: usize, color: Hsla) -> TextRun {
TextRun {
len,
font: gpui::font(".SystemUIFont"),
color,
background_color: None,
underline: None,
strikethrough: None,
..Default::default()
}
}