Problem with indent

I cannot figure out why this indentation is occurring in my code:

'should return an array of users from the group', function() {
  var result = jsom.getGroupUsers(2);
  result
  
.then(function(data) {
    expect(data.length).toBe(2);
    expect(data[0].displayName).toBe('Brian');
      // why is this indented?
  
});
  // this does not indent
});

It is not a continuation line as the line before is ended.  This code is inside of a function. 
It only seems to happen inside the then or catch blocks.


I am using IntelliJ 14.1.4 Ultimate.

5 comments
Comment actions Permalink

Can't recreate using default javascript code style settings. Can you export your settings (File/Export settings) and attach them to the thread?

0
Comment actions Permalink

Here you go.



Attachment(s):
settings.jar
0
Comment actions Permalink

Tried both styles defined by you  - 'Mine' and 'Standard'.. Can't see any additional indents. See the screenshot - it shows that cursor position on Enter

indent.png

do you get this wrong indentation on running Code/Reformat Code, or just on pressing Enter?

0
Comment actions Permalink

I see what is happening.  I did not have my .then indented, but IntelliJ seems to assume it to be so anyway:

result
.then(function() {
  var i = 1;
    // indent happens because it seems to expect .then to be indented - var i is also indented but I manually corrected
})


result
  .then(function() {
    var i = 1;
    // no indent on return because the
  })


I actually use the 2nd format, which is what you tried out; forgetting to indent was a mistake.  However, I don't like that if I choose NOT to indent, it assumes that I actually did.

0
Comment actions Permalink

I did not have my .then indented, but IntelliJ seems to assume it to be so anyway

so, you have your code formatted manually, so that the indentation  differs from the one you get when you run Code/Reformat Code, right? And  you'd like 'Smart indent' to create indent according to your existing  manual formatting instead of following code style settings? This can't  work. 'Smart indent' doesn't care about your manual indentation, created  indents are based on code style settings. You can turn it off - the  next line will always be indented to the same level as previous in this  case

0

Please sign in to leave a comment.