Skip to content

Commit 208e36d

Browse files
Cover all top-level items in 'getIndent'.
1 parent 1814261 commit 208e36d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/services/navigationBar.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,20 @@ module ts.NavigationBar {
1616

1717
var current = node.parent;
1818
while (current) {
19-
if (current.kind === SyntaxKind.ModuleDeclaration || current.kind === SyntaxKind.FunctionDeclaration) {
20-
indent++;
19+
switch (current.kind) {
20+
case SyntaxKind.ModuleDeclaration:
21+
// If we have a module declared as A.B.C, it is more "intuitive"
22+
// to say it only has a single layer of depth
23+
do {
24+
current = current.parent;
25+
} while (current.kind === SyntaxKind.ModuleDeclaration);
26+
27+
// fall through
28+
case SyntaxKind.ClassDeclaration:
29+
case SyntaxKind.EnumDeclaration:
30+
case SyntaxKind.InterfaceDeclaration:
31+
case SyntaxKind.FunctionDeclaration:
32+
indent++;
2133
}
2234

2335
current = current.parent;
@@ -207,7 +219,7 @@ module ts.NavigationBar {
207219
}
208220
}
209221

210-
function getNavigationBarItem(text: string, kind: string, kindModifiers: string, spans: TypeScript.TextSpan[], childItems: ts.NavigationBarItem[]= [], indent: number = 0): ts.NavigationBarItem {
222+
function getNavigationBarItem(text: string, kind: string, kindModifiers: string, spans: TypeScript.TextSpan[], childItems: ts.NavigationBarItem[] = [], indent: number = 0): ts.NavigationBarItem {
211223
return {
212224
text: text,
213225
kind: kind,

0 commit comments

Comments
 (0)