hints kitten: Preserve line breaks when the hint is over a line break
Fixes #8674
This commit is contained in:
parent
8e720cc1da
commit
5faa7bda5d
2 changed files with 23 additions and 0 deletions
|
|
@ -115,6 +115,8 @@ Detailed list of changes
|
|||
|
||||
- Remote control: Fix holding a remote control socket open causing the kitty I/O thread to go into a loop and not respond on other remote control sockets (:disc:`8670`)
|
||||
|
||||
- hints kitten: Preserve line breaks when the hint is over a line break (:iss:`8674`)
|
||||
|
||||
0.42.1 [2025-05-17]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
|||
|
|
@ -203,6 +203,27 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
|||
if len(mark_text) <= len(hint) {
|
||||
mark_text = ""
|
||||
} else {
|
||||
replaced_text := mark_text[:len(hint)]
|
||||
replaced_text = strings.ReplaceAll(replaced_text, "\r", "\n")
|
||||
if strings.Contains(replaced_text, "\n") {
|
||||
buf := strings.Builder{}
|
||||
buf.Grow(2 * len(hint))
|
||||
h := hint
|
||||
parts := strings.Split(replaced_text, "\n")
|
||||
for i, x := range parts {
|
||||
if x != "" {
|
||||
buf.WriteString(h[:len(x)])
|
||||
h = h[len(x):]
|
||||
}
|
||||
if i != len(parts)-1 {
|
||||
buf.WriteString("\n")
|
||||
}
|
||||
}
|
||||
if h != "" {
|
||||
buf.WriteString(h)
|
||||
}
|
||||
hint = buf.String()
|
||||
}
|
||||
mark_text = mark_text[len(hint):]
|
||||
}
|
||||
ans := hint_style(hint) + text_style(mark_text)
|
||||
|
|
|
|||
Loading…
Reference in a new issue