Auto-indentation problem with promise blocks
See original GitHub issueFrom @lumaxis on August 12, 2016 0:7
- VSCode Version: 1.5.0-insider (666ed83a2d465257201cdac215a553ddee3cccbe)
- OS Version: 10.11.6
Steps to Reproduce:
- Create a Typescript file and start writing code using promises
- Auto-indent file using
Shift+Alt+DShift+Alt-F
Expected Result:
return output
.then((result: ControllerResponse) => {
return res
.status(result.statusCode)
.json(result.payload);
})
Actual Result:
return output
.then((result: ControllerResponse) => {
return res
.status(result.statusCode)
.json(result.payload);
})
Description:
The problem with the current way is that it leads to a strange indentation on the closing braces:
});
}
Here, the closing curly braces and parentheses for the .then()
block are indented 4 spaces instead of 2 spaces as they should be.
Copied from original issue: Microsoft/vscode#10453
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:13 (9 by maintainers)
Top Results From Across the Web
How to avoid indented nested promises? - Stack Overflow
You should not nest the .then() handlers but let each .then() create and return a new Promise . This is how it was...
Read more >auto formatting too aggressive for the common block case
When a C# file is open and you are adding to an existing file then trying to use a block like structure like...
Read more >Emacs auto-indenting comments in an unhelpful manner
Hitting enter after a semicolon commented line in any file type (.el and .lisp at the very least) indents the comment in a...
Read more >Programming patterns | ArcGIS Maps SDK for JavaScript 4.25
Learn more about the AMD module format with the Dojo Toolkit introduction to ... promise is resolved, and an error function that is...
Read more >Configuration - Editor.js
Format of the data object should be the same as returned by Editor ... If there is an error during initialization the isReady...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@SaschaNaz If that is the case it’s imo a very questionable decision that at least would need an option to be able to change it. The biggest problem with the current behavior, as mentioned in my original issue, is the inconsistent indentation of closing curly braces and parentheses:
any news on this? This is still happening in the last version!