Fix browser search scrolling and remove list item selection highlight
This commit is contained in:
parent
57a185fa36
commit
a17c3760f2
|
|
@ -188,7 +188,7 @@ func recomputeSearchResults(s *BrowserState) {
|
|||
|
||||
// Jump to first result if any matches found
|
||||
if len(results) > 0 {
|
||||
s.ScrollOffset = float64(results[0]) * s.EntryHeight
|
||||
s.ScrollOffset = 0 // Search results start at the top
|
||||
} else {
|
||||
s.ScrollOffset = 0
|
||||
}
|
||||
|
|
@ -246,14 +246,20 @@ func computeVisibleEntries(state *BrowserState) []ui.ListItem {
|
|||
}
|
||||
|
||||
// computeSearchResults builds the list of ui.ListItem entries for search results.
|
||||
// Only entries whose indices are in SearchResults are shown.
|
||||
// Only entries whose indices are in SearchResults are shown, based on the current scroll offset.
|
||||
func computeSearchResults(state *BrowserState) []ui.ListItem {
|
||||
var items []ui.ListItem
|
||||
for _, idx := range state.SearchResults {
|
||||
if idx < 0 || idx >= state.TotalEntries {
|
||||
continue
|
||||
startIndex := state.GetScrollIndex()
|
||||
// show one past the "visible count" for a partial view of the next item
|
||||
endIndex := startIndex + state.VisibleCount + 1
|
||||
if endIndex > len(state.SearchResults) {
|
||||
endIndex = len(state.SearchResults)
|
||||
}
|
||||
entry, ok := getEntryByIndex(state, idx)
|
||||
|
||||
var items []ui.ListItem
|
||||
for idx := startIndex; idx < endIndex; idx++ {
|
||||
rawIdx := state.SearchResults[idx]
|
||||
|
||||
entry, ok := getEntryByIndex(state, rawIdx)
|
||||
if !ok {
|
||||
// Page not loaded yet; add placeholder
|
||||
items = append(items, ui.ListItem{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user