gpui: Make TextSystem::line_wrapper non-fallible. (#4022)
Editors WrapMap could become desynchronised if user had an invalid font specified in their config. Compared to Zed1, WrapMap ignored the resolution failure instead of panicking. Now, if there's an invalid font in the user config, we just fall back to an arbitrary default. Release Notes: - Fixed the editor panic in presence of invalid font name in the config (fixes https://github.com/zed-industries/community/issues/2397) --------- Co-authored-by: Conrad <conrad@zed.dev> Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
af790d11ee
commit
a98d048905
2 changed files with 30 additions and 44 deletions
|
@ -364,28 +364,20 @@ impl TextSystem {
|
|||
self.line_layout_cache.start_frame()
|
||||
}
|
||||
|
||||
pub fn line_wrapper(
|
||||
self: &Arc<Self>,
|
||||
font: Font,
|
||||
font_size: Pixels,
|
||||
) -> Result<LineWrapperHandle> {
|
||||
pub fn line_wrapper(self: &Arc<Self>, font: Font, font_size: Pixels) -> LineWrapperHandle {
|
||||
let lock = &mut self.wrapper_pool.lock();
|
||||
let font_id = self.font_id(&font)?;
|
||||
let font_id = self.resolve_font(&font);
|
||||
let wrappers = lock
|
||||
.entry(FontIdWithSize { font_id, font_size })
|
||||
.or_default();
|
||||
let wrapper = wrappers.pop().map(anyhow::Ok).unwrap_or_else(|| {
|
||||
Ok(LineWrapper::new(
|
||||
font_id,
|
||||
font_size,
|
||||
self.platform_text_system.clone(),
|
||||
))
|
||||
})?;
|
||||
let wrapper = wrappers.pop().unwrap_or_else(|| {
|
||||
LineWrapper::new(font_id, font_size, self.platform_text_system.clone())
|
||||
});
|
||||
|
||||
Ok(LineWrapperHandle {
|
||||
LineWrapperHandle {
|
||||
wrapper: Some(wrapper),
|
||||
text_system: self.clone(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn raster_bounds(&self, params: &RenderGlyphParams) -> Result<Bounds<DevicePixels>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue