mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-14 20:44:32 +02:00
Fixes bug where hints starting with the first alphabet's character are _almost never_ generated.
* Switches to "positional notation" to fix the bug. * Consolidates `encode_hint` and `generate_prefix_free_hint` into `encode_hint`. * Moves prefix_free_hints.go to hints_generator.go; `encode_hint` and `decode_hint` were moved here too. * The "prefix-free" logic was made 0-index based instead of 1-index based for two reasons: 1. To simplify 1-off discrepancies. 2. To keep backwards compatibility with the old usage of `encode_hint`. * Slight perfomance improvement added by reusing the runt-to-index map instead of rebuilding for each call to `decode_hint`. * Unit tests added; for all new logic and old affected logic. Fixes #10231
This commit is contained in:
@@ -716,18 +716,10 @@ process_answer:
|
||||
index_map = make(map[int]*Mark, len(ans))
|
||||
for i := range ans {
|
||||
m := &ans[i]
|
||||
if opts.PrefixFree {
|
||||
if opts.Ascending {
|
||||
m.Index = i + offset + 1
|
||||
} else {
|
||||
m.Index = (largest_index - m.Index) + offset + 1
|
||||
}
|
||||
if opts.Ascending {
|
||||
m.Index += offset
|
||||
} else {
|
||||
if opts.Ascending {
|
||||
m.Index += offset
|
||||
} else {
|
||||
m.Index = largest_index - m.Index + offset
|
||||
}
|
||||
m.Index = largest_index - m.Index + offset
|
||||
}
|
||||
index_map[m.Index] = m
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user