use `H` to collapse value nodes

develop
skanehira 5 years ago
parent 2074324e11
commit bf49ccb878

@ -139,7 +139,7 @@ func (t *Tree) SetKeybindings(g *Gui) {
case 'h':
t.GetCurrentNode().SetExpanded(false)
case 'H':
t.GetRoot().CollapseAll()
t.CollapseValues(t.GetRoot())
case 'd':
t.GetCurrentNode().ClearChildren()
newRoot := *g.Tree.GetRoot()
@ -176,6 +176,20 @@ func (t *Tree) SetKeybindings(g *Gui) {
})
}
func (t *Tree) CollapseValues(node *tview.TreeNode) {
node.Walk(func(node, parent *tview.TreeNode) bool {
ref := node.GetReference().(Reference)
if ref.JSONType == Value {
pRef := parent.GetReference().(Reference)
t := pRef.JSONType
if t == Key || t == Array {
parent.SetExpanded(false)
}
}
return true
})
}
func (t *Tree) moveParent(movement int) {
current := t.GetCurrentNode()
t.GetRoot().Walk(func(node, parent *tview.TreeNode) bool {

Loading…
Cancel
Save