diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-03-21 08:41:06 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-03-30 21:57:00 +1100 |
commit | da6fe01eca531635c09627c60bd38d49bb092906 (patch) | |
tree | 79ecf551adaee34fccabaa60f3d083c7792a25a0 /pkg/commands/models/file.go | |
parent | c27cea6f30c35328a24bb4fb7db4f002ab544ad3 (diff) |
allow toggling on/off file tree mode
Diffstat (limited to 'pkg/commands/models/file.go')
-rw-r--r-- | pkg/commands/models/file.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/pkg/commands/models/file.go b/pkg/commands/models/file.go index 32e90f718..3e28ca46f 100644 --- a/pkg/commands/models/file.go +++ b/pkg/commands/models/file.go @@ -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 } |