Repository navigation
Editor search: one current match, the selected one if it is a match (#1145) - #1167
Merged
Merged
Conversation
…1145) Of two adjacent matches, the caret at the end of the first one is also at the start of the second, and both were drawn as current. The current match is now the selected match if the selection is one, else the first match with the caret inside or right after it; Find next and Replace count from the same match (findNextPattern takes the selection). The match loop is shared by the highlight and findAll(), the choice of the current and the next match are static functions with unittests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #1145
Two adjacent search matches could both get the current-match color: the caret at the end of the first one is also at the start of the second.
Changes (
editors.d):currentMatchIndex()). After Find next, the found match is selected; after selecting a match from right to left (caret at its start), that match stays current too.findNextPattern()counts from the same current match: it takes the selection as a new last parameter (TextRange selection = TextRange.init), and the Find panel passes it for Find next and Replace. Before, Find next from a match selected right to left selected the same match again.findAll()(forEachLineMatch()), so both see the same matches; the index arithmetic offindNextPattern()moved unchanged intonextMatchIndex().currentMatchIndex()andnextMatchIndex()(adjacent matches, selections in both directions, a selection that isn't a match, wrapping, a single match). They fail with the old rule.API change:
findNextPattern()has a new parameter with a default value, so calls compile as before, but a subclass overriding the old 4-parameter version no longer compiles. DlangIDE doesn't override or call it.Testing:
dub test(36 modules) anddub test -c console(33), no leak lines; D-Scanner clean; dmledit and DlangIDE build.Found by the reviews, filed separately: #1164 (Replace repeats when the replacement is a match), #1165 (Find next skips the match at the caret without a selection), #1166 (Selection option ignored by Find next and Replace).
🤖 Generated with Claude Code