mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 16:58:09 +02:00
hints kitten: Preserve line breaks when the hint is over a line break
Fixes #8674
This commit is contained in:
@@ -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`)
|
- 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]
|
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) {
|
if len(mark_text) <= len(hint) {
|
||||||
mark_text = ""
|
mark_text = ""
|
||||||
} else {
|
} 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):]
|
mark_text = mark_text[len(hint):]
|
||||||
}
|
}
|
||||||
ans := hint_style(hint) + text_style(mark_text)
|
ans := hint_style(hint) + text_style(mark_text)
|
||||||
|
|||||||
Reference in New Issue
Block a user