1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-25 22:32:13 +02:00

Fix keybinding cheatsheets with regard to pipe characters in key or description

The "Cycle pagers" command wasn't rendered correctly, because it's bound to '|'
by default, but this was taked as a table column delimiter. Fix this by escaping
the pipe character.

A similar thing could happen for the description or tooltip (and did in fact,
for a tooltip in the russion translation), so escape those too just to be sure.
This commit is contained in:
Stefan Haller
2025-11-01 09:54:32 +01:00
parent 48c1db6fe4
commit ff0a16f809
10 changed files with 17 additions and 12 deletions

View File

@@ -225,6 +225,11 @@ func formatBinding(binding *types.Binding) string {
// Replace newlines with <br> tags for proper markdown table formatting
tooltip := strings.ReplaceAll(binding.Tooltip, "\n", "<br>")
// Escape pipe characters to avoid breaking the table format
action = strings.ReplaceAll(action, `|`, `\|`)
description = strings.ReplaceAll(description, `|`, `\|`)
tooltip = strings.ReplaceAll(tooltip, `|`, `\|`)
// Use backticks for keyboard keys. Two backticks are needed with an inner space
// to escape a key that is itself a backtick.
return fmt.Sprintf("| `` %s `` | %s | %s |\n", action, description, tooltip)