Skip to content

Commit 3ece65a

Browse files
author
Orta
authored
When looking at outlines for try functions, allow for not finding a child to provide a span when requesting outlines (microsoft#36389)
1 parent e1bce18 commit 3ece65a

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/services/outliningElementsCollector.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ namespace ts.OutliningElementsCollector {
182182
return spanForNode(n.parent);
183183
}
184184
else if (tryStatement.finallyBlock === n) {
185-
return spanForNode(findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile)!);
185+
const node = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile);
186+
if (node) return spanForNode(node);
186187
}
187188
// falls through
188189
default:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
// #33102
4+
5+
//// try[| {
6+
//// var x = [
7+
//// {% try[||] %}|][|{% except %}|]
8+
//// ]
9+
//// } catch (e)[| {
10+
////
11+
//// }|]
12+
13+
verify.outliningSpansInCurrentFile(test.ranges());

tests/cases/fourslash/fourslash.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ declare namespace FourSlashInterface {
433433
printNavigationBar(): void;
434434
printNavigationItems(searchValue?: string): void;
435435
printScriptLexicalStructureItems(): void;
436+
printOutliningSpans(): void;
436437
printReferences(): void;
437438
printContext(): void;
438439
}
@@ -775,4 +776,4 @@ declare namespace completion {
775776
export const statementKeywordsWithTypes: ReadonlyArray<Entry>;
776777
export const statementKeywords: ReadonlyArray<Entry>;
777778
export const statementInJsKeywords: ReadonlyArray<Entry>;
778-
}
779+
}

0 commit comments

Comments
 (0)