Skip to content

Commit

Permalink
Merge pull request #224 from smacker/fix_values_as_search_result
Browse files Browse the repository at this point in the history
Fix search results that has only values
  • Loading branch information
smacker authored Aug 8, 2019
2 parents 4ef0ebc + 61d9e8f commit 73f2105
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/UASTViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ export const getSearchResults = uast => {
return null;
}

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

Expand Down

0 comments on commit 73f2105

Please sign in to comment.