Skip to content

fix: canMerge implementation#1

Merged
guyutongxue merged 5 commits into
mainfrom
copilot/fix-canmerge-wrongly-adding-startoffset
Jun 3, 2026
Merged

fix: canMerge implementation#1
guyutongxue merged 5 commits into
mainfrom
copilot/fix-canmerge-wrongly-adding-startoffset

Conversation

Copilot AI commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Pull request created by AI Agent

@guyutongxue guyutongxue marked this pull request as ready for review June 3, 2026 05:43
Copilot AI review requested due to automatic review settings June 3, 2026 05:43
@guyutongxue guyutongxue changed the title Fixing canMerge implementation and updating tests fix: canMerge implementation Jun 3, 2026
@guyutongxue guyutongxue merged commit 28deb7d into main Jun 3, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes source-map segment merging so adjacent mappings are merged correctly even when the mapping does not start at source offset 0, and updates/extends tests to cover the corrected behavior and resulting mapping shapes.

Changes:

  • Correct canMerge adjacency logic to compare end/start offsets directly.
  • Add a regression test for merging adjacent mappings with non-zero source offsets.
  • Update existing mapping assertions impacted by the new merging behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
test/printer.test.ts Adds/updates tests to validate the corrected mapping merge behavior and the resulting merged mapping segments.
src/mappings.ts Fixes canMerge so pushMapping can merge truly adjacent source/generated segments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/mappings.ts
Comment on lines 61 to 64
return (
left.sourceStart + left.sourceEnd === right.sourceStart &&
left.generatedStart + left.generatedEnd === right.generatedStart
left.sourceEnd === right.sourceStart &&
left.generatedEnd === right.generatedStart
);
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.

3 participants