mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-22 00:08:04 +02:00
Ensure positions are always sorted when rendering
This commit is contained in:
@@ -134,7 +134,7 @@ func (h *Handler) draw_column_of_matches(matches []*ResultItem, current_idx int,
|
||||
} else {
|
||||
h.lp.QueueWriteString(icon + " ")
|
||||
}
|
||||
h.render_match_with_positions(text, add_ellipsis, m.positions, is_current)
|
||||
h.render_match_with_positions(text, add_ellipsis, m.sorted_positions(), is_current)
|
||||
h.lp.MoveCursorVertically(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,27 @@ import (
|
||||
var _ = fmt.Print
|
||||
|
||||
type ResultItem struct {
|
||||
text, abspath string
|
||||
dir_entry os.DirEntry
|
||||
positions []int // may be nil
|
||||
score float64
|
||||
text, abspath string
|
||||
dir_entry os.DirEntry
|
||||
positions []int // may be nil
|
||||
score float64
|
||||
positions_sorted bool
|
||||
}
|
||||
|
||||
func (r ResultItem) String() string {
|
||||
return fmt.Sprintf("{text: %#v, abspath: %#v, is_dir: %v, positions: %#v}", r.text, r.abspath, r.dir_entry.IsDir(), r.positions)
|
||||
}
|
||||
|
||||
func (r *ResultItem) sorted_positions() []int {
|
||||
if !r.positions_sorted {
|
||||
r.positions_sorted = true
|
||||
if len(r.positions) > 1 {
|
||||
sort.Ints(r.positions)
|
||||
}
|
||||
}
|
||||
return r.positions
|
||||
}
|
||||
|
||||
type dir_cache map[string][]os.DirEntry
|
||||
|
||||
type ScanCache struct {
|
||||
|
||||
Reference in New Issue
Block a user