mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Merge branch 'fix-hints-utf8-rune-slicing' of https://github.com/gogongxt/kitty
This commit is contained in:
@@ -200,10 +200,12 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
|||||||
if hint == "" {
|
if hint == "" {
|
||||||
hint = " "
|
hint = " "
|
||||||
}
|
}
|
||||||
if len(mark_text) <= len(hint) {
|
hint_runes := len(hint)
|
||||||
|
runes := []rune(mark_text)
|
||||||
|
if len(runes) <= hint_runes {
|
||||||
mark_text = ""
|
mark_text = ""
|
||||||
} else {
|
} else {
|
||||||
replaced_text := mark_text[:len(hint)]
|
replaced_text := string(runes[:hint_runes])
|
||||||
replaced_text = strings.ReplaceAll(replaced_text, "\r", "\n")
|
replaced_text = strings.ReplaceAll(replaced_text, "\r", "\n")
|
||||||
if strings.Contains(replaced_text, "\n") {
|
if strings.Contains(replaced_text, "\n") {
|
||||||
buf := strings.Builder{}
|
buf := strings.Builder{}
|
||||||
@@ -224,7 +226,7 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
|||||||
}
|
}
|
||||||
hint = buf.String()
|
hint = buf.String()
|
||||||
}
|
}
|
||||||
mark_text = mark_text[len(hint):]
|
mark_text = string(runes[hint_runes:])
|
||||||
}
|
}
|
||||||
ans := hint_style(hint) + text_style(mark_text)
|
ans := hint_style(hint) + text_style(mark_text)
|
||||||
return fmt.Sprintf("\x1b]8;;mark:%d\a%s\x1b]8;;\a", m.Index, ans)
|
return fmt.Sprintf("\x1b]8;;mark:%d\a%s\x1b]8;;\a", m.Index, ans)
|
||||||
|
|||||||
Reference in New Issue
Block a user