From 07b941a043f8aac761af63fd5327f45cbff7d275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Tue, 31 Jan 2023 15:19:43 +0100 Subject: [PATCH] fix(editor): Fix `json` field completions while typing (#5309) :bug: Fix `json` field completions while typing --- .../completions/jsonField.completions.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/editor-ui/src/components/CodeNodeEditor/completions/jsonField.completions.ts b/packages/editor-ui/src/components/CodeNodeEditor/completions/jsonField.completions.ts index a6e636ed31f4f..416950a80f595 100644 --- a/packages/editor-ui/src/components/CodeNodeEditor/completions/jsonField.completions.ts +++ b/packages/editor-ui/src/components/CodeNodeEditor/completions/jsonField.completions.ts @@ -234,7 +234,10 @@ export const jsonFieldCompletions = (Vue as CodeNodeEditorMixin).extend({ jsonOutput: IDataObject, matcher: string, // e.g. `$input.first().json` or `x` (user-defined variable) ) { - if (preCursor.text.endsWith('.json[') || preCursor.text.endsWith(`${matcher}[`)) { + if ( + /\.json\[/.test(preCursor.text) || + new RegExp(`(${escape(matcher)})\\[`).test(preCursor.text) + ) { const options: Completion[] = Object.keys(jsonOutput) .map((field) => `${matcher}['${field}']`) .map((label) => ({ @@ -248,7 +251,10 @@ export const jsonFieldCompletions = (Vue as CodeNodeEditorMixin).extend({ }; } - if (preCursor.text.endsWith('.json.') || preCursor.text.endsWith(`${matcher}.`)) { + if ( + /\.json\./.test(preCursor.text) || + new RegExp(`(${escape(matcher)})\.`).test(preCursor.text) + ) { const options: Completion[] = Object.keys(jsonOutput) .filter(isAllowedInDotNotation) .map((field) => `${matcher}.${field}`)