forked from jesseduffield/lazygit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dde30fa
commit c7a629c
Showing
52 changed files
with
3,014 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,38 @@ | ||
package filetree | ||
|
||
type CollapsedPaths map[string]bool | ||
import "github.com/jesseduffield/generics/set" | ||
|
||
func (cp CollapsedPaths) ExpandToPath(path string) { | ||
type CollapsedPaths struct { | ||
collapsedPaths *set.Set[string] | ||
} | ||
|
||
func NewCollapsedPaths() *CollapsedPaths { | ||
return &CollapsedPaths{ | ||
collapsedPaths: set.New[string](), | ||
} | ||
} | ||
|
||
func (self *CollapsedPaths) ExpandToPath(path string) { | ||
// need every directory along the way | ||
splitPath := split(path) | ||
for i := range splitPath { | ||
dir := join(splitPath[0 : i+1]) | ||
cp[dir] = false | ||
self.collapsedPaths.Remove(dir) | ||
} | ||
} | ||
|
||
func (cp CollapsedPaths) IsCollapsed(path string) bool { | ||
return cp[path] | ||
func (self *CollapsedPaths) IsCollapsed(path string) bool { | ||
return self.collapsedPaths.Includes(path) | ||
} | ||
|
||
func (self *CollapsedPaths) Collapse(path string) { | ||
self.collapsedPaths.Add(path) | ||
} | ||
|
||
func (cp CollapsedPaths) ToggleCollapsed(path string) { | ||
cp[path] = !cp[path] | ||
func (self *CollapsedPaths) ToggleCollapsed(path string) { | ||
if self.collapsedPaths.Includes(path) { | ||
self.collapsedPaths.Remove(path) | ||
} else { | ||
self.collapsedPaths.Add(path) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.