Restore deriveSegmentText() to fix missing matchedText - #155
Conversation
ec46820 to
5f83337
Compare
|
Coverage after merging fix/derive-segment-text into fix/regex-local-filter-full-content will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 similar comment
|
Coverage after merging fix/derive-segment-text into fix/regex-local-filter-full-content will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This PR restores deriveSegmentText() in src/api.ts so text-match segments missing the text field from GitHub’s API derive their matched text from fragment.slice(indices[0], indices[1]), preventing empty/missing matched text in downstream output.
Changes:
- Reintroduced
deriveSegmentText(fragment, seg)and applied it duringfetchAllResults()text-match normalization. - Added unit tests for
deriveSegmentText()covering provided text, omitted text, and invalid indices. - Added a
fetchAllResults()regression test ensuring derived segment text is produced whensegment.textis omitted.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/api.ts | Restores deriveSegmentText() and uses it when mapping raw GitHub text-match segments into normalized matches. |
| src/api.test.ts | Adds unit coverage for deriveSegmentText() and an integration-style regression test for fetchAllResults() deriving missing segment text. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| it("derives matchedText from fragment + indices when GitHub omits the segment's text field (issue #151)", async () => { | ||
| const fakeItem = { | ||
| path: "src/foo.ts", | ||
| html_url: "https://github.com/org/repo/blob/main/src/foo.ts", | ||
| repository: { full_name: "org/repo", archived: false }, |
5f83337 to
7879ae5
Compare
|
Coverage after merging fix/derive-segment-text into fix/regex-local-filter-full-content will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 similar comment
|
Coverage after merging fix/derive-segment-text into fix/regex-local-filter-full-content will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
7879ae5 to
5d605b1
Compare
|
Coverage after merging fix/derive-segment-text into fix/regex-local-filter-full-content will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 similar comment
|
Coverage after merging fix/derive-segment-text into fix/regex-local-filter-full-content will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PR #133 introduced deriveSegmentText() to derive a text-match segment's matched text from fragment.slice(indices[0], indices[1]) when GitHub omits the text field, but the current code on this branch still defaulted to an empty string in that case. Reintroduced the helper and wired it into fetchAllResults()'s mapping, with unit tests for the helper itself and an integration test through fetchAllResults() covering the omitted-text case. Closes #151
5d605b1 to
e4b7220
Compare
|
Coverage after merging fix/derive-segment-text into fix/regex-local-filter-full-content will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 similar comment
|
Coverage after merging fix/derive-segment-text into fix/regex-local-filter-full-content will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
What does this PR do?
Closes #151.
Pull request #133 introduced
deriveSegmentText()to derive a text-match segment's matched text fromfragment.slice(indices[0], indices[1])when GitHub omits thetextfield, but the current code on this branch still defaulted to an empty string in that case. This reintroduces the helper insrc/api.tsand wires it intofetchAllResults()'s mapping.How did you verify your code works?
deriveSegmentText()itself (provided text, omitted text, out-of-range indices, inverted indices).fetchAllResults()covering atext_matchessegment with notextfield, asserting the derived value is correct.