Skip to content

Commit

Permalink
fix: bug with offset in time mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Oct 26, 2023
1 parent 0326883 commit ff092f1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/mux/screen/replay/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (r *Replay) getLine(row int) emu.Line {
func (r *Replay) exitSelectionMode() {
r.isSelectionMode = false
termCursor := r.getTerminalCursor()
r.center(termCursor)
r.centerPoint(termCursor)
r.cursor = r.termToViewport(termCursor)
r.desiredCol = r.cursor.C
}
Expand Down
6 changes: 1 addition & 5 deletions pkg/mux/screen/replay/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,9 @@ func (r *Replay) setIndex(index, indexByte int, updateTime bool) {

r.isSelectionMode = false

// reset scroll offset whenever we move in time
r.offset.R = 0
r.offset.C = 0

// Center the cursor if it's not in the viewport
if !r.isInViewport(viewportCursor) {
r.center(termCursor)
r.centerPoint(termCursor)
}

r.cursor = r.termToViewport(termCursor)
Expand Down
6 changes: 3 additions & 3 deletions pkg/mux/screen/replay/viewport.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func (r *Replay) setViewport(oldViewport, newViewport geom.Size) (taro.Model, te
r.setOffsetY(-1)

if r.isSelectionMode {
r.center(r.cursor)
r.centerPoint(r.cursor)
} else {
r.center(r.getTerminalCursor())
r.centerPoint(r.getTerminalCursor())
}

return r, nil
Expand All @@ -67,7 +67,7 @@ func (r *Replay) setOffsetX(offset int) {
}

// Center the viewport on a point in the reference frame of the terminal.
func (r *Replay) center(point geom.Vec2) {
func (r *Replay) centerPoint(point geom.Vec2) {
r.setOffsetX(point.C - (r.viewport.C / 2))
r.setOffsetY(point.R - (r.viewport.R / 2))
}
Expand Down

0 comments on commit ff092f1

Please sign in to comment.