[PATCH] D116638: [clang-format] Fix ignoring JavaScriptWrapImport when ColumnWidth: 0

Stanisław Małolepszy via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 8 08:50:03 PST 2022


stasm added a comment.

The reporter of issue 52935 <https://github.com/llvm/llvm-project/issues/52935> here. Thanks, @andmis, for your work.  Thinking about the `ColumnLimit: 0` and `JavaScriptWrapImports: false` case, it seems that there are two issues in the current implementation that could be solved separately.

1. Single-line imports get force-wrapped despite `JavaScriptWrapImports: false`. This seems to be a clear bug in `clang-format`. The expected behavior in this case should be to not touch the import line at all. Instead, the current behavior is the following:

  import {aaa, bbb, ccc} from "def";



  import {aaa,
          bbb,
          ccc} from "def";



2. It's not clear what `JavaScriptWrapImports: false` should do to multiline imports when `ColumnLimit: 0`. Should it
  - force-unwrap to a single line, or
  - leave the import as-is (i.e. //not force-wrap// it)?

    Since the expected behavior is not clear there might indeed be different groups of users expecting one behavior or the other. To reduce the ambiguity an enum option like the one proposed by @MyDeveloperDay  would be helpful.

I'd personally would love to see both of these issues addressed (and I'd be a happy user of `JavaScriptWrapImports: Never` if it's available), but just fixing the first bug would go a long way in making `ColumnLimit: 0` a viable setting for JavaScript for me.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116638/new/

https://reviews.llvm.org/D116638



More information about the cfe-commits mailing list