fix(60887): Incorrect Formatting on if (a) try {} finally {} #60898
fix(60887): Incorrect Formatting on if (a) try {} finally {} #60898jakebailey merged 4 commits intomicrosoft:mainfrom
Conversation
| break; | ||
| case SyntaxKind.TryStatement: | ||
| const tryStatement = parent as TryStatement; | ||
| if (tryStatement.finallyBlock && tryStatement.finallyBlock === child) { |
There was a problem hiding this comment.
I'm suspicious about this just because all of the other code in this switch case are only checking syntax kind or position info, not node equality.
There was a problem hiding this comment.
@jakebailey thanks for the feedback. I found that in this case, the finallyBlock should not be handled as a child of the try block to ensure the correct delta calculation
There are other places where we handle the finallyBlock in a similar way
TypeScript/src/services/outliningElementsCollector.ts
Lines 259 to 261 in 5170645
I hope that makes sense., if you have any thoughts or suggestions, I’d be grateful to hear them. thanks
There was a problem hiding this comment.
How does this bug not affect the try block or the catch block, then? Maybe I'm missing something...
There was a problem hiding this comment.
I've modified changes to rely exclusively on checking the syntax kind
|
@typescript-bot pack this |
|
Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running There is also a playground for this build and an npm module you can use via |
|
@typescript-bot pack this |
|
Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running There is also a playground for this build and an npm module you can use via |
Fixes #60887