Add shift left collapse (#144)

pull/148/head
Andrey Shilov 4 years ago committed by GitHub
parent 604512a410
commit 3e0cc4f61b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -271,6 +271,7 @@ Next commands available in interactive mode:
| `left` or `h` | Collapse |
| `right` or `l` | Expand |
| `Shift`+`right` or `L` | Expand all under cursor |
| `Shift`+`left` or `K` | Collapse all under cursor |
| `e` | Expand all |
| `E` | Collapse all |
| `g` | Scroll to top |

23
fx.js

@ -363,6 +363,29 @@ module.exports = function start(filename, source, prev = {}) {
render()
})
box.key(['S-left', 'S-k'], function () {
hideStatusBar()
const [n, line] = getLine(program.y)
program.showCursor()
program.cursorPos(program.y, line.search(/\S/))
const path = index.get(n)
if (!path) {
// collapse on top level (should render like after run)
expanded.clear()
expanded.add('')
} else {
const subJson = reduce(json, 'this' + path)
for (let p of dfs(subJson, path)) {
if (expanded.size < 1000) {
expanded.delete(p)
} else {
break
}
}
}
render()
})
box.key(['left', 'h'], function () {
hideStatusBar()
const [n, line] = getLine(program.y)

Loading…
Cancel
Save