Windows: Fix direct_write crash when clicking an empty line (#11117)

Windows platform direct_write using `LineLayout::default` indicates
`font_size` will be 0. Zed crashed when click empty line.

Release Notes:
- N/A
This commit is contained in:
CharlesChen0823 2024-04-29 12:37:45 +08:00 committed by GitHub
parent c826ad2f82
commit c8a496ec4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -367,7 +367,10 @@ impl DirectWriteState {
fn layout_line(&mut self, text: &str, font_size: Pixels, font_runs: &[FontRun]) -> LineLayout {
if font_runs.is_empty() {
return LineLayout::default();
return LineLayout {
font_size,
..Default::default()
};
}
unsafe {
let text_renderer = self.components.text_renderer.clone();