Skip to content

Fix missing matchedText key in JSON result#133

Draft
armandabric wants to merge 1 commit into
mainfrom
fix/missing-matched-text-attibutes
Draft

Fix missing matchedText key in JSON result#133
armandabric wants to merge 1 commit into
mainfrom
fix/missing-matched-text-attibutes

Conversation

@armandabric

Copy link
Copy Markdown
Collaborator

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:

  • Added a new function deriveSegmentText in src/api.ts to 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]
  • Updated the test suite in src/api.test.ts to verify that segment text is correctly derived from the fragment when omitted by GitHub.

Test and comment improvements:

  • Clarified the comment in src/output.test.ts to reflect that empty segment text should not emit matchedText in the JSON output.

@armandabric armandabric requested review from Copilot and shouze July 7, 2026 13:07
@armandabric armandabric self-assigned this Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Coverage after merging fix/missing-matched-text-attibutes into main will be

95.89%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.80%100%100%94.14%331–335, 396, 413, 75–81
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.26%100%100%99.21%251
   render.ts89.87%100%89.47%89.89%167, 191–196, 198–200, 202–203, 254–255, 276, 463–464, 487–489, 555–559, 571–572, 577–584, 586–594, 596–597
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() in src/api.ts to compute segment text from fragment + indices when GitHub omits the text field.
  • Updated fetchAllResults() normalization to use the derived segment text instead of defaulting missing text to "".
  • Added a unit test in src/api.test.ts to validate derived segment text behavior; clarified an existing comment in src/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.

@armandabric armandabric marked this pull request as draft July 7, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants