diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts
index 26a5f098967..167ca62982e 100644
--- a/src/services/navigationBar.ts
+++ b/src/services/navigationBar.ts
@@ -84,6 +84,7 @@ import {
isStatic,
isStringLiteralLike,
isStringOrNumericLiteralLike,
+ isTemplateLiteral,
isToken,
isVariableDeclaration,
lastOrUndefined,
@@ -1057,7 +1058,7 @@ function getFunctionOrClassName(node: FunctionExpression | FunctionDeclaration |
return `${name} callback`;
}
- const args = cleanText(mapDefined(parent.arguments, a => isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined).join(", "));
+ const args = cleanText(mapDefined(parent.arguments, a => isStringLiteralLike(a) || isTemplateLiteral(a) ? a.getText(curSourceFile) : undefined).join(", "));
return `${name}(${args}) callback`;
}
}
diff --git a/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts b/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts
index d35d051eda6..16ad964e5dc 100644
--- a/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts
+++ b/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts
@@ -18,7 +18,7 @@
//// // These will only show up as childItems.
//// function z() {}
//// console.log(function() {})
-//// describe("this", 'function', `is a function`, `but this ${"wont"} show`, () => {});
+//// describe("this", 'function', `is a function`, `with template literal ${"a"}`, () => {});
//// [].map(() => {});
////})
////(function classes() {
@@ -77,11 +77,11 @@ verify.navigationTree({
"kind": "function"
},
{
- "text": `describe("this", 'function', \`is a function\`) callback`,
+ "text": "describe(\"this\", 'function', `is a function`, `with template literal ${\"a\"}`) callback",
"kind": "function"
},
{
- "text": `map() callback`,
+ "text": "map() callback",
"kind": "function"
},
{
@@ -199,11 +199,11 @@ verify.navigationBar([
"kind": "function"
},
{
- "text": `describe("this", 'function', \`is a function\`) callback`,
+ "text": "describe(\"this\", 'function', `is a function`, `with template literal ${\"a\"}`) callback",
"kind": "function"
},
{
- "text": `map() callback`,
+ "text": "map() callback",
"kind": "function"
},
{
diff --git a/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions3.ts b/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions3.ts
new file mode 100644
index 00000000000..2b2881e8ac6
--- /dev/null
+++ b/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions3.ts
@@ -0,0 +1,93 @@
+///
+
+////describe('foo', () => {
+//// test(`a ${1} b ${2}`, () => {})
+////})
+////
+////const a = 1;
+////const b = 2;
+////describe('foo', () => {
+//// test(`a ${a} b {b}`, () => {})
+////})
+
+verify.navigationTree({
+ "text": "",
+ "kind": "script",
+ "childItems": [
+ {
+ "text": "a",
+ "kind": "const"
+ },
+ {
+ "text": "b",
+ "kind": "const"
+ },
+ {
+ "text": "describe('foo') callback",
+ "kind": "function",
+ "childItems": [
+ {
+ "text": "test(`a ${1} b ${2}`) callback",
+ "kind": "function"
+ }
+ ]
+ },
+ {
+ "text": "describe('foo') callback",
+ "kind": "function",
+ "childItems": [
+ {
+ "text": "test(`a ${a} b {b}`) callback",
+ "kind": "function"
+ }
+ ]
+ }
+ ]
+});
+
+verify.navigationBar([
+ {
+ "text": "",
+ "kind": "script",
+ "childItems": [
+ {
+ "text": "a",
+ "kind": "const"
+ },
+ {
+ "text": "b",
+ "kind": "const"
+ },
+ {
+ "text": "describe('foo') callback",
+ "kind": "function"
+ },
+ {
+ "text": "describe('foo') callback",
+ "kind": "function"
+ }
+ ]
+ },
+ {
+ "text": "describe('foo') callback",
+ "kind": "function",
+ "childItems": [
+ {
+ "text": "test(`a ${1} b ${2}`) callback",
+ "kind": "function"
+ }
+ ],
+ "indent": 1
+ },
+ {
+ "text": "describe('foo') callback",
+ "kind": "function",
+ "childItems": [
+ {
+ "text": "test(`a ${a} b {b}`) callback",
+ "kind": "function"
+ }
+ ],
+ "indent": 1
+ }
+]);