question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto-indentation problem with promise blocks

See original GitHub issue

From @lumaxis on August 12, 2016 0:7

  • VSCode Version: 1.5.0-insider (666ed83a2d465257201cdac215a553ddee3cccbe)
  • OS Version: 10.11.6

Steps to Reproduce:

  1. Create a Typescript file and start writing code using promises
  2. Auto-indent file using Shift+Alt+D Shift+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:open
  • Created 7 years ago
  • Reactions:7
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

9reactions
lumaxiscommented, Sep 5, 2016

@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:

          });
      });
    });
});
4reactions
ksairicommented, Dec 11, 2018

any news on this? This is still happening in the last version!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found