Skip to content

Commit 2e2c071

Browse files
committed
feat: add more context lines when scrolling
1 parent 5e0c900 commit 2e2c071

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

filetree.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ func (m ftModel) SetCursor(cursor int) ftModel {
4444
return m
4545
}
4646

47+
const contextLines = 15
48+
4749
func (m *ftModel) scrollSelectedFileIntoView(t *tree.Tree) {
4850
children := t.Children()
4951
for i := 0; i < children.Length(); i++ {
@@ -54,11 +56,10 @@ func (m *ftModel) scrollSelectedFileIntoView(t *tree.Tree) {
5456
case filetree.FileNode:
5557
if child.Path() == *m.selectedFile {
5658
// offset is 1-based, so we need to subtract 1
57-
// we subtract another another 2 because offset should show the node and it's parent
58-
offset := child.YOffset - 3
59+
offset := child.YOffset - 1 - contextLines
5960
// we also need to subtract 1 if the root is not shown
6061
if m.tree.Value() == "." {
61-
offset = child.YOffset - 1
62+
offset = offset - 1
6263
}
6364
m.vp.SetYOffset(offset)
6465
}

0 commit comments

Comments
 (0)