From f5733ea2d7268b4316c5209e8d8ff4f5b47b6d00 Mon Sep 17 00:00:00 2001 From: "SPRINX0\\prochazka" Date: Tue, 17 Dec 2024 10:16:19 +0100 Subject: [PATCH] handle camelCase in tokenizer --- packages/tools/src/filterName.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/tools/src/filterName.ts b/packages/tools/src/filterName.ts index c18fcdfd5..a0be15a1d 100644 --- a/packages/tools/src/filterName.ts +++ b/packages/tools/src/filterName.ts @@ -90,11 +90,16 @@ export function tokenizeBySearchFilter(text: string, filter: string): { text: st for (const item of res) { const indexes = []; for (const char of token) { - const index = item.text.indexOf(char, indexes.length > 0 ? indexes[indexes.length - 1] + 1 : 0); - if (index < 0) { - indexes.push(-1); + if (indexes.length == 0 && char == item.text[0]?.toUpperCase()) { + // handle first letter of camelcase + indexes.push(0); } else { - indexes.push(index); + const index = item.text.indexOf(char, indexes.length > 0 ? indexes[indexes.length - 1] + 1 : 0); + if (index < 0) { + indexes.push(-1); + } else { + indexes.push(index); + } } } if (indexes.some(x => x < 0)) {