From ff092f1c6941bec514b0b19e6527843c70ed8dc9 Mon Sep 17 00:00:00 2001 From: Caleb Foust Date: Thu, 26 Oct 2023 06:17:31 -0400 Subject: [PATCH] fix: bug with offset in time mode --- pkg/mux/screen/replay/screen.go | 2 +- pkg/mux/screen/replay/time.go | 6 +----- pkg/mux/screen/replay/viewport.go | 6 +++--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/pkg/mux/screen/replay/screen.go b/pkg/mux/screen/replay/screen.go index d87306dd..7f7a9e41 100644 --- a/pkg/mux/screen/replay/screen.go +++ b/pkg/mux/screen/replay/screen.go @@ -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 } diff --git a/pkg/mux/screen/replay/time.go b/pkg/mux/screen/replay/time.go index 9589ee03..4d381da3 100644 --- a/pkg/mux/screen/replay/time.go +++ b/pkg/mux/screen/replay/time.go @@ -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) diff --git a/pkg/mux/screen/replay/viewport.go b/pkg/mux/screen/replay/viewport.go index d5c8cf2a..91a6c14f 100644 --- a/pkg/mux/screen/replay/viewport.go +++ b/pkg/mux/screen/replay/viewport.go @@ -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 @@ -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)) }