From f9a4a9962cbbae5970047fa15146e40a6c6d1378 Mon Sep 17 00:00:00 2001 From: Sherfin Shamsudeen Date: Mon, 13 Jan 2025 18:33:29 +0530 Subject: [PATCH] Replace complex autosuggestions filtering function with simple one --- .../CodeEditor/autocompleteExtensionConfig.js | 32 +++---------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/frontend/src/AppBuilder/CodeEditor/autocompleteExtensionConfig.js b/frontend/src/AppBuilder/CodeEditor/autocompleteExtensionConfig.js index e1d597c957..e8df4290f0 100644 --- a/frontend/src/AppBuilder/CodeEditor/autocompleteExtensionConfig.js +++ b/frontend/src/AppBuilder/CodeEditor/autocompleteExtensionConfig.js @@ -156,35 +156,11 @@ export const generateHints = (hints, totalReferences = 1, input, searchText) => function filterHintsByDepth(input, hints) { if (input === '') return hints; - const inputDepth = input.includes('.') ? input.split('.').length : 0; + const inputParts = input.split('.'); - const filteredHints = hints.filter((cm) => { - const hintParts = cm.hint.split('.'); - - let shouldInclude = - (cm.hint.startsWith(input) && hintParts.length === inputDepth + 1) || - (cm.hint.startsWith(input) && hintParts.length === inputDepth); - - const shouldFuzzyMatch = !shouldInclude ? hintParts.length > inputDepth : false; - - if (shouldFuzzyMatch) { - // fuzzy match - let matchedDepth = -1; - for (let i = 0; i < hintParts.length; i++) { - if (hintParts[i].includes(input)) { - matchedDepth = i; - break; - } - } - - if (matchedDepth !== -1) { - shouldInclude = hintParts.length === matchedDepth + 1; - } - } else if (input.endsWith('.')) { - shouldInclude = cm.hint.startsWith(input) && hintParts.length === inputDepth; - } - - return shouldInclude; + const filteredHints = hints.filter((hint) => { + const hintParts = hint.hint.split('.'); + return hintParts.length <= inputParts.length + 1; }); return filteredHints;