llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.16k stars 12.03k forks source link

Regression in formatting for JS template strings #107571

Open kadircet opened 2 months ago

kadircet commented 2 months ago

Actual formatting:

# clang-format a.ts

`${
    (
        FOOFOOFOOFOO____FOO_FOO_FO_FOO_FOOO -
            (barbarbarbar____bar_bar_bar_bar_bar_bar +
                bar_bar_bar_barbarbar___bar_bar_bar + 1),
        )}`;

Expected formatting:

`${
    (
        FOOFOOFOOFOO____FOO_FOO_FO_FOO_FOOO -
            (barbarbarbar____bar_bar_bar_bar_bar_bar +
             bar_bar_bar_barbarbar___bar_bar_bar + 1),
        )}`;

i.e. no extra indentation for the inner subexpression, as that's the formatting we got without template strings:

# clang-format a.ts

FOOOOOOOOFOOFOOFOOFOO____FOO_FOO_FO_FOO_FOOO -
    (barrrrbarbarbarbar____bar_bar_bar_bar_bar_bar +
     barrrrbar_bar_bar_barbarbar___bar_bar_bar + 1),
kadircet commented 2 months ago

https://github.com/llvm/llvm-project/commit/ccae7b461be339e717d02f99ac857cf0bc7d17fc seems to be the culprit

cc @gedare @owenca

llvmbot commented 2 months ago

@llvm/issue-subscribers-clang-format

Author: kadir çetinkaya (kadircet)

Actual formatting: ``` # clang-format a.ts `${ ( FOOFOOFOOFOO____FOO_FOO_FO_FOO_FOOO - (barbarbarbar____bar_bar_bar_bar_bar_bar + bar_bar_bar_barbarbar___bar_bar_bar + 1), )}`; ``` Expected formatting: ``` `${ ( FOOFOOFOOFOO____FOO_FOO_FO_FOO_FOOO - (barbarbarbar____bar_bar_bar_bar_bar_bar + bar_bar_bar_barbarbar___bar_bar_bar + 1), )}`; ``` i.e. no extra indentation for the inner subexpression, as that's the formatting we got without template strings: ``` # clang-format a.ts FOOOOOOOOFOOFOOFOOFOO____FOO_FOO_FO_FOO_FOOO - (barrrrbarbarbarbar____bar_bar_bar_bar_bar_bar + barrrrbar_bar_bar_barbarbar___bar_bar_bar + 1), ```