summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-01-31 22:11:34 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-17 19:13:40 +1100
commit2a1e3faa0c61cc8c2418310089485dbab268228f (patch)
tree742988b455946b12a84adccb950b8df5a631417b /pkg
parenteb056576cfe7d97503ef1baf3e1730c87d63976f (diff)
resetting controllers on new repo
Diffstat (limited to 'pkg')
-rw-r--r--pkg/app/app.go8
-rw-r--r--pkg/cheatsheet/generate.go2
-rw-r--r--pkg/gui/branches_panel.go30
-rw-r--r--pkg/gui/commit_files_panel.go10
-rw-r--r--pkg/gui/commits_panel.go6
-rw-r--r--pkg/gui/controllers/files_controller.go4
-rw-r--r--pkg/gui/controllers/files_helper.go (renamed from pkg/gui/file_helper.go)11
-rw-r--r--pkg/gui/controllers/local_commits_controller.go12
-rw-r--r--pkg/gui/controllers/refs_helper.go (renamed from pkg/gui/refs_helper.go)52
-rw-r--r--pkg/gui/controllers/suggestions_helper.go (renamed from pkg/gui/suggestions_helper.go)43
-rw-r--r--pkg/gui/controllers/types.go30
-rw-r--r--pkg/gui/controllers/working_tree_helper.go (renamed from pkg/gui/working_tree_helper.go)24
-rw-r--r--pkg/gui/diffing.go2
-rw-r--r--pkg/gui/dummies.go2
-rw-r--r--pkg/gui/filtering_menu_panel.go2
-rw-r--r--pkg/gui/gui.go226
-rw-r--r--pkg/gui/gui_test.go1
-rw-r--r--pkg/gui/keybindings.go12
-rw-r--r--pkg/gui/layout.go6
-rw-r--r--pkg/gui/line_by_line_panel.go2
-rw-r--r--pkg/gui/list_context_config.go50
-rw-r--r--pkg/gui/misc.go2
-rw-r--r--pkg/gui/modes.go8
-rw-r--r--pkg/gui/patch_options_panel.go20
-rw-r--r--pkg/gui/pull_request_menu_panel.go2
-rw-r--r--pkg/gui/recent_repos_panel.go18
-rw-r--r--pkg/gui/reflog_panel.go10
-rw-r--r--pkg/gui/refresh.go40
-rw-r--r--pkg/gui/remote_branches_panel.go8
-rw-r--r--pkg/gui/remotes_panel.go4
-rw-r--r--pkg/gui/stash_panel.go4
-rw-r--r--pkg/gui/status_panel.go6
-rw-r--r--pkg/gui/sub_commits_panel.go14
-rw-r--r--pkg/gui/submodules_panel.go6
-rw-r--r--pkg/gui/types/common.go29
-rw-r--r--pkg/gui/workspace_reset_options_panel.go2
36 files changed, 360 insertions, 348 deletions
diff --git a/pkg/app/app.go b/pkg/app/app.go
index f38dcb75e..0ee7e4adf 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -94,7 +94,7 @@ func newLogger(config config.AppConfigurer) *logrus.Entry {
}
// NewApp bootstrap a new application
-func NewApp(config config.AppConfigurer, filterPath string) (*App, error) {
+func NewApp(config config.AppConfigurer) (*App, error) {
userConfig := config.GetUserConfig()
app := &App{
@@ -140,7 +140,7 @@ func NewApp(config config.AppConfigurer, filterPath string) (*App, error) {
gitConfig := git_config.NewStdCachedGitConfig(app.Log)
- app.Gui, err = gui.NewGui(app.Common, config, gitConfig, app.Updater, filterPath, showRecentRepos, dirName)
+ app.Gui, err = gui.NewGui(app.Common, config, gitConfig, app.Updater, showRecentRepos, dirName)
if err != nil {
return app, err
}
@@ -241,7 +241,7 @@ func (app *App) setupRepo() (bool, error) {
return false, nil
}
-func (app *App) Run() error {
+func (app *App) Run(filterPath string) error {
if app.ClientContext == "INTERACTIVE_REBASE" {
return app.Rebase()
}
@@ -250,7 +250,7 @@ func (app *App) Run() error {
os.Exit(0)
}
- err := app.Gui.RunAndHandleError()
+ err := app.Gui.RunAndHandleError(filterPath)
return err
}
diff --git a/pkg/cheatsheet/generate.go b/pkg/cheatsheet/generate.go
index 3d1b5efcf..15e390356 100644
--- a/pkg/cheatsheet/generate.go
+++ b/pkg/cheatsheet/generate.go
@@ -41,7 +41,7 @@ func generateAtDir(cheatsheetDir string) {
for lang := range translationSetsByLang {
mConfig.GetUserConfig().Gui.Language = lang
- mApp, _ := app.NewApp(mConfig, "")
+ mApp, _ := app.NewApp(mConfig)
path := cheatsheetDir + "/Keybindings_" + lang + ".md"
file, err := os.Create(path)
if err != nil {
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index 9cf0d740a..f295c9470 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -14,7 +14,7 @@ import (
// list panel functions
func (gui *Gui) getSelectedBranch() *models.Branch {
- if len(gui.State.Branches) == 0 {
+ if len(gui.State.Model.Branches) == 0 {
return nil
}
@@ -23,7 +23,7 @@ func (gui *Gui) getSelectedBranch() *models.Branch {
return nil
}
- return gui.State.Branches[selectedLine]
+ return gui.State.Model.Branches[selectedLine]
}
func (gui *Gui) branchesRenderToMain() error {
@@ -56,7 +56,7 @@ func (gui *Gui) handleBranchPress() error {
}
branch := gui.getSelectedBranch()
gui.c.LogAction(gui.c.Tr.Actions.CheckoutBranch)
- return gui.helpers.refs.CheckoutRef(branch.Name, types.CheckoutRefOptions{})
+ return gui.helpers.Refs.CheckoutRef(branch.Name, types.CheckoutRefOptions{})
}
func (gui *Gui) handleCreatePullRequestPress() error {
@@ -129,10 +129,10 @@ func (gui *Gui) handleForceCheckout() error {
func (gui *Gui) handleCheckoutByName() error {
return gui.c.Prompt(types.PromptOpts{
Title: gui.c.Tr.BranchName + ":",
- FindSuggestionsFunc: gui.helpers.suggestions.GetRefsSuggestionsFunc(),
+ FindSuggestionsFunc: gui.helpers.Suggestions.GetRefsSuggestionsFunc(),
HandleConfirm: func(response string) error {
gui.c.LogAction("Checkout branch")
- return gui.helpers.refs.CheckoutRef(response, types.CheckoutRefOptions{
+ return gui.helpers.Refs.CheckoutRef(response, types.CheckoutRefOptions{
OnRefNotFound: func(ref string) error {
return gui.c.Ask(types.AskOpts{
Title: gui.c.Tr.BranchNotFoundTitle,
@@ -148,11 +148,11 @@ func (gui *Gui) handleCheckoutByName() error {
}
func (gui *Gui) getCheckedOutBranch() *models.Branch {
- if len(gui.State.Branches) == 0 {
+ if len(gui.State.Model.Branches) == 0 {
return nil
}
- return gui.State.Branches[0]
+ return gui.State.Model.Branches[0]
}
func (gui *Gui) createNewBranchWithName(newBranchName string) error {
@@ -239,7 +239,7 @@ func (gui *Gui) mergeBranchIntoCheckedOutBranch(branchName string) error {
HandleConfirm: func() error {
gui.c.LogAction(gui.c.Tr.Actions.Merge)
err := gui.git.Branch.Merge(branchName, git_commands.MergeOpts{})
- return gui.helpers.rebase.CheckMergeOrRebase(err)
+ return gui.helpers.Rebase.CheckMergeOrRebase(err)
},
})
}
@@ -273,7 +273,7 @@ func (gui *Gui) handleRebaseOntoBranch(selectedBranchName string) error {
HandleConfirm: func() error {
gui.c.LogAction(gui.c.Tr.Actions.RebaseBranch)
err := gui.git.Rebase.RebaseBranch(selectedBranchName)
- return gui.helpers.rebase.CheckMergeOrRebase(err)
+ return gui.helpers.Rebase.CheckMergeOrRebase(err)
},
})
}
@@ -339,7 +339,7 @@ func (gui *Gui) handleCreateResetToBranchMenu() error {
return nil
}
- return gui.helpers.refs.CreateGitResetMenu(branch.Name)
+ return gui.helpers.Refs.CreateGitResetMenu(branch.Name)
}
func (gui *Gui) handleRenameBranch() error {
@@ -362,7 +362,7 @@ func (gui *Gui) handleRenameBranch() error {
gui.refreshBranches()
// now that we've got our stuff again we need to find that branch and reselect it.
- for i, newBranch := range gui.State.Branches {
+ for i, newBranch := range gui.State.Model.Branches {
if newBranch.Name == newBranchName {
gui.State.Panels.Branches.SetSelectedLineIdx(i)
if err := gui.State.Contexts.Branches.HandleRender(); err != nil {
@@ -390,12 +390,6 @@ func (gui *Gui) handleRenameBranch() error {
})
}
-// sanitizedBranchName will remove all spaces in favor of a dash "-" to meet
-// git's branch naming requirement.
-func sanitizedBranchName(input string) string {
- return strings.Replace(input, " ", "-", -1)
-}
-
func (gui *Gui) handleEnterBranch() error {
branch := gui.getSelectedBranch()
if branch == nil {
@@ -411,5 +405,5 @@ func (gui *Gui) handleNewBranchOffBranch() error {
return nil
}
- return gui.helpers.refs.NewBranch(selectedBranch.RefName(), selectedBranch.RefName(), "")
+ return gui.helpers.Refs.NewBranch(selectedBranch.RefName(), selectedBranch.RefName(), "")
}
diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go
index 8e6410b9e..f55b3d6c3 100644
--- a/pkg/gui/commit_files_panel.go
+++ b/pkg/gui/commit_files_panel.go
@@ -82,8 +82,8 @@ func (gui *Gui) handleDiscardOldFileChange() error {
HandleConfirm: func() error {
return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error {
gui.c.LogAction(gui.c.Tr.Actions.DiscardOldFileChange)
- if err := gui.git.Rebase.DiscardOldFileChanges(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, fileName); err != nil {
- if err := gui.helpers.rebase.CheckMergeOrRebase(err); err != nil {
+ if err := gui.git.Rebase.DiscardOldFileChanges(gui.State.Model.Commits, gui.State.Panels.Commits.SelectedLineIdx, fileName); err != nil {
+ if err := gui.helpers.Rebase.CheckMergeOrRebase(err); err != nil {
return err
}
}
@@ -109,7 +109,7 @@ func (gui *Gui) refreshCommitFilesView() error {
if err != nil {
return gui.c.Error(err)
}
- gui.State.CommitFiles = files
+ gui.State.Model.CommitFiles = files
gui.State.Contexts.CommitFiles.CommitFileTreeViewModel.SetTree()
return gui.c.PostRefreshUpdate(gui.State.Contexts.CommitFiles)
@@ -121,7 +121,7 @@ func (gui *Gui) handleOpenOldCommitFile() error {
return nil
}
- return gui.helpers.files.OpenFile(node.GetPath())
+ return gui.helpers.Files.OpenFile(node.GetPath())
}
func (gui *Gui) handleEditCommitFile() error {
@@ -134,7 +134,7 @@ func (gui *Gui) handleEditCommitFile() error {
return gui.c.ErrorMsg(gui.c.Tr.ErrCannotEditDirectory)
}
- return gui.helpers.files.EditFile(node.GetPath())
+ return gui.helpers.Files.EditFile(node.GetPath())
}
func (gui *Gui) handleToggleFileForPatch() error {
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index b2233f377..4175918ea 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -12,11 +12,11 @@ const COMMIT_THRESHOLD = 200
func (gui *Gui) getSelectedLocalCommit() *models.Commit {
selectedLine := gui.State.Panels.Commits.SelectedLineIdx
- if selectedLine == -1 || selectedLine > len(gui.State.Commits)-1 {
+ if selectedLine == -1 || selectedLine > len(gui.State.Model.Commits)-1 {
return nil
}
- return gui.State.Commits[selectedLine]
+ return gui.State.Model.Commits[selectedLine]
}
func (gui *Gui) onCommitFocus() error {
@@ -56,7 +56,7 @@ func (gui *Gui) branchCommitsRenderToMain() error {
func (gui *Gui) refForLog() string {
bisectInfo := gui.git.Bisect.GetInfo()
- gui.State.BisectInfo = bisectInfo
+ gui.State.Model.BisectInfo = bisectInfo
if !bisectInfo.Started() {
return "HEAD"
diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go
index 9209a96b3..57df2e84e 100644
--- a/pkg/gui/controllers/files_controller.go
+++ b/pkg/gui/controllers/files_controller.go
@@ -40,7 +40,7 @@ type FilesController struct {
switchToMergeFn func(path string) error
suggestionsHelper ISuggestionsHelper
refsHelper IRefsHelper
- filesHelper IFileHelper
+ filesHelper IFilesHelper
workingTreeHelper IWorkingTreeHelper
}
@@ -64,7 +64,7 @@ func NewFilesController(
switchToMergeFn func(path string) error,
suggestionsHelper ISuggestionsHelper,
refsHelper IRefsHelper,
- filesHelper IFileHelper,
+ filesHelper IFilesHelper,
workingTreeHelper IWorkingTreeHelper,
) *FilesController {
return &FilesController{
diff --git a/pkg/gui/file_helper.go b/pkg/gui/controllers/files_helper.go
index 2e32e168f..c3706cc72 100644
--- a/pkg/gui/file_helper.go
+++ b/pkg/gui/controllers/files_helper.go
@@ -1,12 +1,17 @@
-package gui
+package controllers
import (
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
- "github.com/jesseduffield/lazygit/pkg/gui/controllers"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
+type IFilesHelper interface {
+ EditFile(filename string) error
+ EditFileAtLine(filename string, lineNumber int) error
+ OpenFile(filename string) error
+}
+
type FilesHelper struct {
c *types.ControllerCommon
git *commands.GitCommand
@@ -25,7 +30,7 @@ func NewFilesHelper(
}
}
-var _ controllers.IFileHelper = &FilesHelper{}
+var _ IFilesHelper = &FilesHelper{}
func (self *FilesHelper) EditFile(filename string) error {
return self.EditFileAtLine(filename, 1)
diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go
index 3e30619be..bc25411bf 100644
--- a/pkg/gui/controllers/local_commits_controller.go
+++ b/pkg/gui/controllers/local_commits_controller.go
@@ -20,7 +20,6 @@ type (
GetHostingServiceMgrFn func() *hosting_service.HostingServiceMgr
PullFilesFn func() error
CheckMergeOrRebase func(error) error
- OpenSearchFn func(viewName string) error
)
type LocalCommitsController struct {
@@ -40,7 +39,6 @@ type LocalCommitsController struct {
pullFiles PullFilesFn
getHostingServiceMgr GetHostingServiceMgrFn
switchToCommitFilesContext SwitchToCommitFilesContextFn
- openSearch OpenSearchFn
getLimitCommits func() bool
setLimitCommits func(bool)
getShowWholeGitGraph func() bool
@@ -65,7 +63,6 @@ func NewLocalCommitsController(
pullFiles PullFilesFn,
getHostingServiceMgr GetHostingServiceMgrFn,
switchToCommitFilesContext SwitchToCommitFilesContextFn,
- openSearch OpenSearchFn,
getLimitCommits func() bool,
setLimitCommits func(bool),
getShowWholeGitGraph func() bool,
@@ -87,7 +84,6 @@ func NewLocalCommitsController(
pullFiles: pullFiles,
getHostingServiceMgr: getHostingServiceMgr,
switchToCommitFilesContext: switchToCommitFilesContext,
- openSearch: openSearch,
getLimitCommits: getLimitCommits,
setLimitCommits: setLimitCommits,
getShowWholeGitGraph: getShowWholeGitGraph,
@@ -191,7 +187,7 @@ func (self *LocalCommitsController) Keybindings(
// more commits on demand
{
Key: getKey(config.Universal.StartSearch),
- Handler: func() error { return self.handleOpenSearch("commits") },
+ Handler: self.openSearch,
Description: self.c.Tr.LcStartSearch,
Tag: "navigation",
},
@@ -653,7 +649,7 @@ func (self *LocalCommitsController) handleCreateCommitResetMenu(commit *models.C
return self.refsHelper.CreateGitResetMenu(commit.Sha)
}
-func (self *LocalCommitsController) handleOpenSearch(string) error {
+func (self *LocalCommitsController) openSearch() error {
// we usually lazyload these commits but now that we're searching we need to load them now
if self.getLimitCommits() {
self.setLimitCommits(false)
@@ -662,7 +658,9 @@ func (self *LocalCommitsController) handleOpenSearch(string) error {
}
}
- return self.openSearch("commits")
+ self.c.OpenSearch()
+
+ return nil
}
func (self *LocalCommitsController) gotoBottom() error {
diff --git a/pkg/gui/refs_helper.go b/pkg/gui/controllers/refs_helper.go
index f732ce204..2bb1868e0 100644
--- a/pkg/gui/refs_helper.go
+++ b/pkg/gui/controllers/refs_helper.go
@@ -1,4 +1,4 @@
-package gui
+package controllers
import (
"fmt"
@@ -7,35 +7,40 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
"github.com/jesseduffield/lazygit/pkg/gui/context"
- "github.com/jesseduffield/lazygit/pkg/gui/controllers"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
)
-type RefsHelper struct {
- c *types.ControllerCommon
- git *commands.GitCommand
- getContexts func() context.ContextTree
+type IRefsHelper interface {
+ CheckoutRef(ref string, options types.CheckoutRefOptions) error
+ CreateGitResetMenu(ref string) error
+ ResetToRef(ref string, strength string, envVars []string) error
+ NewBranch(from string, fromDescription string, suggestedBranchname string) error
+}
- getState func() *GuiRepoState
+type RefsHelper struct {
+ c *types.ControllerCommon
+ git *commands.GitCommand
+ getContexts func() context.ContextTree
+ limitCommits func()
}
func NewRefsHelper(
c *types.ControllerCommon,
git *commands.GitCommand,
getContexts func() context.ContextTree,
- getState func() *GuiRepoState,
+ limitCommits func(),
) *RefsHelper {
return &RefsHelper{
- c: c,
- git: git,
- getContexts: getContexts,
- getState: getState,
+ c: c,
+ git: git,
+ getContexts: getContexts,
+ limitCommits: limitCommits,
}
}
-var _ controllers.IRefsHelper = &RefsHelper{}
+var _ IRefsHelper = &RefsHelper{}
func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions) error {
waitingStatus := options.WaitingStatus
@@ -46,10 +51,11 @@ func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions
cmdOptions := git_commands.CheckoutOptions{Force: false, EnvVars: options.EnvVars}
onSuccess := func() {
- self.getState().Panels.Branches.SelectedLineIdx = 0
- self.getState().Panels.Commits.SelectedLineIdx = 0
+ self.getContexts().Branches.GetPanelState().SetSelectedLineIdx(0)
+ self.getContexts().BranchCommits.GetPanelState().SetSelectedLineIdx(0)
+ self.getContexts().ReflogCommits.GetPanelState().SetSelectedLineIdx(0)
// loading a heap of commits is slow so we limit them whenever doing a reset
- self.getState().Panels.Commits.LimitCommits = true
+ self.limitCommits()
}
return self.c.WithWaitingStatus(waitingStatus, func() error {
@@ -101,12 +107,12 @@ func (self *RefsHelper) ResetToRef(ref string, strength string, envVars []string
return self.c.Error(err)
}
- self.getState().Panels.Commits.SelectedLineIdx = 0
- self.getState().Panels.ReflogCommits.SelectedLineIdx = 0
+ self.getContexts().BranchCommits.GetPanelState().SetSelectedLineIdx(0)
+ self.getContexts().ReflogCommits.GetPanelState().SetSelectedLineIdx(0)
// loading a heap of commits is slow so we limit them whenever doing a reset
- self.getState().Panels.Commits.LimitCommits = true
+ self.limitCommits()
- if err := self.c.PushContext(self.getState().Contexts.BranchCommits); err != nil {
+ if err := self.c.PushContext(self.getContexts().BranchCommits); err != nil {
return err
}
@@ -170,3 +176,9 @@ func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggest
},
})
}
+
+// sanitizedBranchName will remove all spaces in favor of a dash "-" to meet
+// git's branch naming requirement.
+func sanitizedBranchName(input string) string {
+ return strings.Replace(input, " ", "-", -1)
+}
diff --git a/pkg/gui/suggestions_helper.go b/pkg/gui/controllers/suggestions_helper.go
index 3d6d9cd79..8a58e0e56 100644
--- a/pkg/gui/suggestions_helper.go
+++ b/pkg/gui/controllers/suggestions_helper.go
@@ -1,10 +1,9 @@
-package gui
+package controllers
import (
"fmt"
"os"
- "github.com/jesseduffield/lazygit/pkg/gui/controllers"
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
@@ -22,30 +21,39 @@ import (
// finding suggestions in this file, so that it's easy to see if a function already
// exists for fetching a particular model.
+type ISuggestionsHelper interface {
+ GetRemoteSuggestionsFunc() func(string) []*types.Suggestion
+ GetBranchNameSuggestionsFunc() func(string) []*types.Suggestion
+ GetFilePathSuggestionsFunc() func(string) []*types.Suggestion
+ GetRemoteBranchesSuggestionsFunc(separator string) func(string) []*types.Suggestion
+ GetRefsSuggestionsFunc() func(string) []*types.Suggestion
+ GetCustomCommandsHistorySuggestionsFunc() func(string) []*types.Suggestion
+}
+
type SuggestionsHelper struct {
c *types.ControllerCommon
- getState func() *GuiRepoState
+ model *types.Model
refreshSuggestionsFn func()
}
-var _ controllers.ISuggestionsHelper = &SuggestionsHelper{}
+var _ ISuggestionsHelper = &SuggestionsHelper{}
func NewSuggestionsHelper(
c *types.ControllerCommon,
- getState func() *GuiRepoState,
+ model *types.Model,
refreshSuggestionsFn func(),
) *SuggestionsHelper {
return &SuggestionsHelper{
c: c,
- getState: getState,
+ model: model,
refreshSuggestionsFn: refreshSuggestionsFn,
}
}
func (self *SuggestionsHelper) getRemoteNames() []string {
- result := make([]string, len(self.getState().Remotes))
- for i, remote := range self.getState().Remotes {
+ result := make([]string, len(self.model.Remotes))
+ for i, remote := range self.model.Remotes {
result[i] = remote.Name
}
return result
@@ -69,8 +77,8 @@ func (self *SuggestionsHelper) GetRemoteSuggestionsFunc() func(string) []*types.
}
func (self *SuggestionsHelper) getBranchNames() []string {
- result := make([]string, len(self.getState().Branches))
- for i, branch := range self.getState().Branches {
+ result := make([]string, len(self.model.Branches))
+ for i, branch := range self.model.Branches {
result[i] = branch.Name
}
return result
@@ -100,8 +108,8 @@ func (self *SuggestionsHelper) GetBranchNameSuggestionsFunc() func(string) []*ty
}
// here we asynchronously fetch the latest set of paths in the repo and store in
-// self.State.FilesTrie. On the main thread we'll be doing a fuzzy search via
-// self.State.FilesTrie. So if we've looked for a file previously, we'll start with
+// self.model.FilesTrie. On the main thread we'll be doing a fuzzy search via
+// self.model.FilesTrie. So if we've looked for a file previously, we'll start with
// the old trie and eventually it'll be swapped out for the new one.
// Notably, unlike other suggestion functions we're not showing all the options
// if nothing has been typed because there'll be too much to display efficiently
@@ -122,8 +130,9 @@ func (self *SuggestionsHelper) GetFilePathSuggestionsFunc() func(string) []*type
trie.Insert(patricia.Prefix(path), path)
return nil
})
+
// cache the trie for future use
- self.getState().FilesTrie = trie
+ self.model.FilesTrie = trie
self.refreshSuggestionsFn()
@@ -132,7 +141,7 @@ func (self *SuggestionsHelper) GetFilePathSuggestionsFunc() func(string) []*type
return func(input string) []*types.Suggestion {
matchingNames := []string{}
- _ = self.getState().FilesTrie.VisitFuzzy(patricia.Prefix(input), true, func(prefix patricia.Prefix, item patricia.Item, skipped int) error {
+ _ = self.model.FilesTrie.VisitFuzzy(patricia.Prefix(input), true, func(prefix patricia.Prefix, item patricia.Item, skipped int) error {
matchingNames = append(matchingNames, item.(string))
return nil
})
@@ -154,7 +163,7 @@ func (self *SuggestionsHelper) GetFilePathSuggestionsFunc() func(string) []*type
func (self *SuggestionsHelper) getRemoteBranchNames(separator string) []string {
result := []string{}
- for _, remote := range self.getState().Remotes {
+ for _, remote := range self.model.Remotes {
for _, branch := range remote.Branches {
result = append(result, fmt.Sprintf("%s%s%s", remote.Name, separator, branch.Name))
}
@@ -167,8 +176,8 @@ func (self *SuggestionsHelper) GetRemoteBranchesSuggestionsFunc(separator string
}
func (self *SuggestionsHelper) getTagNames() []string {
- result := make([]string, len(self.getState().Tags))
- for i, tag := range self.getState().Tags {
+ result := make([]string, len(self.model.Tags))
+ for i, tag := range self.model.Tags {
result[i] = tag.Name
}
return result
diff --git a/pkg/gui/controllers/types.go b/pkg/gui/controllers/types.go
index c3466e536..ecd02536c 100644
--- a/pkg/gui/controllers/types.go
+++ b/pkg/gui/controllers/types.go
@@ -1,39 +1,9 @@
package controllers
import (
- "github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
-type IRefsHelper interface {
- CheckoutRef(ref string, options types.CheckoutRefOptions) error
- CreateGitResetMenu(ref string) error
- ResetToRef(ref string, strength string, en