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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user