Skip to content

fix: a display line changing is not hidden by the other lines on the page - #68

Open
bluzername wants to merge 1 commit into
awlevin:mainfrom
bluzername:fix-same-screen-single-line-change
Open

bluzername wants to merge 1 commit into
awlevin:mainfrom
bluzername:fix-same-screen-single-line-change

Conversation

@bluzername

Copy link
Copy Markdown

Fixes part of #58 (bug 5, "One changed line in ten counts as the same screen").

same_screen only looked at how many lines differ against the page total. On a page with 10 or more lines, any single line changing was close enough to the clock/ticker ratio rule to count as no change. So a calculator display that gains a digit, or any other one-line content change, was swallowed as long as enough unrelated lines sat around it. This is what let the Calculator run in #58 stall before reaching =.

Fix: when exactly one line goes away and exactly one new line takes its place, that line is now checked for whether it looks like noise (same text once a clock/ticker is stripped, same length with at most one changed character, or a digit swap) before the ratio rule gets to decide. A real change no longer hides behind nine other lines that did not move. Noise (a clock, a ticker) is still absorbed exactly as before.

I re-derived this independently from the bug report rather than taking the diff there as-is; the shape ended up close to it, but the test is new.

Test: added test_a_display_line_changing_is_a_new_screen_even_on_a_longer_page to tests/test_signature.py - a 10-line page where only the display line changes from "0" to "29". It fails on main (same_screen returns True, should be False) and passes with this fix.

Ran before opening:

uv run ruff check . && uv run ruff format --check .
uv run pytest -q

731 passed, 2 skipped, 1 xfailed (one more pass than main's 730, the new test).

🤖 Generated with Claude Code

…page

same_screen only looked at how many lines differ versus the page total.
On a page with 10 or more lines, one line changing in any way was close
enough to a clock or a ticker to count as no change, so a calculator
display that gains a digit, or any other single-line content change,
was swallowed when enough unrelated lines sat around it.

Now a single line changed in place has to look like noise first (same
text once a clock or a ticker is stripped, same length with at most one
changed character, or a digit swap) before the ratio rule gets to decide.
A real change no longer hides behind nine other lines that did not move.

Added a test with a 10-line page where only the display line changes
from "0" to "29": it failed before this fix (same_screen said True) and
passes now.
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