mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-20 07:24:41 +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:
@@ -706,13 +706,28 @@ process_answer:
|
||||
}
|
||||
largest_index := ans[len(ans)-1].Index
|
||||
offset := max(0, opts.HintsOffset)
|
||||
if opts.PrefixFree {
|
||||
alphabetLength := len(opts.Alphabet)
|
||||
if alphabetLength == 0 {
|
||||
alphabetLength = len(DEFAULT_HINT_ALPHABET)
|
||||
}
|
||||
offset = max(offset, hints_to_skip(len(ans), alphabetLength))
|
||||
}
|
||||
index_map = make(map[int]*Mark, len(ans))
|
||||
for i := range ans {
|
||||
m := &ans[i]
|
||||
if opts.Ascending {
|
||||
m.Index += offset
|
||||
if opts.PrefixFree {
|
||||
if opts.Ascending {
|
||||
m.Index = i + offset + 1
|
||||
} else {
|
||||
m.Index = (largest_index - m.Index) + offset + 1
|
||||
}
|
||||
} else {
|
||||
m.Index = largest_index - m.Index + offset
|
||||
if opts.Ascending {
|
||||
m.Index += offset
|
||||
} else {
|
||||
m.Index = largest_index - m.Index + offset
|
||||
}
|
||||
}
|
||||
index_map[m.Index] = m
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user