Skip to content

Commit

Permalink
fix: jsx_text node trims whitespace too often
Browse files Browse the repository at this point in the history
Co-authored-by: Amaan Qureshi <[email protected]>
  • Loading branch information
jackschu and amaanq committed Jul 6, 2024
1 parent 12e4537 commit 99be62f
Show file tree
Hide file tree
Showing 4 changed files with 2,778 additions and 2,785 deletions.
7 changes: 4 additions & 3 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,11 @@ module.exports = grammar({
field('close_tag', $.jsx_closing_element),
),

// Should not contain new lines and should not start or end with a space
jsx_text: _ => choice(
/[^{}<>\n& ]([^{}<>\n&]*[^{}<>\n& ])?/,
/\/\/[^\n]*/,
// if there is a newline, only capture if there's non-whitespace-text
token.immediate(/[^{}<>&]*[^{}<>\s\p{Zs}\uFEFF\u2028\u2029\u2060\u200B&][^{}<>&]*/),
// whitespace between jsx_tags should be captured if there's no newline
token.immediate(/[^{}<>\n&]+/),
),

// An entity can be named, numeric (decimal), or numeric (hexadecimal). The
Expand Down
14 changes: 10 additions & 4 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 99be62f

Please sign in to comment.