Skip to content

Commit

Permalink
feat: expose Item and ItemAtCurrentOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolev Hadar committed Oct 17, 2024
1 parent 1638aba commit 941897a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,16 @@ func (m *Model) YOffset() int {
return m.yOffset
}

// Item returns the item at the given yoffset

Check failure on line 337 in tree/tree.go

View workflow job for this annotation

GitHub Actions / lint-soft

Comment should end in a period (godot)
func (m *Model) Item(yoffset int) *Item {
return findNode(m.root, yoffset)
}

// ItemAtCurrentOffset returns the item at the current yoffset

Check failure on line 342 in tree/tree.go

View workflow job for this annotation

GitHub Actions / lint-soft

Comment should end in a period (godot)
func (m *Model) ItemAtCurrentOffset() *Item {
return findNode(m.root, m.yOffset)
}

// Since the selected node changes, we need to capture m.yOffset in the
// style function's closure again

Check failure on line 348 in tree/tree.go

View workflow job for this annotation

GitHub Actions / lint-soft

Comment should end in a period (godot)
func (m *Model) updateStyles() {
Expand Down Expand Up @@ -372,7 +382,7 @@ func (m *Model) nodeStyle(node ltree.Node) lipgloss.Style {

// TODO: remove

Check failure on line 383 in tree/tree.go

View workflow job for this annotation

GitHub Actions / lint-soft

Comment should end in a period (godot)
func printDebugInfo(t *Item) string {
debug := fmt.Sprintf("size=%-2d y=%d", t.size, t.yOffset)
debug := fmt.Sprintf("size=%2d y=%2d", t.size, t.yOffset)
children := t.Children()
for i := 0; i < children.Length(); i++ {
child := children.At(i)
Expand Down

0 comments on commit 941897a

Please sign in to comment.