Skip to content

Commit 5f16a48

Browse files
author
Andy
authored
Merge pull request #10590 from Microsoft/navbar_fn_in_var
Treat variable declaration as top-level if it has an important child.
2 parents db62503 + 5e4465a commit 5f16a48

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

src/services/navigationBar.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ namespace ts.NavigationBar {
466466
case SyntaxKind.MethodDeclaration:
467467
case SyntaxKind.GetAccessor:
468468
case SyntaxKind.SetAccessor:
469+
case SyntaxKind.VariableDeclaration:
469470
return hasSomeImportantChild(item);
470471

471472
case SyntaxKind.ArrowFunction:

tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ verify.navigationBar([
9090
],
9191
"indent": 2
9292
},
93+
{
94+
"text": "y",
95+
"kind": "const",
96+
"childItems": [
97+
{
98+
"text": "foo",
99+
"kind": "function"
100+
}
101+
],
102+
"indent": 2
103+
},
93104
{
94105
"text": "<function>",
95106
"kind": "function",
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
////var a = {
4+
//// propA: function() {}
5+
////};
6+
////var b;
7+
////b = {
8+
//// propB: function() {}
9+
////};
10+
11+
verify.navigationBar([
12+
{
13+
"text": "<global>",
14+
"kind": "script",
15+
"childItems": [
16+
{
17+
"text": "a",
18+
"kind": "var"
19+
},
20+
{
21+
"text": "b",
22+
"kind": "var"
23+
},
24+
{
25+
"text": "propB",
26+
"kind": "function"
27+
}
28+
]
29+
},
30+
{
31+
"text": "a",
32+
"kind": "var",
33+
"childItems": [
34+
{
35+
"text": "propA",
36+
"kind": "function"
37+
}
38+
],
39+
"indent": 1
40+
},
41+
{
42+
"text": "propB",
43+
"kind": "function",
44+
"indent": 1
45+
}
46+
]);

0 commit comments

Comments
 (0)