diff --git a/x-pack/plugins/code/public/components/symbol_tree/__test__/__snapshots__/symbol_tree.test.tsx.snap b/x-pack/plugins/code/public/components/symbol_tree/__test__/__snapshots__/symbol_tree.test.tsx.snap index bb5e0986ed18d..f2b7685db3ec0 100644 --- a/x-pack/plugins/code/public/components/symbol_tree/__test__/__snapshots__/symbol_tree.test.tsx.snap +++ b/x-pack/plugins/code/public/components/symbol_tree/__test__/__snapshots__/symbol_tree.test.tsx.snap @@ -471,6 +471,106 @@ exports[`render symbol tree correctly 1`] = ` +
+
+
+
+ +
+
+ + + +
+
+ Unit +
+
+
+
+
+
+
+
+
+
+
+ +
+
+ + + +
+
+ datemath +
+
+
+
+
+
+
diff --git a/x-pack/plugins/code/public/components/symbol_tree/__test__/props.ts b/x-pack/plugins/code/public/components/symbol_tree/__test__/props.ts index 5ab617e9b658c..523a4708b0ac7 100644 --- a/x-pack/plugins/code/public/components/symbol_tree/__test__/props.ts +++ b/x-pack/plugins/code/public/components/symbol_tree/__test__/props.ts @@ -112,6 +112,26 @@ export const props: { structureTree: SymbolWithMembers[] } = { }, ], }, + { + name: 'Unit', + kind: SymbolKind.Variable, + location: { + uri: + 'git://github.com/elastic/kibana/blob/master/packages/elastic-datemath/src/index.d.ts', + range: { start: { line: 20, character: 0 }, end: { line: 20, character: 66 } }, + }, + path: 'Unit', + }, + { + name: 'datemath', + kind: SymbolKind.Constant, + location: { + uri: + 'git://github.com/elastic/kibana/blob/master/packages/elastic-datemath/src/index.d.ts', + range: { start: { line: 22, character: 14 }, end: { line: 47, character: 1 } }, + }, + path: 'datemath', + }, ], }, ], diff --git a/x-pack/plugins/code/public/reducers/symbol.ts b/x-pack/plugins/code/public/reducers/symbol.ts index b02a03a2486ac..177d80d0db134 100644 --- a/x-pack/plugins/code/public/reducers/symbol.ts +++ b/x-pack/plugins/code/public/reducers/symbol.ts @@ -58,8 +58,11 @@ const generateStructureTree: (symbols: SymbolInformation[]) => any = symbols => function findContainer( tree: SymbolWithMembers[], - containerName: string + containerName?: string ): SymbolInformation | undefined { + if (containerName === undefined) { + return undefined; + } const regex = new RegExp(`^${containerName}[<(]?.*[>)]?$`); const result = tree.find((s: SymbolInformation) => { return regex.test(s.name); @@ -93,7 +96,7 @@ const generateStructureTree: (symbols: SymbolInformation[]) => any = symbols => (sy: SymbolInformation) => sy.name === SPECIAL_SYMBOL_NAME ); } else { - container = findContainer(structureTree, s.containerName || ''); + container = findContainer(structureTree, s.containerName); } if (container) { if (!container.path) {