From 52d33e2c82cea677920e9ccaf936174fb3d90b23 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 26 Oct 2026 16:31:39 +0530 Subject: [PATCH] zsh completion: Respect the descriptions format style for group headings Previously group headings were hard-coded as %B%b, ignoring the user's zstyle ':completion:*:descriptions' format. This caused literal %B/%b markers to appear with fzf-tab. Now the configured format is used, falling back to bold titles when none is set. Fixes #10748 --- docs/changelog.rst | 4 ++++ tools/cli/zsh.go | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 2af6ecc80..30aa09847 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -454,6 +454,10 @@ Detailed list of changes :file:`/dev` is stuck (:iss:`10708`, :iss:`10581`, :iss:`10628`, :iss:`10673`, :iss:`10741`) +- zsh completion: Respect the user's ``descriptions`` format style for group + headings instead of always using bold titles. Fixes literal ``%B`` markers + appearing with fzf-tab (:iss:`10748`) + 0.49.2 [2026-10-01] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tools/cli/zsh.go b/tools/cli/zsh.go index f8294b7c2..9d010894e 100644 --- a/tools/cli/zsh.go +++ b/tools/cli/zsh.go @@ -108,7 +108,13 @@ func serialize(completions *Completions, f *markup.Context, screen_width int) ([ fmt.Fprintln(&output, "words[1]="+service) fmt.Fprintln(&output, "_normal -p", service) } else { + if len(completions.Groups) > 0 { + // Respect the user's description format, falling back to bold group titles + fmt.Fprintln(&output, "builtin local _kitty_fmt _kitty_expl") + output.WriteString(`builtin zstyle -s ":completion:${curcontext}:descriptions" format _kitty_fmt || _kitty_fmt='%B%d%b'` + "\n") + } for _, mg := range completions.Groups { + fmt.Fprintln(&output, "builtin zformat -f _kitty_expl \"$_kitty_fmt\"", utils.QuoteStringForSH("d:"+mg.Title)) cmd := strings.Builder{} escape_ourselves := mg.IsFiles // zsh quoting quotes a leading ~/ in filenames which is wrong cmd.WriteString("compadd -U ") @@ -117,8 +123,7 @@ func serialize(completions *Completions, f *markup.Context, screen_width int) ([ } cmd.WriteString("-J ") cmd.WriteString(utils.QuoteStringForSH(mg.Title)) - cmd.WriteString(" -X ") - cmd.WriteString(utils.QuoteStringForSH("%B" + mg.Title + "%b")) + cmd.WriteString(` -X "$_kitty_expl"`) if mg.NoTrailingSpace { cmd.WriteString(" -S ''") }