mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-08-24 10:13:41 -05:00
Make StringStack generic
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
d19af37ee7
commit
9b1078a2ca
+3
-3
@@ -96,7 +96,7 @@ type Gui struct {
|
||||
|
||||
// when you enter into a submodule we'll append the superproject's path to this array
|
||||
// so that you can return to the superproject
|
||||
RepoPathStack *utils.StringStack
|
||||
RepoPathStack *utils.Stack[string]
|
||||
|
||||
// this tells us whether our views have been initially set up
|
||||
ViewsSetup bool
|
||||
@@ -158,7 +158,7 @@ type StateAccessor struct {
|
||||
|
||||
var _ types.IStateAccessor = new(StateAccessor)
|
||||
|
||||
func (self *StateAccessor) GetRepoPathStack() *utils.StringStack {
|
||||
func (self *StateAccessor) GetRepoPathStack() *utils.Stack[string] {
|
||||
return self.gui.RepoPathStack
|
||||
}
|
||||
|
||||
@@ -799,7 +799,7 @@ func NewGui(
|
||||
viewBufferManagerMap: map[string]*tasks.ViewBufferManager{},
|
||||
viewPtmxMap: map[string]oscommands.Pty{},
|
||||
showRecentRepos: showRecentRepos,
|
||||
RepoPathStack: &utils.StringStack{},
|
||||
RepoPathStack: &utils.Stack[string]{},
|
||||
RepoStateMap: map[Repo]*GuiRepoState{},
|
||||
GuiLog: []string{},
|
||||
|
||||
|
||||
@@ -404,7 +404,7 @@ type HasUrn interface {
|
||||
}
|
||||
|
||||
type IStateAccessor interface {
|
||||
GetRepoPathStack() *utils.StringStack
|
||||
GetRepoPathStack() *utils.Stack[string]
|
||||
GetRepoState() IRepoStateAccessor
|
||||
GetDiffRendererConfigManager() *config.DiffRendererConfigManager
|
||||
// tells us whether we're currently updating lazygit
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package utils
|
||||
|
||||
type Stack[T any] struct {
|
||||
stack []T
|
||||
}
|
||||
|
||||
func (self *Stack[T]) Push(item T) {
|
||||
self.stack = append(self.stack, item)
|
||||
}
|
||||
|
||||
func (self *Stack[T]) Pop() T {
|
||||
if len(self.stack) == 0 {
|
||||
var zero T
|
||||
return zero
|
||||
}
|
||||
n := len(self.stack) - 1
|
||||
last := self.stack[n]
|
||||
self.stack = self.stack[:n]
|
||||
return last
|
||||
}
|
||||
|
||||
func (self *Stack[T]) IsEmpty() bool {
|
||||
return len(self.stack) == 0
|
||||
}
|
||||
|
||||
func (self *Stack[T]) Clear() {
|
||||
self.stack = nil
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package utils
|
||||
|
||||
type StringStack struct {
|
||||
stack []string
|
||||
}
|
||||
|
||||
func (self *StringStack) Push(s string) {
|
||||
self.stack = append(self.stack, s)
|
||||
}
|
||||
|
||||
func (self *StringStack) Pop() string {
|
||||
if len(self.stack) == 0 {
|
||||
return ""
|
||||
}
|
||||
n := len(self.stack) - 1
|
||||
last := self.stack[n]
|
||||
self.stack = self.stack[:n]
|
||||
return last
|
||||
}
|
||||
|
||||
func (self *StringStack) IsEmpty() bool {
|
||||
return len(self.stack) == 0
|
||||
}
|
||||
|
||||
func (self *StringStack) Clear() {
|
||||
self.stack = []string{}
|
||||
}
|
||||
Reference in New Issue
Block a user