Skip to content

TXT chapter mode: progress bar shows book progress instead of chapter progress #31

@lllyys

Description

@lllyys

Bug

Severity: Medium

Repro

  1. Open a TXT file that has detected chapters (WI-6 chapter-based mode)
  2. Navigate to any chapter
  3. Observe the ReadingProgressBar scrubber and progress percentage

Expected

Progress bar reflects position within the current chapter (0-100%).

Actual

Progress bar shows position relative to the whole book.

Root cause

currentOffsetUTF16 in TXTReaderViewModel is dual-purpose — set to a global offset by navigateToChapter() but overwritten with local (chapter-relative) offsets by the bridge's scroll callbacks. The onChange handler in TXTReaderContainerView that feeds chapterScrollFraction can't reliably distinguish them.

Attempted fixes

  • Normalize offset by subtracting chapter.globalStartUTF16 when offset >= globalStart
  • Still unreliable due to dual-purpose currentOffsetUTF16

Proper fix needed

Separate currentOffsetUTF16 (global, for persistence) from a chapter-local scroll fraction reported directly by the bridge.

Files

  • vreader/Views/Reader/TXTReaderContainerView.swift — progress bar wiring
  • vreader/ViewModels/TXTReaderViewModel.swiftcurrentOffsetUTF16, navigateToChapter()
  • vreader/Views/Reader/TXTTextViewBridgeCoordinator.swift — scroll callbacks

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions