Repository navigation
Respect the exclusive TextRange.end in add_messages_for_semantic_ref (#372) - #376
Open
Kevin Turcios (KRRT7) wants to merge 1 commit into
Open
Kevin Turcios (KRRT7) wants to merge 1 commit into
Kevin Turcios (KRRT7) wants to merge 1 commit into
Conversation
…icrosoft#372) The loop ran through end.message_ordinal inclusive, so a range ending at chunk 0 of a message also added that message, which holds none of the range's text. Include end.message_ordinal only when end.chunk_ordinal > 0.
Kevin Turcios (KRRT7)
marked this pull request as ready for review
October 25, 2026 09:29
This branch has not been deployed
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 #372.
Behavior
MessageAccumulator.add_messages_for_semantic_reflooped overrange(start.message_ordinal, end.message_ordinal + 1), treatingTextRange.endas inclusive. The end is exclusive (itschunk_ordinalis 1 + the last chunk in the range), so whenend.chunk_ordinal == 0the messageend.message_ordinalholds none of the range's text but was still added to the matches. For example,TextRange(TextLocation(0), TextLocation(1))covers exactly message 0 but also added message 1.text_range_from_message_rangeproduces ranges of this shape.Now
end.message_ordinalis included only whenend.chunk_ordinal > 0. Ranges ending inside a message, and ranges within a single message, keep including that message as before.Validation
test_add_messages_for_semantic_ref_exclusive_endcovers a point range, a range of exactly one message, an end at chunk 0, an end inside a message, and a range within one message. The first two range cases fail onmain.test_add_messages_for_semantic_ref_matches_text_range_containmentchecks every well-formed range with endpoints in messages 0–3, chunks 0–3: the accumulator adds exactly the messages that have a chunk contained in the range perTextRange.__contains__. It fails onmain.make format check testpasses: 939 passed, 12 skipped.