diff --git a/fx.js b/fx.js index ed49f29..db19dd4 100644 --- a/fx.js +++ b/fx.js @@ -348,11 +348,17 @@ module.exports = function start(filename, source) { const [n, line] = getLine(program.y) program.showCursor() program.cursorPos(program.y, line.search(/\S/)) - const path = index.get(n) - if (expanded.has(path)) { - expanded.delete(path) - render() + let path = index.get(n) + if (typeof path === 'string' && !expanded.has(path)) { + path = path.replace(/(\.[^\[\].]+|\[\d+\])$/, '') + for (let y = program.y; y >= 0; --y) { + const [n, line] = getLine(y) + program.cursorPos(y, line.search(/\S/)) + if (index.get(n) === path) break + } } + expanded.delete(path) + render() }) box.on('click', function (mouse) {