Inconsistent indentation problems in Javascript and PHP

Hi,

I'm wondering what settings I'm missing, or if these are bugs:

Best demonstrated through some examples:

Javascript - various constructs
// problems with variable declarations and function call params
var a // enter
,b // enter
,c // press enter with cursor right before the comma

          ,c // ends up here (2 tabs), enter again
// back to the front
;


// problems with the switch statement
switch (1) {
     case 1: // press enter with the cursor at the end of this line (with or without a comment)
     // cursor is placed here incorrectly
     var a=1; // press enter with cursor right before var a...

          var a=1; // you get here (1 tab), but pressing enter with the cursor at the end of this line
     // you end up here again
     
     // another problem below          
          // starting at the correct indentation by pressing tab
          var b=2;  // step 1
               // step 3: you end up here
               var d=4;
               
          var c=3; // step 2: type a line of code, then go back to right after b=2; and press enter
}

There are problems with jQuery style code as well

$('robin') // press enter with cursor after ) parenthesis
// will end up here
.appendTo('batman') // enter
// end up here
.animate({},'fast') // press enter with cursor at the beginning of the line
          .animate({},'fast') // it ends up here (2 tabs), press enter
// ends up here

;

There is also a problem with PHP switch statement indentation
switch (4) {
     case 1:
          $a=1;
          $b=2;
               // ends up here
               $d=4;

          $c=3; // now go back to after $b=2 and press enter
}

Thanks for developing an otherwise wonderful editor!

0
3 comments

Leo,
speaking of your first example: if you press enter the indentation is calculated according to formatting rules which state that any variable under "var" statement must be indented. If you reformat the whole statement you will get the following:
var a
     ,b
    ,c;

and this is considered to be correct.
The other cases seem to be just bugs. Feel free to report them to http://youtrack.jetbrains.net.
For PHP switch statement I could reproduce the following:
switch (4) {
    case 1:
        $a = 1;<caret>
        $b = 2;           
}
Pressing Enter gives the wrong indentation.

0
Avatar
Permanently deleted user

was this like this pre the 2.1.4 release? ive noticed regression with indentations / reformat code in this release.

0

I managed to reproduce the problems described in the original post with 2.1.2. From that point of view 2.1.4 didn't bring any regression. But please let me know if you have other cases in mind.

0

Please sign in to leave a comment.