mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 00:38:10 +02:00
Implements option to generate prefix-free hints
- Declares --prefix-free CLI flag in main.py. - Implements dynamic index offset shifting in marks.go to prevent generating hints that prefix other hints. - Integrates prefix-free encoding in main.go. - Includes tests. Implements #10195
This commit is contained in:
@@ -192,7 +192,12 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
text_style := fctx.SprintFunc(fmt.Sprintf("fg=%s bg=%s bold", o.HintsTextColor, o.HintsTextBackgroundColor))
|
||||
|
||||
highlight_mark := func(m *Mark, mark_text string) string {
|
||||
hint := encode_hint(m.Index, alphabet)
|
||||
var hint string
|
||||
if o.PrefixFree {
|
||||
hint = generate_prefix_free_hint(m.Index, alphabet)
|
||||
} else {
|
||||
hint = encode_hint(m.Index, alphabet)
|
||||
}
|
||||
if current_input != "" && !strings.HasPrefix(hint, current_input) {
|
||||
return faint(mark_text)
|
||||
}
|
||||
@@ -311,7 +316,13 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
if changed {
|
||||
matches := []*Mark{}
|
||||
for idx, m := range index_map {
|
||||
if eh := encode_hint(idx, alphabet); strings.HasPrefix(eh, current_input) {
|
||||
var eh string
|
||||
if o.PrefixFree {
|
||||
eh = generate_prefix_free_hint(idx, alphabet)
|
||||
} else {
|
||||
eh = encode_hint(idx, alphabet)
|
||||
}
|
||||
if strings.HasPrefix(eh, current_input) {
|
||||
matches = append(matches, m)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user