Skip to content

Commit

Permalink
fix(editor): Fix quote handling on dollar-sign variable completions (#…
Browse files Browse the repository at this point in the history
…6128)

🐛 Fix quote handling on dollar-sign variable completions
  • Loading branch information
ivov authored May 2, 2023
1 parent 85e8145 commit 51f5990
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])*/, // ({}).
Expand Down

0 comments on commit 51f5990

Please sign in to comment.