Skip to content

Commit 73f2105

Browse files
authored
Merge pull request #224 from smacker/fix_values_as_search_result
Fix search results that has only values
2 parents 4ef0ebc + 61d9e8f commit 73f2105

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/components/UASTViewer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ export const getSearchResults = uast => {
1313
return null;
1414
}
1515

16-
if (Array.isArray(rootNode.n)) {
16+
// for search server returns [result, result, result]
17+
// in case when all the results are nodes we can ignore wrapper node
18+
// and display only results for better UI/UX.
19+
//
20+
// for values (strings, ints, bool) we have to keep the wrapping node
21+
// otherwise it's not a tree and uast-viewer wouldn't be able to display it
22+
if (Array.isArray(rootNode.n) && rootNode.n.every(c => c.id !== undefined)) {
1723
return rootNode.n.map(c => c.id);
1824
}
1925

0 commit comments

Comments
 (0)