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
|
// Jump to first result if any matches found
|
||||||
if len(results) > 0 {
|
if len(results) > 0 {
|
||||||
s.ScrollOffset = float64(results[0]) * s.EntryHeight
|
s.ScrollOffset = 0 // Search results start at the top
|
||||||
} else {
|
} else {
|
||||||
s.ScrollOffset = 0
|
s.ScrollOffset = 0
|
||||||
}
|
}
|
||||||
|
|
@ -246,14 +246,20 @@ func computeVisibleEntries(state *BrowserState) []ui.ListItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
// computeSearchResults builds the list of ui.ListItem entries for search results.
|
// 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 {
|
func computeSearchResults(state *BrowserState) []ui.ListItem {
|
||||||
var items []ui.ListItem
|
startIndex := state.GetScrollIndex()
|
||||||
for _, idx := range state.SearchResults {
|
// show one past the "visible count" for a partial view of the next item
|
||||||
if idx < 0 || idx >= state.TotalEntries {
|
endIndex := startIndex + state.VisibleCount + 1
|
||||||
continue
|
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 {
|
if !ok {
|
||||||
// Page not loaded yet; add placeholder
|
// Page not loaded yet; add placeholder
|
||||||
items = append(items, ui.ListItem{
|
items = append(items, ui.ListItem{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user