When looking at outlines for try functions, allow for not finding a child to provide a span when requesting outlines (#36389)

This commit is contained in:
Orta
2020-01-27 15:59:49 -05:00
committed by GitHub
parent e1bce187a8
commit 3ece65a94c
3 changed files with 17 additions and 2 deletions
+2 -1
View File
@@ -182,7 +182,8 @@ namespace ts.OutliningElementsCollector {
return spanForNode(n.parent);
}
else if (tryStatement.finallyBlock === n) {
return spanForNode(findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile)!);
const node = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile);
if (node) return spanForNode(node);
}
// falls through
default:
@@ -0,0 +1,13 @@
/// <reference path="fourslash.ts"/>
// #33102
//// try[| {
//// var x = [
//// {% try[||] %}|][|{% except %}|]
//// ]
//// } catch (e)[| {
////
//// }|]
verify.outliningSpansInCurrentFile(test.ranges());
+2 -1
View File
@@ -433,6 +433,7 @@ declare namespace FourSlashInterface {
printNavigationBar(): void;
printNavigationItems(searchValue?: string): void;
printScriptLexicalStructureItems(): void;
printOutliningSpans(): void;
printReferences(): void;
printContext(): void;
}
@@ -775,4 +776,4 @@ declare namespace completion {
export const statementKeywordsWithTypes: ReadonlyArray<Entry>;
export const statementKeywords: ReadonlyArray<Entry>;
export const statementInJsKeywords: ReadonlyArray<Entry>;
}
}