diff --git a/src/renderer/scripts/autoCompletions/Dynamic.js b/src/renderer/scripts/autoCompletions/Dynamic.js index aa0c38a25..954d67437 100644 --- a/src/renderer/scripts/autoCompletions/Dynamic.js +++ b/src/renderer/scripts/autoCompletions/Dynamic.js @@ -7,7 +7,7 @@ import fs from "fs"; let PARENT_CONTEXT = {}; let NODE_CONTEXT = {}; -let PREV_CONTEXT = undefined; +let PREV_CONTEXT = []; export function walkSync(dir, filelist = []) { fs.readdirSync(dir).forEach(file => { @@ -25,15 +25,14 @@ export function SET_CONTEXT(node, parent) { NODE_CONTEXT = node; } export function CONTEXT_UP() { - PREV_CONTEXT = NODE_CONTEXT; + PREV_CONTEXT.push(NODE_CONTEXT); if(NODE_CONTEXT !== undefined) NODE_CONTEXT = NODE_CONTEXT.parent; if(PARENT_CONTEXT !== undefined) PARENT_CONTEXT = PARENT_CONTEXT.parent; } export function CONTEXT_DOWN() { - if(PREV_CONTEXT !== undefined) { + if(PREV_CONTEXT.length > 0) { PARENT_CONTEXT = NODE_CONTEXT; - NODE_CONTEXT = PREV_CONTEXT; - PREV_CONTEXT = undefined; + NODE_CONTEXT = PREV_CONTEXT.pop(); } else if(NODE_CONTEXT !== undefined) { throw new Error("Called CONTEXT_DOWN without PREV_CONTEXT."); } @@ -42,9 +41,10 @@ export function CONTEXT_DOWN() { export const DYNAMIC = { list: { next_index() { - let arr = NODE_CONTEXT.toJSON(); - if(Array.isArray(arr)) { + if(NODE_CONTEXT.is_array) { let res = []; + let arr = NODE_CONTEXT.toJSON(); + for(let i = arr.length; i >= 0; i--) { res.push(i + ""); } @@ -53,15 +53,10 @@ export const DYNAMIC = { return [ "0" ]; }, index_pair() { - let arr = NODE_CONTEXT.toJSON(); - if(Array.isArray(arr)) return [ "0", "1" ]; - return [ "0" ]; + return [ "0", "1" ]; }, index_triple() { - let arr = NODE_CONTEXT.toJSON(); - if(Array.isArray(arr) && arr.length >= 2) return [ "1", "2" ]; - if(Array.isArray(arr)) return [ "0", "1" ]; - return [ "0" ]; + return [ "0", "1", "2" ]; } }, setting: { diff --git a/src/renderer/scripts/autoCompletions/Provider.js b/src/renderer/scripts/autoCompletions/Provider.js index 794263988..1490f10b4 100644 --- a/src/renderer/scripts/autoCompletions/Provider.js +++ b/src/renderer/scripts/autoCompletions/Provider.js @@ -75,7 +75,7 @@ class Provider { } static removeFromLib(path, current=LIB) { let { key, created } = path.shift(); - console.log(key, created); + // console.log(key, created); if(path.length > 0) this.removeFromLib(path, current[key]); if(created) delete current[key]; } @@ -191,16 +191,16 @@ class Provider { let key = path_arr.shift(); if(current[key] === undefined) { - //TODO: ONE COMPONENT PER CONDITION WHICH USES CURRENT & KEY TO EVALUATE let res = ComponentProvider.process(this, key, path_arr, current); if(res !== undefined) { return res; } else if(current !== LIB) { for(let k of Object.keys(current)) { if(k[0] === "$") { - CONTEXT_UP(); + for(let i = 0; i < path_arr.length + 1; i++) CONTEXT_UP(); let { object, value } = this.omegaExpression(k); - CONTEXT_DOWN(); + for(let i = 0; i < path_arr.length + 1; i++) CONTEXT_DOWN(); + if(value.includes(key) || object[key] !== undefined) return this.walk(path_arr, current[k]); }