fix: Ensure new Set node is on top of search list (#7215)

Github issue / Community forum post (link here to close automatically):
This commit is contained in:
Mutasem Aldmour
2023-09-20 16:47:51 +02:00
committed by GitHub
parent 8bb22292d5
commit 2491ccf4d9
3 changed files with 152 additions and 3 deletions

View File

@@ -64,7 +64,7 @@ export function searchNodes(searchFilter: string, items: INodeCreateElement[]) {
const trimmedFilter = searchFilter.toLowerCase().replace('trigger', '').trimEnd();
const result = (
sublimeSearch<INodeCreateElement>(trimmedFilter, items, [
{ key: 'properties.displayName', weight: 2 },
{ key: 'properties.displayName', weight: 1.3 },
{ key: 'properties.codex.alias', weight: 1 },
]) || []
).map(({ item }) => item);

View File

@@ -4,12 +4,12 @@
// based on https://github.com/forrestthewoods/lib_fts/blob/master/code/fts_fuzzy_match.js
const SEQUENTIAL_BONUS = 30; // bonus for adjacent matches
const SEQUENTIAL_BONUS = 60; // bonus for adjacent matches
const SEPARATOR_BONUS = 30; // bonus if match occurs after a separator
const CAMEL_BONUS = 30; // bonus if match is uppercase and prev is lower
const FIRST_LETTER_BONUS = 15; // bonus if the first letter is matched
const LEADING_LETTER_PENALTY = -15; // penalty applied for every letter in str before the first match
const LEADING_LETTER_PENALTY = -20; // penalty applied for every letter in str before the first match
const MAX_LEADING_LETTER_PENALTY = -200; // maximum penalty for leading letters
const UNMATCHED_LETTER_PENALTY = -5;