1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

allow toggling on/off file tree mode

This commit is contained in:
Jesse Duffield
2021-03-21 08:41:06 +11:00
parent c27cea6f30
commit da6fe01eca
14 changed files with 175 additions and 58 deletions

View File

@ -1,8 +1,6 @@
package models
import (
"strings"
"github.com/jesseduffield/lazygit/pkg/utils"
)
@ -10,6 +8,7 @@ import (
// duplicating this for now
type File struct {
Name string
PreviousName string
HasStagedChanges bool
HasUnstagedChanges bool
Tracked bool
@ -25,12 +24,16 @@ type File struct {
const RENAME_SEPARATOR = " -> "
func (f *File) IsRename() bool {
return strings.Contains(f.Name, RENAME_SEPARATOR)
return f.PreviousName != ""
}
// Names returns an array containing just the filename, or in the case of a rename, the after filename and the before filename
func (f *File) Names() []string {
return strings.Split(f.Name, RENAME_SEPARATOR)
result := []string{f.Name}
if f.PreviousName != "" {
result = append(result, f.PreviousName)
}
return result
}
// returns true if the file names are the same or if a a file rename includes the filename of the other
@ -73,6 +76,6 @@ func (f *File) GetIsTracked() bool {
}
func (f *File) GetPath() string {
names := f.Names()
return names[len(names)-1]
// TODO: remove concept of name; just use path
return f.Name
}