mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
feat(editor): Make expression autocomplete search case-insensitive (#10017)
This commit is contained in:
parent
8171d75f5d
commit
cde6fe90e5
|
@ -217,6 +217,14 @@ describe('Resolution-based completions', () => {
|
|||
Object.keys(object).length + extensions({ typeName: 'object' }).length,
|
||||
);
|
||||
});
|
||||
|
||||
test('should return case-insensitive completions', () => {
|
||||
vi.spyOn(workflowHelpers, 'resolveParameter').mockReturnValueOnce('abc');
|
||||
|
||||
const result = completions('{{ "abc".tolowerca| }}');
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result?.at(0)).toEqual(expect.objectContaining({ label: 'toLowerCase()' }));
|
||||
});
|
||||
});
|
||||
|
||||
describe('indexed access completions', () => {
|
||||
|
|
|
@ -98,7 +98,7 @@ export function datatypeCompletions(context: CompletionContext): CompletionResul
|
|||
}
|
||||
|
||||
if (tail !== '') {
|
||||
options = options.filter((o) => prefixMatch(o.label, tail) && o.label !== tail);
|
||||
options = options.filter((o) => prefixMatch(o.label, tail));
|
||||
}
|
||||
|
||||
let from = word.to - tail.length;
|
||||
|
|
|
@ -59,7 +59,7 @@ export function longestCommonPrefix(...strings: string[]) {
|
|||
}
|
||||
|
||||
export const prefixMatch = (first: string, second: string) =>
|
||||
first.startsWith(second) && first !== second;
|
||||
first.toLocaleLowerCase().startsWith(second.toLocaleLowerCase()) && first !== second;
|
||||
|
||||
export const isPseudoParam = (candidate: string) => {
|
||||
const PSEUDO_PARAMS = ['notice']; // user input disallowed
|
||||
|
|
Loading…
Reference in a new issue