1

I have this line in my coffeescript file

if someVariable then no else yes

One of the most valuable feature in IDEA for me is code clean up. But it doesn't work as I expect here. After pressing Ctrl+Alt+L, IDEA reformats this line to ugly

if someVariable then {
    no
        } else yes

Which is not just bad style but error when compile from coffeescript to javascript.

Here is similar line which couldn't be formatted properly by IDEA.

return true if someVariable is 5

...becomes...

{
        return true
        } if someVariable is 5

Why is that?

4

2 回答 2

3

这是由if()语句引起的错误,Force braces: Always setting in JavaScript Wrapping and Braces

问题提交给 YouTrack

于 2013-05-06T16:33:50.563 回答
1

这看起来像 JavaScript 代码风格。尝试检查文件>设置>项目设置>代码样式下的设置。

如果您无法将代码样式设置为正确的形式,那么您仍然可以选择自己自定义它。

最后看看@http ://www.jetbrains.com/webstorm/webhelp/coffeescript-support.html,如果你还没有准备好,你可能会发现一些有趣的东西。祝你好运!

于 2013-05-06T06:39:45.217 回答