From 0337421299b3fb37391d1f55d7b4d1005a3f1221 Mon Sep 17 00:00:00 2001 From: En-En <39373446+En-En-Code@users.noreply.github.com> Date: Fri, 12 Dec 2025 01:21:42 +0000 Subject: [PATCH] fix(decor): unwrap if max width fits 0 chars The `title_pixmap` function assumed if `title` was not empty, the returned `glyphs` from `layout_title_glyphs` would also not be empty. `layout_title_glyphs`, however, could break before a single insertion if `max_width` was too small. Emacs, when using `emacsclient --create-frame`, could call `title_pixmap` with a `max_width` of 1, causing a panic. Closes #311. --- src/server/decoration.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/server/decoration.rs b/src/server/decoration.rs index fb273ad..f80c886 100644 --- a/src/server/decoration.rs +++ b/src/server/decoration.rs @@ -382,8 +382,7 @@ fn title_pixmap(title: &str, max_width: u32, height: u32, scale: f32) -> Option< let width = glyphs .last() - .map(|g| g.position.x + font.h_advance(g.id)) - .unwrap() + .map(|g| g.position.x + font.h_advance(g.id))? .ceil() as u32; let mut pixmap = Pixmap::new(width, height).unwrap();