Skip to content

fix: preserve diff scroll position during auto-refresh#24

Merged
JanSmrcka merged 4 commits intomasterfrom
fix/preserve-scroll-on-refresh
Feb 23, 2026
Merged

fix: preserve diff scroll position during auto-refresh#24
JanSmrcka merged 4 commits intomasterfrom
fix/preserve-scroll-on-refresh

Conversation

@JanSmrcka
Copy link
Copy Markdown
Owner

@JanSmrcka JanSmrcka commented Feb 23, 2026

Summary

  • 2s pollInterval tick was calling viewport.GotoTop() unconditionally on every diff reload, resetting scroll position
  • Added resetScroll flag to diffLoadedMsg — only true for user-initiated loads (file switch, split toggle, resize)
  • Added lastDiffContent dedup to skip viewport update entirely when content unchanged (prevents flicker)

Test plan

  • go run . in repo with long diff, scroll down, wait >2s — scroll preserved
  • Edit file externally while viewing diff — content updates, scroll stays
  • Switch files with n/p — scroll resets to top
  • Toggle split with v — scroll resets to top
  • make test passes

🤖 Generated with Claude Code

JanSmrcka and others added 4 commits February 23, 2026 14:32
2s poll tick was resetting viewport to top via unconditional GotoTop()
in handleDiffLoaded. Add resetScroll flag to diffLoadedMsg — only true
for user-initiated loads (file switch, split toggle, resize). Tick
refreshes pass false. Also skip viewport update entirely when content
unchanged (lastDiffContent dedup).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
viewport.New() creates empty viewport, but dedup check in
handleDiffLoaded skipped SetContent when diff unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Locks behavior: handleResize clears lastDiffContent so
handleDiffLoaded re-applies content to recreated viewport.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@JanSmrcka JanSmrcka merged commit e8f6d0c into master Feb 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant