Skip to content

fix: restore indent level after LESS each() mixin #2380#2441

Open
Anton-dev3306 wants to merge 1 commit into
beautifier:mainfrom
Anton-dev3306:fix/less-each-indentation-2380-v2
Open

fix: restore indent level after LESS each() mixin #2380#2441
Anton-dev3306 wants to merge 1 commit into
beautifier:mainfrom
Anton-dev3306:fix/less-each-indentation-2380-v2

Conversation

@Anton-dev3306
Copy link
Copy Markdown

Closes #2380

Problem

After a LESS each() mixin call using object notation (});), the
beautifier zeroed the indent level for all subsequent rules, even when
still inside a parent block.

Root cause: the } handler calls outdent(), then when the next char
is ), trim(true) pops the newline — leaving current_line at the
previous (shallower) indent. The { opening the mixin body (preceded
by ,) skips indent(), so the net result is one extra outdent().

Fix

Added this.indent() / self.indent() after trim(true) in the
peek() === ')' branch to compensate for the asymmetry.

Both JS and Python implementations updated.

Verification

Input:

.my-function(@iterator) { each(@iterator, { color: red; }); .wrong { color: blue; } }

Before fix:

.my-function(@iterator) {
  each(@iterator, {
    color: red;
  });
.wrong {
  color: blue;
}
}

After fix:

.my-function(@iterator) {
  each(@iterator, {
    color: red;
  });
  .wrong {
    color: blue;
  }
}

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.

LESS "each" function breaks indentation

1 participant