fix(editor): Fix quote handling on dollar-sign variable completions (#6128)

🐛 Fix quote handling on dollar-sign variable completions
This commit is contained in:
Iván Ovejero 2023-05-02 09:36:42 +02:00 committed by GitHub
parent 85e8145439
commit 51f5990559
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -276,6 +276,14 @@ describe('Resolution-based completions', () => {
);
});
test('should return completions for: {{ "hello"+input.| }}', () => {
resolveParameterSpy.mockReturnValue($input);
expect(completions('{{ "hello"+$input.| }}')).toHaveLength(
Reflect.ownKeys($input).length + natives('object').length,
);
});
test("should return completions for: {{ $('nodeName').| }}", () => {
resolveParameterSpy.mockReturnValue($('Rename'));

View file

@ -440,11 +440,12 @@ export const objectGlobalOptions = () => {
};
const regexes = {
generalRef: /\$[^$]+\.([^{\s])*/, // $input. or $json. or similar ones
generalRef: /\$[^$'"]+\.([^{\s])*/, // $input. or $json. or similar ones
selectorRef: /\$\(['"][\S\s]+['"]\)\.([^{\s])*/, // $('nodeName').
numberLiteral: /\((\d+)\.?(\d*)\)\.([^{\s])*/, // (123). or (123.4).
stringLiteral: /(".+"|('.+'))\.([^{\s])*/, // 'abc'. or "abc".
singleQuoteStringLiteral: /('.+')\.([^'{\s])*/, // 'abc'.
doubleQuoteStringLiteral: /(".+")\.([^"{\s])*/, // "abc".
dateLiteral: /\(?new Date\(\(?.*?\)\)?\.([^{\s])*/, // new Date(). or (new Date()).
arrayLiteral: /(\[.+\])\.([^{\s])*/, // [1, 2, 3].
objectLiteral: /\(\{.*\}\)\.([^{\s])*/, // ({}).