Fix missing matchedText key in JSON result#133
Draft
armandabric wants to merge 1 commit into
Draft
Conversation
|
Coverage after merging fix/missing-matched-text-attibutes into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes missing matchedText in JSON output by deriving match segment text from the fragment using GitHub-provided indices when seg.text is omitted, keeping output consistent and improving downstream rendering.
Changes:
- Added
deriveSegmentText()insrc/api.tsto compute segment text fromfragment+indiceswhen GitHub omits thetextfield. - Updated
fetchAllResults()normalization to use the derived segment text instead of defaulting missing text to"". - Added a unit test in
src/api.test.tsto validate derived segment text behavior; clarified an existing comment insrc/output.test.ts.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/api.ts |
Derives missing text-match segment text from fragment and indices during result normalization. |
src/api.test.ts |
Adds coverage ensuring omitted seg.text is correctly derived from the fragment. |
src/output.test.ts |
Updates wording to reflect that empty segment text should not emit matchedText in JSON. |
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.
This pull request improves the handling of text matches in search results, specifically addressing cases where GitHub omits the matched text. The main changes ensure that the matched text is accurately derived from the fragment when necessary, and that the output remains consistent.
Text match derivation and normalization:
deriveSegmentTextinsrc/api.tsto extract the matched text from the fragment using indices when GitHub does not provide the text. This function is now used when processing search results. [1] [2]src/api.test.tsto verify that segment text is correctly derived from the fragment when omitted by GitHub.Test and comment improvements:
src/output.test.tsto reflect that empty segment text should not emitmatchedTextin the JSON output.