Skip to content

Commit

Permalink
Collapse from anywhere (#102)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
rosshadden authored and antonmedv committed Apr 4, 2019
1 parent 35526cc commit d216e02
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions fx.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d216e02

Please sign in to comment.