impr: Jump to top of selection instead of the bottom

Fixes #2354
This commit is contained in:
WerWolv
2025-09-10 20:50:27 +02:00
parent 88ccb0e075
commit c1619820c7
2 changed files with 7 additions and 4 deletions

View File

@@ -1054,15 +1054,15 @@ namespace hex::ui {
// Calculate the current top and bottom row numbers of the viewport
ImS64 currentTopRow = m_scrollPosition;
ImS64 currentBottomRow = m_scrollPosition + m_visibleRowCount - 3;
ImS64 currentBottomRow = std::max<ImS64>(m_scrollPosition + m_visibleRowCount - 3, 0);
// Check if the targetRowNumber is outside the current visible range
if (ImS64(targetRowNumber) < currentTopRow) {
// If target is above the current view, scroll just enough to bring it into view at the top
m_scrollPosition = targetRowNumber - (m_visibleRowCount * m_jumpPivot);
m_scrollPosition = targetRowNumber + m_visibleRowCount * m_jumpPivot - 3;
} else if (ImS64(targetRowNumber) > currentBottomRow) {
// If target is below the current view, scroll just enough to bring it into view at the bottom
m_scrollPosition = targetRowNumber - (m_visibleRowCount - 3);
m_scrollPosition = targetRowNumber - 3;
}
m_jumpPivot = 0.0F;