New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Too much indentation in method body selected by range if first line is comment or incompletely selected #4926
Comments
I’m starting to wonder if we should change range formatting to format the whole file, but with two “cursors,” then replace what’s in the range with the text between the cursors. |
Sounds sensible to me. In my project we just ended up running prettier on everything so that we could use whole file prettier. |
This makes range formatting unusable. Prettier randomly indents half of codebase |
btw. to make it worse range formatting is very slow because of API prettier is exposing (you can provide just one range, so if you need to format n ranges you need to call format n times) |
@sheerun Kind of related: #5807 (comment) |
Here's another even simpler example: test.js
command:
|
See one more manifestation of this bug in #7082. |
Prettier 1.14.0
Playground link
Can reproduce with just range 100 - 101 (the newline character after the brace on line 4), so that seems to be the culprit.
If I replace line 4 with an expression (e.g. let x) then the method is formatted correctly more often so long as my selection covers the second character of the expression, but you can break it again by moving the start of the selection over the brace on line 3.
Input:
Output:
Expected behavior:
Don't indent so much. Don't be so sensitive to range choice.
Ref: nrwl/precise-commits#15
The text was updated successfully, but these errors were encountered: