Skip to content

Commit

Permalink
remove empty match results
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemitchel committed Dec 2, 2024
1 parent 3f5a685 commit 3f1a227
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/variables/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const VariableEditorVM = DefineMap.extend('VariableEditorVM', {
const useExplicitSearch = this.useExplicitSearch

const results = findVarUsage(varName, pages, useExplicitSearch)
console.log('results', results)

return results
}
})
Expand Down
11 changes: 8 additions & 3 deletions src/variables/editor/util/findVarUsage.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,22 @@ const getMatches = (page, regEx) => { // pages or fields or buttons
}
}

return foundMatches
if (foundMatches.page.length || foundMatches.fields.length || foundMatches.buttons.length) {
return foundMatches
}
}

export const findVarUsage = (varName, pages, useExplicitSearch) => {
const regEx = getRegEx(varName, useExplicitSearch)
const matches = new DefineMap({})

for (const page of pages) {
matches[page.name] = getMatches(page, regEx)
const foundMatches = getMatches(page, regEx)

if (foundMatches) {
matches[page.name] = foundMatches
}
}

console.log('final matches', matches)
return matches
}

0 comments on commit 3f1a227

Please sign in to comment.