Repository navigation
Keep n/N's place when the page changes while a repeated page search still runs - #5910
Merged
Merged
Conversation
…runs When the page changed after Enter, n or N searched again by calling find with a landing for a new query, then cleared it. find takes its first slice at once, so on a page whose search outlasts that slice, the slice could land on the first match in the window and write it into the repeated search's position. Where the step then stayed put (N from the first match, "Searching"), the position kept that match, and the next N stepped back from it rather than coming round to the last match. find now takes its landing as one optional argument, and repeatSearch passes none, so a repeated search lands nowhere and steps from where it stood. The stray landing, the line clearing it and an index argument nothing read go. Introduced by #5875. The new browser test fails before this change (the second N selects match 1) and passes after.
leaf-agent
added a commit
that referenced
this pull request
Nov 16, 2026
…h the held search before Shift+n (#6211) Two tests failed in main's push run [43928743834](https://github.com/max-sixty/leaf/actions/runs/43928743834) (`3bc561561`). This PR fixes both, and changes only the tests. - **`test_code_is_colored_without_a_word_moving`**: the test was stale after #6191. That PR moved a docked `lf-note`'s line indent out of its padding and into `margin-inline-start`, so the card keeps its first-paint size. The card and its words still stand where they did, but the note's border box now starts at the indent: 33.5px from the frame for the example's 4-space line, where the test expected 1px. The test now measures the note's margin box, which is what meets the frame (to within 0.1px, since the indent is a fractional number of `ch`). It fails on `main`. With #6191's `code.css` reverted, the old assertion passes. - **`test_a_step_back_after_the_page_changed_keeps_the_match_it_stood_on`**: the test pressed before the page was ready. It released the held search slices and pressed Shift+n at once. On a slow runner the search was still going, so the step back stayed on the first match and said "Searching", which is the behavior #5910 specified, and the wait for the last match ran out at 120 s. The test now runs the held slices, and any they schedule, until the search ends, and then presses. With `leaf-dev suite flake --cpu-throttle 8`, it failed 4 of 18 copies before this change and 0 of 18 after. It also passed 18 of 18 at throttle 16. The other two failures in that run already have owners: #5642/#6130 and #6139. Not covered here: at throttle 8 to 16, `test_code_is_colored_without_a_word_moving` also fails sometimes at an earlier line. The test reads the `lf-code` token colours before `bucket_key` is split into its own span. CI has not shown this failure, and it happens with or without this change. Refs #3985 — automated triage Co-authored-by: leaf-agent <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After Enter closes a page search and the page then changes,
nor Shift+nsearches again from the match it selected. On a page whose search outlasts its first 8 ms slice, a step back from the first match could lose that place: the next Shift+nstepped back to match 1 instead of coming round to the last match. This keeps the place, and a new browser test fails before the change and passes after it.Cause.
repeatSearchcalledfindwith a new query's landing ("the first match at or below the top of the window"), then cleared it. Butfindtakes its first slice at once, and that slice can land before the clear. Landing with the field closed writes the match into the repeated search's position intake. The normal step overwrote that position again, but a step that stays put while the search runs (Shift+nfrom the first match, which says "Searching") kept the stray one.Change.
findnow takes its landing as one optional argument.repeatSearchpasses none, so the search it starts lands nowhere. That removes the stray landing, the line clearing it, and anindexargument nothing read.Test.
test_a_step_back_after_the_page_changed_keeps_the_match_it_stood_onsearches ten text documents, selects match 1 with Enter, scrolls it above the window and changes the page. It holds the page's zero-delay timers and lets the first slice take a dozen steps, so the search is still running when Shift+nsays "Searching". Once the search ends, the next Shift+nmust select the last match. On main it selects match 1. The test and the existing search and match tests intest_render_anchors.py(31) pass, andpre-commitand the browser type check pass.#5875 introduced this; the nightly review of recent commits found it.