Collapse from anywhere (#102)

* Collapse from anywhere within child, instead of just when highlighting the expanded node itself.

Signed-off-by: Ross Hadden <rosshadden@gmail.com>

* Moved cursor to parent.

Signed-off-by: Ross Hadden <rosshadden@gmail.com>

* Properly handled collapsing arrays.

Signed-off-by: Ross Hadden <rosshadden@gmail.com>
js-version
Ross Hadden 5 years ago committed by Anton Medvedev
parent 35526cc4d3
commit d216e02cb3

14
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) {

Loading…
Cancel
Save