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

@ -72,11 +72,11 @@ func init() {
key.WithHelp("", "up"),
),
Expand: key.NewBinding(
key.WithKeys("right", "l"),
key.WithKeys("right", "l", "enter"),
key.WithHelp("", "expand"),
),
Collapse: key.NewBinding(
key.WithKeys("left", "h"),
key.WithKeys("left", "h", "backspace"),
key.WithHelp("", "collapse"),
),
ExpandRecursively: key.NewBinding(

@ -157,6 +157,26 @@ func (m *model) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
}
case key.Matches(msg, keyMap.PrevSibling):
pointsTo := m.cursorPointsTo()
var prevSibling *node
if pointsTo.parent() != nil && pointsTo.parent().end == pointsTo {
prevSibling = pointsTo.parent()
} else if pointsTo.prev != nil {
prevSibling = pointsTo.prev
parent := prevSibling.parent()
if parent != nil && parent.end == prevSibling {
prevSibling = parent
}
}
if prevSibling != nil {
if m.nodeInsideView(prevSibling) {
m.selectNodeInView(prevSibling)
} else {
m.cursor = 0
m.head = prevSibling
m.scrollIntoView()
}
}
case key.Matches(msg, keyMap.Collapse):
node := m.cursorPointsTo().collapseThisOrParent()

@ -61,8 +61,10 @@ func (n *node) isCollapsed() bool {
}
func (n *node) expand() {
if n.collapsed != nil {
n.next.prev = n.end
if n.isCollapsed() {
if n.next != nil {
n.next.prev = n.end
}
n.next = n.collapsed
n.collapsed = nil
}

Loading…
Cancel
Save