Skip to content

Commit

Permalink
fix: keep table offset on deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
dundee committed Mar 30, 2024
1 parent d511c55 commit 7bfeb98
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tui/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ func (ui *UI) deleteSelected(shouldEmpty bool) {

ui.app.QueueUpdateDraw(func() {
ui.pages.RemovePage(acting)
x, y := ui.table.GetOffset()
ui.showDir()
ui.table.Select(min(row, ui.table.GetRowCount()-1), 0)
ui.table.SetOffset(min(x, ui.table.GetRowCount()-1), y)
})

if ui.done != nil {
Expand Down
2 changes: 2 additions & 0 deletions tui/marked.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ func (ui *UI) deleteMarked(shouldEmpty bool) {
ui.app.QueueUpdateDraw(func() {
ui.pages.RemovePage(acting)
ui.markedRows = make(map[int]struct{})
x, y := ui.table.GetOffset()
ui.showDir()
ui.table.Select(min(currentRow, ui.table.GetRowCount()-1), 0)
ui.table.SetOffset(min(x, ui.table.GetRowCount()-1), y)
})

if ui.done != nil {
Expand Down

0 comments on commit 7bfeb98

Please sign in to comment.