Repository navigation
Find a whole JSON string before a substring in FindLocation [patch] - #63
Merged
Merged
Conversation
FindLocation(needle) and FindLocation(anchor, needle) matched with a plain substring search, so "Meter" landed inside "SquareMeter" and the anchored overload scoped to the wrong entry. Both now look for the quoted string first and fall back to the raw search only when that finds nothing. Fixes #33 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4i7FzmxvaxCZgeCwe
|
This was referenced Nov 4, 2026
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.



MetadataFile.FindLocation(needle)andFindLocation(anchor, needle)found both strings with a plain ordinalIndexOf, so a name contained in a longer one matched the longer one. WithSquareMeterlisted beforeMeter, both overloads pointed at theSquareMeterentry.Both overloads now look for the quoted string (
"Meter") first and return a span that covers only the name inside the quotes. The raw substring search remains the fallback, so a number, or an anchor the caller has already quoted (as the existing"\"b\""test does), is still found.Tests:
FindLocationSkipsALongerNameThatContainsTheNeedleandScopedFindLocationSkipsALongerNameThatContainsTheAnchoruse the repro from the issue. Both fail onmain(they land on line 2) and pass with the change.FindLocationStillFindsTextThatIsNotAWholeStringcovers the fallback.Fixes #33
Generated by Claude Code