From b52ccfe36a83879e2f7e854484fd689cda759a3d Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 24 Dec 2022 08:17:24 -0700 Subject: [PATCH] palette: adjust group prefix when menubar is empty Avoid printing `: ` at the start of the line refs: https://github.com/wez/wezterm/issues/1485 --- wezterm-gui/src/termwindow/palette.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wezterm-gui/src/termwindow/palette.rs b/wezterm-gui/src/termwindow/palette.rs index 52be2fc77..977ae63ca 100644 --- a/wezterm-gui/src/termwindow/palette.rs +++ b/wezterm-gui/src/termwindow/palette.rs @@ -215,7 +215,11 @@ impl CommandPalette { .skip(top_row) .take(max_rows_on_screen) { - let group = command.menubar.join(" | "); + let group = if command.menubar.is_empty() { + String::new() + } else { + format!("{}: ", command.menubar.join(" | ")) + }; let (bg, text) = if display_idx == selected_row { ( @@ -245,9 +249,9 @@ impl CommandPalette { let label = if command.doc.is_empty() || command.brief.to_ascii_lowercase() == command.doc.to_ascii_lowercase() { - format!("{group}: {}", command.brief) + format!("{group}{}", command.brief) } else { - format!("{group}: {}. {}", command.brief, command.doc) + format!("{group}{}. {}", command.brief, command.doc) }; elements.push(