Skip to content

fix(formatter): Count emoji sequences correctly#17331

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-24-fix_formatter_count_emoji_sequences_correctly
Dec 25, 2025
Merged

fix(formatter): Count emoji sequences correctly#17331
graphite-app[bot] merged 1 commit intomainfrom
12-24-fix_formatter_count_emoji_sequences_correctly

Conversation

@leaysgur
Copy link
Member

@leaysgur leaysgur commented Dec 24, 2025

Copilot AI review requested due to automatic review settings December 24, 2025 07:19
@leaysgur leaysgur requested a review from Dunqing as a code owner December 24, 2025 07:19
@github-actions github-actions bot added the A-formatter Area - Formatter label Dec 24, 2025
Copy link
Member Author

leaysgur commented Dec 24, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Contributor

Copilot AI left a comment

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 a bug where emoji sequences (particularly those with variation selectors) were counted incorrectly when calculating text width in the formatter. The fix changes from character-by-character width calculation to segment-based calculation using UnicodeWidthStr::width(), which correctly handles complex Unicode sequences as grapheme clusters.

Key Changes:

  • Replaced character-by-character iteration with segment-based width calculation in TextWidth::from_text()
  • Removed unused UnicodeWidthChar import and retained UnicodeWidthStr
  • Added comprehensive test coverage for emoji sequences with variation selectors

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

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 24, 2025

CodSpeed Performance Report

Merging #17331 will not alter performance

Comparing 12-24-fix_formatter_count_emoji_sequences_correctly (b58d3de) with main (b00da37)1

Summary

✅ 38 untouched
⏩ 7 skipped2

Footnotes

  1. No successful run was found on main (0e79375) during the generation of this report, so b00da37 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@leaysgur leaysgur force-pushed the 12-24-fix_formatter_count_emoji_sequences_correctly branch from 787dd9d to 3094071 Compare December 24, 2025 07:26
Copy link
Member

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

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

Please add a test in the fixtures; I want to see the final output

Copy link
Member

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

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

Nice finding

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Dec 25, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 25, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the 12-24-fix_formatter_count_emoji_sequences_correctly branch from b58d3de to a55bfc1 Compare December 25, 2025 01:16
@graphite-app graphite-app bot merged commit a55bfc1 into main Dec 25, 2025
20 checks passed
@graphite-app graphite-app bot deleted the 12-24-fix_formatter_count_emoji_sequences_correctly branch December 25, 2025 01:23
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-formatter Area - Formatter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

formatter: Diff with Prettier on Template String in Function Calls

3 participants