pull/268/head
Anton Medvedev 9 months ago
parent 22826568ce
commit 1c9d9ebea2
No known key found for this signature in database

@ -179,7 +179,7 @@ func (m *model) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
}
case key.Matches(msg, keyMap.Collapse):
node := m.cursorPointsTo().collapseThisOrParent()
node := m.cursorPointsTo().collapse()
if m.nodeInsideView(node) {
m.selectNodeInView(node)
m.scrollIntoView()
@ -215,7 +215,7 @@ func (m *model) down() {
}
if m.cursor >= m.viewHeight() {
m.cursor = m.viewHeight() - 1
if m.head.next != nil && !n.atEnd() {
if m.head.next != nil && n.next != nil {
m.head = m.head.next
}
}

@ -11,6 +11,10 @@ type node struct {
comma bool
}
func (n *node) hasChildren() bool {
return n.end != nil
}
func (n *node) parent() *node {
if n.directParent == nil {
return nil
@ -35,16 +39,6 @@ func (n *node) append(child *node) {
}
}
func (n *node) collapseThisOrParent() *node {
if n.end == nil || n.isCollapsed() {
if n.parent() != nil {
return n.parent().collapseThisOrParent()
}
return n
}
return n.collapse()
}
func (n *node) collapse() *node {
if n.end != nil {
n.collapsed = n.next
@ -69,7 +63,3 @@ func (n *node) expand() {
n.collapsed = nil
}
}
func (n *node) atEnd() bool {
return n.next == nil
}

Loading…
Cancel
Save