Skip to content

Commit 3e42aaf

Browse files
committed
Improve sidebar scroll behaviour on search
1 parent 80f117d commit 3e42aaf

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/TSMapEditor/UI/Sidebar/TreeView.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,17 @@ public void FindNode(string text, bool findNext)
226226
SelectedNode = foundNode;
227227

228228
// Scroll the view to the found item
229-
int totalHeight = GetTotalContentHeight();
230-
if (accumulatedHeight + Height > totalHeight)
231-
accumulatedHeight = totalHeight - Height;
229+
int contentHeight = GetTotalContentHeight();
230+
if (accumulatedHeight + LineHeight + MARGIN > ViewTop + Height)
231+
{
232+
ViewTop += accumulatedHeight + LineHeight + MARGIN - (ViewTop + Height);
233+
}
234+
else if (accumulatedHeight < ViewTop)
235+
{
236+
ViewTop = accumulatedHeight - LineHeight;
237+
}
232238

233239
RefreshScrollbar();
234-
ViewTop = accumulatedHeight;
235240
}
236241
}
237242

0 commit comments

Comments
 (0)