1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-20 05:19:24 +02:00

allow configuring to show file tree on startup

This commit is contained in:
Jesse Duffield 2021-03-21 10:07:38 +11:00
parent 46b79c7c61
commit 6fc3c03c4b
5 changed files with 10 additions and 6 deletions

View File

@ -34,6 +34,7 @@ Default path for the config file:
mouseEvents: true mouseEvents: true
skipUnstageLineWarning: false skipUnstageLineWarning: false
skipStashWarning: true skipStashWarning: true
showFileTree: false # for rendering changes files in a tree format
git: git:
paging: paging:
colorArg: always colorArg: always

View File

@ -35,6 +35,7 @@ type GuiConfig struct {
Theme ThemeConfig `yaml:"theme"` Theme ThemeConfig `yaml:"theme"`
CommitLength CommitLengthConfig `yaml:"commitLength"` CommitLength CommitLengthConfig `yaml:"commitLength"`
SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"` SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"`
ShowFileTree bool `yaml:"showFileTree"`
} }
type ThemeConfig struct { type ThemeConfig struct {

View File

@ -840,7 +840,7 @@ func (gui *Gui) handleToggleFileTreeView() error {
if node != nil { if node != nil {
path = node.Path path = node.Path
} }
gui.State.StatusLineManager.TreeMode = !gui.State.StatusLineManager.TreeMode gui.State.StatusLineManager.ShowTree = !gui.State.StatusLineManager.ShowTree
gui.State.StatusLineManager.SetTree() gui.State.StatusLineManager.SetTree()
// find that same node in the new format and move the cursor to it // find that same node in the new format and move the cursor to it

View File

@ -377,8 +377,10 @@ func (gui *Gui) resetState() {
Diffing: prevDiff, Diffing: prevDiff,
} }
showTree := gui.Config.GetUserConfig().Gui.ShowFileTree
gui.State = &guiState{ gui.State = &guiState{
StatusLineManager: NewStatusLineManager(make([]*models.File, 0), gui.Log), StatusLineManager: NewStatusLineManager(make([]*models.File, 0), gui.Log, showTree),
Commits: make([]*models.Commit, 0), Commits: make([]*models.Commit, 0),
FilteredReflogCommits: make([]*models.Commit, 0), FilteredReflogCommits: make([]*models.Commit, 0),
ReflogCommits: make([]*models.Commit, 0), ReflogCommits: make([]*models.Commit, 0),

View File

@ -15,16 +15,16 @@ const COLLAPSED_ARROW = "►"
type StatusLineManager struct { type StatusLineManager struct {
Files []*models.File Files []*models.File
Tree *models.StatusLineNode Tree *models.StatusLineNode
TreeMode bool ShowTree bool
Log *logrus.Entry Log *logrus.Entry
CollapsedPaths map[string]bool CollapsedPaths map[string]bool
} }
func NewStatusLineManager(files []*models.File, log *logrus.Entry) *StatusLineManager { func NewStatusLineManager(files []*models.File, log *logrus.Entry, showTree bool) *StatusLineManager {
return &StatusLineManager{ return &StatusLineManager{
Files: files, Files: files,
Log: log, Log: log,
TreeMode: false, // always true for now ShowTree: showTree,
CollapsedPaths: map[string]bool{}, CollapsedPaths: map[string]bool{},
} }
} }
@ -62,7 +62,7 @@ func (m *StatusLineManager) SetFiles(files []*models.File) {
} }
func (m *StatusLineManager) SetTree() { func (m *StatusLineManager) SetTree() {
if m.TreeMode { if m.ShowTree {
m.Tree = GetTreeFromStatusFiles(m.Files, m.Log) m.Tree = GetTreeFromStatusFiles(m.Files, m.Log)
} else { } else {
m.Tree = GetFlatTreeFromStatusFiles(m.Files) m.Tree = GetFlatTreeFromStatusFiles(m.Files)