Indentation of JavaScript code in JSP files

Hello all,

I have just started using Webstorm 6. I mainly write JavaScript and our application is using Java. However, I run into a problem with indentation of JavaScript code blocks within JSP's.

We have many JSP's that have calls to JavaScript modules like in this example below:
Selection_002.png

I noticed that when I write an object within another object in the above example, for instance like in the following screenshot, the indentation will go wrong.

Example of wrongly placed cursor and curly bracket:
Selection_003.png
But the following is expected:
Selection_006.png

This happens in a JSP file, but not in a regular JavaScript file.

Somehow it seems that this has something to do with Webstorm not properly detecting blocks of JavaScript in files other than .js files. I went over the settings a thousand times, checked the Code Style settings thouroughly, Google'd, etc., but couldn't find a solution.

This feels like a bug; I have also asked other developers here in the company to check if they could help. They are aware of this issue, but do not know about the solution. Therefore I turn to you.

Is there a way to resolve this, or is it a bug?

4 comments

Don't you have "do not indent children of: body" in your html code style? Maybe it is something similar to this: http://devnet.jetbrains.com/thread/443184?tstart=0
(just guessing)

The indentation works rather weird in phpstorm/webstorm... :-/

0

That option is enabled, but since the examples I am talking about don't contain a body tag, it is not affected/unrelated here.

As said, typing an object outside the existing objects you saw in my screenshot, will be properly indented.

So yes, I agree on the indentation not fully working as it should but as there are many options to try out I'd like to check that I'm not missing something here. :) Maybe I should file a ticket for this then...

0

I run up against this issue too. Indentation often seems annoyingly screwy.

0

Hi Chris,

Please see the following URL, I have created an issue about it. More people seem to have this problem.
Please upvote that issue if you think it is important. :)

WEB-7340 Indentation of JavaScript in JSP files is incorrect: http://youtrack.jetbrains.com/issue/WEB-7340

0

Please sign in to leave a comment.