diff --git a/packages/editor-ui/src/utils/sortUtils.ts b/packages/editor-ui/src/utils/sortUtils.ts index d0521bdf72..77ff66016c 100644 --- a/packages/editor-ui/src/utils/sortUtils.ts +++ b/packages/editor-ui/src/utils/sortUtils.ts @@ -236,7 +236,14 @@ export function sublimeSearch( keys.forEach(({ key, weight }) => { const value = getValue(item, key); if (Array.isArray(value)) { - values = values.concat(value.map((v) => ({ value: v, weight }))); + // Reduce the weight by 10% for subsequent value in the array so we promote results based on the order of values + // e.g. if node has multiple aliases, we want to promote the first alias over the second + values = values.concat( + value.map((v, i) => ({ + value: v, + weight: i <= 1 ? weight : weight * (1 - (i - 1) * 0.1), + })), + ); } else if (typeof value === 'string') { values.push({ value, diff --git a/packages/nodes-base/nodes/Code/Code.node.json b/packages/nodes-base/nodes/Code/Code.node.json index 57dcb6bc2a..0585d6e3b1 100644 --- a/packages/nodes-base/nodes/Code/Code.node.json +++ b/packages/nodes-base/nodes/Code/Code.node.json @@ -11,7 +11,7 @@ } ] }, - "alias": ["cpde", "Javascript", "JS", "Python", "Script", "Custom Code", "Function"], + "alias": ["cpde", "Function", "Javascript", "JS", "Python", "Script", "Custom Code"], "subcategories": { "Core Nodes": ["Helpers", "Data Transformation"] }