1
votes

Let's assume I have a JavaScript file with the following content and the cursor placed at the pipe symbol (|):

class ItemCtrl {
    getPropertiesByItemId(id) {
        return this.fetchItem(id)
            .then(item => {
                return this.getPropertiesOfItem(item);
            });
    }|
}

If I now hit enter, the code changes in the following way:

class ItemCtrl {
    getPropertiesByItemId(id) {
        return this.fetchItem(id)
            .then(item => {
                return this.getPropertiesOfItem(item);
            });
        }
        |
}

It wrongly aligns the closing curly brace with the return statement, when it should be aligned with the method definition. I know that the formatting inside the function is not the best but I still would rather disable that feature to prevent weird things like that from happening.

I already set editor.autoIndent to false but it still keeps happening. Is there any other way, how I can turn this feature off entirely? (or make it work in a smarter way)

1
Do you have eslint extension by any chance? Or another that is doing it? - Mark
I disabled all Extensions. But I actually realised that autoIndent seems to be disabled if I set editor.autoIndent to true. Seems like a bug to me or my installation is messed up. - basilikum

1 Answers

5
votes

In VS Code 1.17, this bug caused "editor.autoIndent": false to not work

This should be fixed in VS Code 1.18