Skip to content

fix(fluent-syntax): Count indented placeables toward common indent - #405

Open
chiliec wants to merge 1 commit into
projectfluent:mainfrom
chiliec:fix-indented-placeable-dedent
Open

chiliec wants to merge 1 commit into
projectfluent:mainfrom
chiliec:fix-indented-placeable-dedent

Conversation

@chiliec

@chiliec chiliec commented Sep 27, 2026

Copy link
Copy Markdown

Fixes #286.

For a block pattern whose line starts with an indented placeable:

key12 =
    { "." }
        four

the parser skipped the placeable line's leading spaces and then dropped the resulting empty text slice. That line never counted toward the common indent, so only four's line did (8). All 8 spaces were stripped and the message parsed the same as if four had been indented by 4.

The fix: when a line-start text slice ends at a placeable, its indent now counts toward the common indent and it is kept as a text element, like the Indent token in fluent.js's getPattern/dedent. Elements that are empty after dedenting are dropped, so placeable lines at the common indent produce the same AST as before.

Examples:

  • { "." } at 4 spaces, four at 8 → " four" (was "four")
  • a at 4, { x } at 8 → "a\n", " ", { x } (the placeable's extra indent used to be lost)

Tests

  • Added the case from the issue to tests/fixtures/normalized/messages.ftl. Without the parser change roundtrip_normalized_fixtures fails (the line is reserialized as four). With it, the test passes.
  • cargo test --workspace: all pass
  • cargo fmt --all -- --check and cargo clippy -p fluent-syntax --all-targets: clean

crlf.ftl has to stay in IGNORE_LIST. Its roundtrip still fails for an unrelated reason: the CRLF Value 02 / \n text-element split differs from the reparsed LF output.

@alerque alerque assigned alerque and unassigned alerque Sep 28, 2026
@alerque
alerque self-requested a review September 28, 2026 08:59
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.

Parser swallows leading whitespace after indented placeable

2 participants