@@ -24,13 +24,19 @@ type ListContextTrait struct {
2424 // If renderOnlyVisibleLines is true, needRerenderVisibleLines indicates whether we need to
2525 // rerender the visible lines e.g. because the scroll position changed
2626 needRerenderVisibleLines bool
27+
28+ inOnSearchSelect bool
2729}
2830
2931func (self * ListContextTrait ) IsListContext () {}
3032
3133func (self * ListContextTrait ) FocusLine (scrollIntoView bool ) {
3234 self .Context .FocusLine (scrollIntoView )
3335
36+ // Need to capture this in a local variable because by the time the AfterLayout function runs,
37+ // the field will have been reset to false already
38+ inOnSearchSelect := self .inOnSearchSelect
39+
3440 // Doing this at the end of the layout function because we need the view to be
3541 // resized before we focus the line, otherwise if we're in accordion mode
3642 // the view could be squashed and won't know how to adjust the cursor/origin.
@@ -40,6 +46,9 @@ func (self *ListContextTrait) FocusLine(scrollIntoView bool) {
4046
4147 self .GetViewTrait ().FocusPoint (
4248 self .ModelIndexToViewIndex (self .list .GetSelectedLineIdx ()), scrollIntoView )
49+ if ! inOnSearchSelect {
50+ self .GetView ().SetNearestSearchPosition ()
51+ }
4352
4453 selectRangeIndex , isSelectingRange := self .list .GetRangeStartIdx ()
4554 if isSelectingRange {
@@ -119,7 +128,9 @@ func (self *ListContextTrait) HandleRender() {
119128
120129func (self * ListContextTrait ) OnSearchSelect (selectedLineIdx int ) {
121130 self .GetList ().SetSelection (self .ViewIndexToModelIndex (selectedLineIdx ))
131+ self .inOnSearchSelect = true
122132 self .HandleFocus (types.OnFocusOpts {})
133+ self .inOnSearchSelect = false
123134}
124135
125136func (self * ListContextTrait ) IsItemVisible (item types.HasUrn ) bool {
0 commit comments