Skip to content

fix: preserve meaningful surrounding spaces in JSX text#782

Open
SunsetTechuila wants to merge 5 commits into
dprint:mainfrom
SunsetTechuila:space-jsx-2
Open

fix: preserve meaningful surrounding spaces in JSX text#782
SunsetTechuila wants to merge 5 commits into
dprint:mainfrom
SunsetTechuila:space-jsx-2

Conversation

@SunsetTechuila
Copy link
Copy Markdown

@SunsetTechuila SunsetTechuila commented May 19, 2026

Fixes #476

Surrounding spaces are trimmed in the get_lines function to remove source indentation for multi-line cases:

let lines = node_text.trim().lines().map(|line| line.trim());

I ended up fixing this at the gen_for_single_line level, as solutions at the gen_jsx_text and get_lines levels seemed worse.

Important

This PR is AI-assisted. I have little experience working with Rust and none working on parsers or formatters.


fn has_jsx_trailing_space<'a>(current_node: Node<'a>, previous_node: Option<Node<'a>>, context: &Context<'a>) -> bool {
if let Node::JSXText(text) = current_node {
if matches!(previous_node, Some(previous_node) if is_ignore_jsx_expr_container(previous_node, context)) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

is_ignore_jsx_expr_container

Otherwise tests/specs/issues/deno/issue026681.txt fails

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.

JSX: Does not respect significant whitespace around expressions

1 participant