@@ -1724,13 +1724,19 @@ func (m *interactiveModel) rebuildTableForWidth() {
m.rebuildSpecsTable(width)
}
- // Restore cursor position (bounded to row count)
+ // Restore cursor position (bounded to row count).
+ // Use GotoTop + MoveDown instead of SetCursor because SetCursor
+ // does not adjust the viewport YOffset, causing the highlighted
+ // row to be scrolled out of the visible area after a table rebuild.
rowCount := len(m.table.Rows())
if rowCount > 0 {
- if currentCursor >= rowCount {
- m.table.SetCursor(rowCount - 1)
- } else {
- m.table.SetCursor(currentCursor)
+ target := currentCursor
+ if target >= rowCount {
+ target = rowCount - 1
+ }
+ m.table.GotoTop()
+ if target > 0 {
+ m.table.MoveDown(target)
}
}