Skip to content

Fix section-limited search in single-page documents#379

Merged
cary-rowen merged 1 commit into
developfrom
fix/section-limited-search-ranges
May 24, 2026
Merged

Fix section-limited search in single-page documents#379
cary-rowen merged 1 commit into
developfrom
fix/section-limited-search-ranges

Conversation

@cary-rowen

Copy link
Copy Markdown
Collaborator

Link to issue number:

N/A

Summary of the issue:

Searching within a specific section did not work correctly for single-page documents with a table of contents, such as EPUB/HTML-derived documents.

When a section was selected in the search dialog, Bookworm still searched the full document because PageRangeControl.get_text_range() returned the root document range whenever the document had only one page.

Description of how this pull request fixes the issue:

This changes the section search range calculation so that, when a specific section is selected, Bookworm searches from that section's start position up to the next non-descendant section.

If no section-specific range can be determined, the existing fallback behavior is preserved.

Testing performed:

  • uv run --no-sync pytest tests/test_search.py -q -> 1 passed
  • uv run --no-sync pytest -q -> 134 passed

Known issues with pull request:

None known.

@cary-rowen
cary-rowen merged commit f1f86dd into develop May 24, 2026
19 of 21 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