| Summary: | [formatting] Wrong indentation if new line is inserted before opening a curly bracket | ||
|---|---|---|---|
| Product: | [WebTools] JSDT | Reporter: | Mauro Molinari <mauromol> |
| Component: | General | Assignee: | Project Inbox <jsdt.javascript-inbox> |
| Status: | NEW --- | QA Contact: | Chris Jaun <cmjaun> |
| Severity: | normal | ||
| Priority: | P3 | CC: | cmjaun, wdtracy |
| Version: | 3.2.2 | ||
| Target Milestone: | Future | ||
| Hardware: | PC | ||
| OS: | Windows Vista | ||
| Whiteboard: | |||
This also occurs when entering a new line after for, if, else, do, etc. except that in those cases, both of the braces are indented:
STEPS TO REPRO
1. create a js file
2. type:
if(expression)
3. go to next line and add a "{"
4. go to next line
EXPECTED BEHAVIOUR
The JavaScript editor removes the indentation and adds the closing bracket for me, putting it indented like the opening one:
if(expression)
{
|
}
The Java Editor behaves in this way.
OBSERVED BEHAVIOUR
The JavaScript editor keeps the indent and adds the closing bracket for me, but it's indented the wrong way:
if(expression)
{
|
}
So this is the most annoying bug in the entire universe, so I've spent the past several hours trying to fix it.
I've narrowed down the problem code.
Class: org.eclipse.wst.jsdt.internal.ui.text.java.JavaAutoIndentStrategy
Method: public void customizeDocumentCommand(IDocument d, DocumentCommand c)
This method is called whenever you type characters. It then formats the document correctly.
In JDT for example, when you type the '{' character, this method is called and then the { is de-indented correctly.
In JSDT however, this method is never called when you type the '{' character.
I've spent a while trying to figure out WHY this method isn't getting called, and have not yet come up with a reason.
|
STEPS TO REPRO 1. create a js file 2. type: function test() 3. go to next line and add a "{" 4. go to next line EXPECTED BEHAVIOUR The JavaScript editor adds the closing bracket for me, putting it indented like the opening one: function test() { | } The Java Editor behaves in this way. OBSERVED BEHAVIOUR The JavaScript editor adds the closing bracket for me, but it's indented the wrong way: function test() { |}