mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-10 22:42:00 +02:00
expand to path when switching to tree mode
This commit is contained in:
@@ -848,6 +848,10 @@ func (gui *Gui) handleToggleFileTreeView() error {
|
||||
|
||||
gui.State.FileChangeManager.ToggleShowTree()
|
||||
|
||||
if path != "" {
|
||||
gui.State.FileChangeManager.ExpandToPath(path)
|
||||
}
|
||||
|
||||
// find that same node in the new format and move the cursor to it
|
||||
if path != "" {
|
||||
index, found := gui.State.FileChangeManager.GetIndexForPath(path)
|
||||
|
@@ -2,6 +2,7 @@ package filetree
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
@@ -141,3 +142,12 @@ func (m *FileChangeManager) renderAux(s *FileChangeNode, prefix string, depth in
|
||||
|
||||
return arr
|
||||
}
|
||||
|
||||
func (m *FileChangeManager) ExpandToPath(path string) {
|
||||
// need every directory along the way
|
||||
split := strings.Split(path, string(os.PathSeparator))
|
||||
for i := range split {
|
||||
dir := strings.Join(split[0:i+1], string(os.PathSeparator))
|
||||
m.collapsedPaths[dir] = false
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user