Skip to content

Commit 806ff7b

Browse files
committed
Only scroll to selected match when outside visible viewport
1 parent 0f7174d commit 806ff7b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

plugins/lua/orders.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,12 @@ function OrdersSearchOverlay:cycle_match(direction)
950950
self.matched_indices = new_matches
951951
self.current_match_idx = new_match_idx
952952

953-
-- Scroll to the selected match
953+
-- Scroll to the selected match only if not already visible
954954
local order_idx = self.matched_indices[self.current_match_idx]
955-
mi.info.work_orders.scroll_position_work_orders = order_idx
955+
local viewport_start, viewport_end = getVisibleOrderIndices()
956+
if order_idx < viewport_start or order_idx > viewport_end then
957+
mi.info.work_orders.scroll_position_work_orders = order_idx
958+
end
956959

957960
self.subviews.main_panel.frame_title = 'Search' .. self:get_match_text()
958961
end

0 commit comments

Comments
 (0)