Why does unexpected intent prompt when compiling coffeescript

Hello everybody:
     I'm using webstorm7.0.1 and find sometimes IDE prompts coffeescript file  'unexpected indent'. I think my code is correct, even if commenting the code lines IDE still prompts and not compile it like the following screenshot.

Best Regards.



not sure I follow you... Do you get this errors when compiling your code, or they come from WebStorm inspections? Can you compile your files outside of WebStorm?
Also, can you attach a file that shows up the problem?


     I seem to have known the reason. The spaces and Tab are different although they appear the same! For example, two spaces and one tab appear same in my webstorm, but if there are two lines code, one is indented by two spaces, the other by one Tab, "unexpected error" will prompt and can't be compiled. It has something to do with the IDE config, i.e.

Settings - Code Style - Coffeescript - Tabs and Indents - Use Tab Characters, it can't be checked. Maybe I checked it several days ago for better experience... But the problem is why it works. I find the official doc http://www.jetbrains.com/webstorm/webhelp/code-style-coffeescript.html  I don't know why "Tab Size" is under 'Use Tab Characters' option's influence. If I checked the latter, the former would go wrong i.e. if it would not be equivalent to 4 spaces even if set 4.

Is it a bug?
Best Regards


Sorry, I understood nothing in your report.

>I don't know why "Tab Size" is under 'Use  Tab Characters' option's influence. If I checked the latter, the former  would go wrong i.e. if it would not be equivalent to 4 spaces even if  set 4.

It would be a tab, not 4 spaces - as expected:) Tab Size just defines a tab 'width' in this case. BTW, you can turn 'Show whitespaces' on in Settings/Editor/Appearance to be able to see if tabs or spaces are used in your code


     as you said, if a tab is set 4 spaces, why is it not equivalent to 4 times space key pressed. I press 4 times, but the coffee file can't be compiled.


It's a problem of coffeescript compiler - it treats Tab character as a single space. So you need to make sure not to mix tabs with spaces when formatting


ok, I found it in Wikipedia :

  • CoffeeScript is very sensitive to whitespace, counting a tab as a single space.

so if Use Tab Characters checked, it would conflict with coffeescript compiler. the code appearance is not fit for the essential ...
so I have to uncheck 'Use Tab Characters', but I think webstorm should forbid checking the option in coffeescript code style panel.

best regards.


Please sign in to leave a comment.