fix: handle multibyte characters in descriptions#1109
Merged
Conversation
Ticket: DX-2788 This commit handles multibyte UTF-8 characters in descriptions. SWC uses UTF-8 byte offsets, while JavaScript uses character offsets. This causes a gradual offset in indices.
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue with parsing JSDoc comments containing multibyte UTF-8 characters. SWC uses byte offsets while JavaScript uses character offsets, causing incorrect comment extraction when multibyte characters are present.
Changes:
- Added byte-to-character offset conversion logic to handle multibyte UTF-8 characters
- Improved JSDoc comment boundary detection using
lastIndexOf/indexOfinstead ofsplit() - Added comprehensive test case for multibyte character handling
- Cleaned up trailing whitespace in existing test comments
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| packages/openapi-generator/src/comments.ts | Implemented byte offset conversion for multibyte characters and improved comment boundary detection logic |
| packages/openapi-generator/test/openapi/comments.test.ts | Added test case for multibyte characters and removed trailing whitespace from JSDoc comments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ericcrosson-bitgo
approved these changes
Jan 15, 2026
Contributor
ericcrosson-bitgo
left a comment
There was a problem hiding this comment.
Thanks, @starfy84 !
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.
Ticket: DX-2788
This commit handles multibyte UTF-8 characters in descriptions. SWC uses UTF-8 byte offsets, while JavaScript uses character offsets. This causes a gradual offset in indices.