Skip to content

Commit

Permalink
fix(editor): Fix json field completions while typing (#5309)
Browse files Browse the repository at this point in the history
🐛 Fix `json` field completions while typing
  • Loading branch information
ivov authored Jan 31, 2023
1 parent 88c7ef2 commit 07b941a
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) => ({
Expand All @@ -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}`)
Expand Down

0 comments on commit 07b941a

Please sign in to comment.