feat(editor): Make expression autocomplete search case-insensitive (#10017)

This commit is contained in:
Elias Meire 2024-07-11 17:30:07 +02:00 committed by GitHub
parent 8171d75f5d
commit cde6fe90e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 2 deletions

View file

@ -217,6 +217,14 @@ describe('Resolution-based completions', () => {
Object.keys(object).length + extensions({ typeName: 'object' }).length, 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', () => { describe('indexed access completions', () => {

View file

@ -98,7 +98,7 @@ export function datatypeCompletions(context: CompletionContext): CompletionResul
} }
if (tail !== '') { 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; let from = word.to - tail.length;

View file

@ -59,7 +59,7 @@ export function longestCommonPrefix(...strings: string[]) {
} }
export const prefixMatch = (first: string, second: 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) => { export const isPseudoParam = (candidate: string) => {
const PSEUDO_PARAMS = ['notice']; // user input disallowed const PSEUDO_PARAMS = ['notice']; // user input disallowed