首页 > 解决方案 > IntelliJ - 有没有办法防止自动格式化程序折叠数组中项目之间的空格?

问题描述

在我的项目中,我们有一些数据是二维数组的区域,我们喜欢将列排列起来,以便于查看哪些数据在哪一列中。例如:

iit("returns #expected if input is #input", (test) => {
    expect(subject.apply(test.input)).to.equal(test.expected)
}).where([
    ["input",    "expected"],
    [null,       ""        ],
    [undefined,  ""        ],
    [[],         ""        ],
    [7,          42        ],       
})

但是,IntelliJ 的自动格式化程序喜欢删除数组中项目之间的空格,将上面的内容转换为:

iit("returns #expected if input is #input", (test) => {
    expect(subject.apply(test.input)).to.equal(test.expected)
}).where([
    ["input", "expected"],
    [null, ""],
    [undefined, ""],
    [[], ""],
    [7, 42],        
})

这可读性较差。有没有办法配置自动格式化程序在这种情况下单独留下空格?

我们的主要目标语言是 TypeScript,但它在 Java 或一般情况下也很方便。我已经探索了 IntelliJ 设置的 Editor -> Code Style 部分,但没有找到任何东西,也没有通过搜索引擎找到任何答案。

标签: typescriptintellij-ideawhitespace

解决方案


没有办法做到这一点,请投票给WEB-41045以通知此功能的任何进展


推荐阅读