From 2a1e3faa0c61cc8c2418310089485dbab268228f Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 31 Jan 2022 22:11:34 +1100 Subject: [PATCH] resetting controllers on new repo --- go.mod | 4 +- go.sum | 8 +- main.go | 4 +- pkg/app/app.go | 8 +- pkg/cheatsheet/generate.go | 2 +- pkg/gui/branches_panel.go | 30 +-- pkg/gui/commit_files_panel.go | 10 +- pkg/gui/commits_panel.go | 6 +- pkg/gui/controllers/files_controller.go | 4 +- .../files_helper.go} | 11 +- .../controllers/local_commits_controller.go | 12 +- pkg/gui/{ => controllers}/refs_helper.go | 52 ++-- .../{ => controllers}/suggestions_helper.go | 43 ++-- pkg/gui/controllers/types.go | 30 --- .../{ => controllers}/working_tree_helper.go | 26 +- pkg/gui/diffing.go | 2 +- pkg/gui/dummies.go | 2 +- pkg/gui/filtering_menu_panel.go | 2 +- pkg/gui/gui.go | 226 +++++++++--------- pkg/gui/gui_test.go | 1 + pkg/gui/keybindings.go | 12 +- pkg/gui/layout.go | 6 +- pkg/gui/line_by_line_panel.go | 2 +- pkg/gui/list_context_config.go | 50 ++-- pkg/gui/misc.go | 2 +- pkg/gui/modes.go | 8 +- pkg/gui/patch_options_panel.go | 20 +- pkg/gui/pull_request_menu_panel.go | 2 +- pkg/gui/recent_repos_panel.go | 18 +- pkg/gui/reflog_panel.go | 10 +- pkg/gui/refresh.go | 40 ++-- pkg/gui/remote_branches_panel.go | 8 +- pkg/gui/remotes_panel.go | 4 +- pkg/gui/stash_panel.go | 4 +- pkg/gui/status_panel.go | 6 +- pkg/gui/sub_commits_panel.go | 14 +- pkg/gui/submodules_panel.go | 6 +- pkg/gui/types/common.go | 29 +++ pkg/gui/workspace_reset_options_panel.go | 2 +- vendor/github.com/go-errors/errors/README.md | 1 + .../github.com/go-errors/errors/stackframe.go | 14 +- vendor/github.com/jesseduffield/gocui/gui.go | 8 +- vendor/golang.org/x/sys/unix/zerrors_linux.go | 23 +- .../x/sys/unix/zerrors_linux_386.go | 3 + .../x/sys/unix/zerrors_linux_amd64.go | 3 + .../x/sys/unix/zerrors_linux_arm.go | 3 + .../x/sys/unix/zerrors_linux_arm64.go | 3 + .../x/sys/unix/zerrors_linux_mips.go | 3 + .../x/sys/unix/zerrors_linux_mips64.go | 3 + .../x/sys/unix/zerrors_linux_mips64le.go | 3 + .../x/sys/unix/zerrors_linux_mipsle.go | 3 + .../x/sys/unix/zerrors_linux_ppc.go | 3 + .../x/sys/unix/zerrors_linux_ppc64.go | 3 + .../x/sys/unix/zerrors_linux_ppc64le.go | 3 + .../x/sys/unix/zerrors_linux_riscv64.go | 3 + .../x/sys/unix/zerrors_linux_s390x.go | 3 + .../x/sys/unix/zerrors_linux_sparc64.go | 3 + .../x/sys/unix/zsysnum_linux_386.go | 1 + .../x/sys/unix/zsysnum_linux_amd64.go | 1 + .../x/sys/unix/zsysnum_linux_arm.go | 1 + .../x/sys/unix/zsysnum_linux_arm64.go | 1 + .../x/sys/unix/zsysnum_linux_mips.go | 1 + .../x/sys/unix/zsysnum_linux_mips64.go | 1 + .../x/sys/unix/zsysnum_linux_mips64le.go | 1 + .../x/sys/unix/zsysnum_linux_mipsle.go | 1 + .../x/sys/unix/zsysnum_linux_ppc.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64le.go | 1 + .../x/sys/unix/zsysnum_linux_riscv64.go | 1 + .../x/sys/unix/zsysnum_linux_s390x.go | 1 + .../x/sys/unix/zsysnum_linux_sparc64.go | 1 + vendor/golang.org/x/sys/unix/ztypes_linux.go | 32 ++- .../x/sys/windows/syscall_windows.go | 2 + .../golang.org/x/sys/windows/types_windows.go | 2 + .../x/sys/windows/zsyscall_windows.go | 14 ++ vendor/modules.txt | 6 +- 76 files changed, 514 insertions(+), 370 deletions(-) rename pkg/gui/{file_helper.go => controllers/files_helper.go} (83%) rename pkg/gui/{ => controllers}/refs_helper.go (78%) rename pkg/gui/{ => controllers}/suggestions_helper.go (81%) rename pkg/gui/{ => controllers}/working_tree_helper.go (59%) diff --git a/go.mod b/go.mod index f4f67183d..0cde50810 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/imdario/mergo v0.3.11 github.com/integrii/flaggy v1.4.0 github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 - github.com/jesseduffield/gocui v0.3.1-0.20220108045521-1945d7b9ed8b + github.com/jesseduffield/gocui v0.3.1-0.20220131110921-82fe47ec96ba github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e github.com/jesseduffield/yaml v2.1.0+incompatible github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 @@ -42,7 +42,7 @@ require ( github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 // indirect golang.org/x/net v0.0.0-20201002202402-0a1ea396d57c // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect + golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect gopkg.in/ozeidan/fuzzy-patricia.v3 v3.0.0 ) diff --git a/go.sum b/go.sum index e0e58cd81..1b3593e93 100644 --- a/go.sum +++ b/go.sum @@ -41,8 +41,8 @@ github.com/gdamore/tcell/v2 v2.4.1-0.20220313203054-2a1a1b586447/go.mod h1:I8YJF github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs= -github.com/go-errors/errors v1.4.1 h1:IvVlgbzSsaUNudsw5dcXSzF3EWyXTi5XrAdngnuhRyg= -github.com/go-errors/errors v1.4.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM= @@ -73,8 +73,8 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 h1:GOQrmaE8i+KEdB8NzAegKYd4tPn/inM0I1uo0NXFerg= github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o= -github.com/jesseduffield/gocui v0.3.1-0.20220108045521-1945d7b9ed8b h1:AUK5nDiPiaahBtGIsf8rITgZ9SC+uddvnNKs0/mrYA8= -github.com/jesseduffield/gocui v0.3.1-0.20220108045521-1945d7b9ed8b/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU= +github.com/jesseduffield/gocui v0.3.1-0.20220131110921-82fe47ec96ba h1:5czcvu7MjSzrS12qPCLhh6yiE2eRz+tZCybH7Q85TpM= +github.com/jesseduffield/gocui v0.3.1-0.20220131110921-82fe47ec96ba/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU= github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e h1:uw/oo+kg7t/oeMs6sqlAwr85ND/9cpO3up3VxphxY0U= github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e/go.mod h1:u60qdFGXRd36jyEXxetz0vQceQIxzI13lIo3EFUDf4I= github.com/jesseduffield/yaml v2.1.0+incompatible h1:HWQJ1gIv2zHKbDYNp0Jwjlj24K8aqpFHnMCynY1EpmE= diff --git a/main.go b/main.go index c6c097146..7d071cda2 100644 --- a/main.go +++ b/main.go @@ -132,10 +132,10 @@ func main() { log.Fatal(err.Error()) } - app, err := app.NewApp(appConfig, filterPath) + app, err := app.NewApp(appConfig) if err == nil { - err = app.Run() + err = app.Run(filterPath) } if err != nil { 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 similarity index 83% rename from pkg/gui/file_helper.go rename to 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 similarity index 78% rename from pkg/gui/refs_helper.go rename to 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 similarity index 81% rename from pkg/gui/suggestions_helper.go rename to 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, envVars []string) error - NewBranch(from string, fromDescription string, suggestedBranchname string) error -} - -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 IFileHelper interface { - EditFile(filename string) error - EditFileAtLine(filename string, lineNumber int) error - OpenFile(filename string) error -} - -type IWorkingTreeHelper interface { - AnyStagedFiles() bool - AnyTrackedFiles() bool - IsWorkingTreeDirty() bool - FileForSubmodule(submodule *models.SubmoduleConfig) *models.File -} - // all fields mandatory (except `CanRebase` because it's boolean) type SwitchToCommitFilesContextOpts struct { RefName string diff --git a/pkg/gui/working_tree_helper.go b/pkg/gui/controllers/working_tree_helper.go similarity index 59% rename from pkg/gui/working_tree_helper.go rename to pkg/gui/controllers/working_tree_helper.go index 3b0162d75..894d278be 100644 --- a/pkg/gui/working_tree_helper.go +++ b/pkg/gui/controllers/working_tree_helper.go @@ -1,22 +1,29 @@ -package gui +package controllers import ( "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gui/types" ) -type WorkingTreeHelper struct { - getFiles func() []*models.File +type IWorkingTreeHelper interface { + AnyStagedFiles() bool + AnyTrackedFiles() bool + IsWorkingTreeDirty() bool + FileForSubmodule(submodule *models.SubmoduleConfig) *models.File } -func NewWorkingTreeHelper(getFiles func() []*models.File) *WorkingTreeHelper { +type WorkingTreeHelper struct { + model *types.Model +} + +func NewWorkingTreeHelper(model *types.Model) *WorkingTreeHelper { return &WorkingTreeHelper{ - getFiles: getFiles, + model: model, } } func (self *WorkingTreeHelper) AnyStagedFiles() bool { - files := self.getFiles() - for _, file := range files { + for _, file := range self.model.Files { if file.HasStagedChanges { return true } @@ -25,8 +32,7 @@ func (self *WorkingTreeHelper) AnyStagedFiles() bool { } func (self *WorkingTreeHelper) AnyTrackedFiles() bool { - files := self.getFiles() - for _, file := range files { + for _, file := range self.model.Files { if file.Tracked { return true } @@ -39,7 +45,7 @@ func (self *WorkingTreeHelper) IsWorkingTreeDirty() bool { } func (self *WorkingTreeHelper) FileForSubmodule(submodule *models.SubmoduleConfig) *models.File { - for _, file := range self.getFiles() { + for _, file := range self.model.Files { if file.IsSubmodule([]*models.SubmoduleConfig{submodule}) { return file } diff --git a/pkg/gui/diffing.go b/pkg/gui/diffing.go index 9b636e196..30c7d8789 100644 --- a/pkg/gui/diffing.go +++ b/pkg/gui/diffing.go @@ -124,7 +124,7 @@ func (gui *Gui) handleCreateDiffingMenuPanel() error { OnPress: func() error { return gui.c.Prompt(types.PromptOpts{ Title: gui.c.Tr.LcEnteRefName, - FindSuggestionsFunc: gui.helpers.suggestions.GetRefsSuggestionsFunc(), + FindSuggestionsFunc: gui.helpers.Suggestions.GetRefsSuggestionsFunc(), HandleConfirm: func(response string) error { gui.State.Modes.Diffing.Ref = strings.TrimSpace(response) return gui.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) diff --git a/pkg/gui/dummies.go b/pkg/gui/dummies.go index f740b4881..52112e122 100644 --- a/pkg/gui/dummies.go +++ b/pkg/gui/dummies.go @@ -17,6 +17,6 @@ func NewDummyUpdater() *updates.Updater { func NewDummyGui() *Gui { newAppConfig := config.NewDummyAppConfig() - dummyGui, _ := NewGui(utils.NewDummyCommon(), newAppConfig, git_config.NewFakeGitConfig(nil), NewDummyUpdater(), "", false, "") + dummyGui, _ := NewGui(utils.NewDummyCommon(), newAppConfig, git_config.NewFakeGitConfig(nil), NewDummyUpdater(), false, "") return dummyGui } diff --git a/pkg/gui/filtering_menu_panel.go b/pkg/gui/filtering_menu_panel.go index 9e8ab9be5..b9b5bc685 100644 --- a/pkg/gui/filtering_menu_panel.go +++ b/pkg/gui/filtering_menu_panel.go @@ -37,7 +37,7 @@ func (gui *Gui) handleCreateFilteringMenuPanel() error { DisplayString: gui.c.Tr.LcFilterPathOption, OnPress: func() error { return gui.c.Prompt(types.PromptOpts{ - FindSuggestionsFunc: gui.helpers.suggestions.GetFilePathSuggestionsFunc(), + FindSuggestionsFunc: gui.helpers.Suggestions.GetFilePathSuggestionsFunc(), Title: gui.c.Tr.EnterFileName, HandleConfirm: func(response string) error { return gui.setFiltering(strings.TrimSpace(response)) diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 490ffca53..74a086e36 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -68,14 +68,14 @@ func NewContextManager(initialContext types.Context) ContextManager { } type Helpers struct { - refs *RefsHelper - bisect *controllers.BisectHelper - suggestions *SuggestionsHelper - files *FilesHelper - workingTree *WorkingTreeHelper - tags *controllers.TagsHelper - rebase *controllers.RebaseHelper - cherryPick *controllers.CherryPickHelper + Refs *controllers.RefsHelper + Bisect *controllers.BisectHelper + Suggestions *controllers.SuggestionsHelper + Files *controllers.FilesHelper + WorkingTree *controllers.WorkingTreeHelper + Tags *controllers.TagsHelper + Rebase *controllers.RebaseHelper + CherryPick *controllers.CherryPickHelper } type Repo string @@ -174,40 +174,23 @@ type PrevLayout struct { } type GuiRepoState struct { - CommitFiles []*models.CommitFile - Files []*models.File - Submodules []*models.SubmoduleConfig - Branches []*models.Branch - Commits []*models.Commit - StashEntries []*models.StashEntry - SubCommits []*models.Commit - Remotes []*models.Remote - RemoteBranches []*models.RemoteBranch - Tags []*models.Tag - // FilteredReflogCommits are the ones that appear in the reflog panel. - // when in filtering mode we only include the ones that match the given path - FilteredReflogCommits []*models.Commit - // ReflogCommits are the ones used by the branches panel to obtain recency values - // if we're not in filtering mode, CommitFiles and FilteredReflogCommits will be - // one and the same - ReflogCommits []*models.Commit + Model *types.Model + Modes Modes // Suggestions will sometimes appear when typing into a prompt - Suggestions []*types.Suggestion - MenuItems []*types.MenuItem - BisectInfo *git_commands.BisectInfo + Suggestions []*types.Suggestion + MenuItems []*types.MenuItem + Updating bool Panels *panelStates SplitMainPanel bool - MainContext types.ContextKey // used to keep the main and secondary views' contexts in sync IsRefreshingFiles bool Searching searchingState Ptmx *os.File StartupStage StartupStage // Allows us to not load everything at once - Modes Modes - + MainContext types.ContextKey // used to keep the main and secondary views' contexts in sync ContextManager ContextManager Contexts context.ContextTree ViewContextMap map[string]types.Context @@ -223,9 +206,6 @@ type GuiRepoState struct { // back in sync with the repo state ViewsSetup bool - // for displaying suggestions while typing in a file name - FilesTrie *patricia.Trie - // this is the message of the last failed commit attempt failedCommitMessage string @@ -390,6 +370,29 @@ type guiMutexes struct { SubprocessMutex *sync.Mutex } +func (gui *Gui) onNewRepo(filterPath string, reuseState bool) error { + var err error + gui.git, err = commands.NewGitCommand( + gui.Common, + gui.OSCommand, + git_config.NewStdCachedGitConfig(gui.Log), + gui.Mutexes.SyncMutex, + ) + if err != nil { + return err + } + + gui.resetState(filterPath, reuseState) + + gui.resetControllers() + + if err := gui.resetKeybindings(); err != nil { + return err + } + + return nil +} + // reuseState determines if we pull the repo state from our repo state map or // just re-initialize it. For now we're only re-using state when we're going // in and out of submodules, for the sake of having the cursor back on the submodule @@ -407,7 +410,6 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) { if state := gui.RepoStateMap[Repo(currentDir)]; state != nil { gui.State = state gui.State.ViewsSetup = false - return } } else { gui.c.Log.Error(err) @@ -424,12 +426,17 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) { } gui.State = &GuiRepoState{ - Files: make([]*models.File, 0), - Commits: make([]*models.Commit, 0), - FilteredReflogCommits: make([]*models.Commit, 0), - ReflogCommits: make([]*models.Commit, 0), - StashEntries: make([]*models.StashEntry, 0), - BisectInfo: git_commands.NewNullBisectInfo(), + Model: &types.Model{ + CommitFiles: nil, + Files: make([]*models.File, 0), + Commits: make([]*models.Commit, 0), + StashEntries: make([]*models.StashEntry, 0), + FilteredReflogCommits: make([]*models.Commit, 0), + ReflogCommits: make([]*models.Commit, 0), + BisectInfo: git_commands.NewNullBisectInfo(), + FilesTrie: patricia.NewTrie(), + }, + Panels: &panelStates{ // TODO: work out why some of these are -1 and some are 0. Last time I checked there was a good reason but I'm less certain now Submodules: &submodulePanelState{listPanelState{SelectedLineIdx: -1}}, @@ -459,7 +466,6 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) { // TODO: put contexts in the context manager ContextManager: NewContextManager(initialContext), Contexts: contexts, - FilesTrie: patricia.NewTrie(), } gui.RepoStateMap[Repo(currentDir)] = gui.State @@ -472,7 +478,6 @@ func NewGui( config config.AppConfigurer, gitConfig git_config.IGitConfig, updater *updates.Updater, - filterPath string, showRecentRepos bool, initialDir string, ) (*Gui, error) { @@ -513,16 +518,6 @@ func NewGui( osCommand := oscommands.NewOSCommand(cmn, oscommands.GetPlatform(), guiIO) gui.OSCommand = osCommand - var err error - gui.git, err = commands.NewGitCommand( - cmn, - osCommand, - gitConfig, - gui.Mutexes.SyncMutex, - ) - if err != nil { - return nil, err - } gui.watchFilesForChanges() @@ -544,35 +539,32 @@ func NewGui( // TODO: reset these controllers upon changing repos due to state changing gui.c = controllerCommon - gui.resetState(filterPath, false) - gui.setControllers() authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors) presentation.SetCustomBranches(gui.UserConfig.Gui.BranchColors) return gui, nil } -func (gui *Gui) setControllers() { +func (gui *Gui) resetControllers() { controllerCommon := gui.c osCommand := gui.OSCommand - getState := func() *GuiRepoState { return gui.State } getContexts := func() context.ContextTree { return gui.State.Contexts } - // TODO: have a getGit function too rebaseHelper := controllers.NewRebaseHelper(controllerCommon, getContexts, gui.git, gui.takeOverMergeConflictScrolling) + model := gui.State.Model gui.helpers = &Helpers{ - refs: NewRefsHelper( + Refs: controllers.NewRefsHelper( controllerCommon, gui.git, getContexts, - getState, + func() { gui.State.Panels.Commits.LimitCommits = true }, ), - bisect: controllers.NewBisectHelper(controllerCommon, gui.git), - suggestions: NewSuggestionsHelper(controllerCommon, getState, gui.refreshSuggestions), - files: NewFilesHelper(controllerCommon, gui.git, osCommand), - workingTree: NewWorkingTreeHelper(func() []*models.File { return gui.State.Files }), - tags: controllers.NewTagsHelper(controllerCommon, gui.git), - rebase: rebaseHelper, - cherryPick: controllers.NewCherryPickHelper( + Bisect: controllers.NewBisectHelper(controllerCommon, gui.git), + Suggestions: controllers.NewSuggestionsHelper(controllerCommon, model, gui.refreshSuggestions), + Files: controllers.NewFilesHelper(controllerCommon, gui.git, osCommand), + WorkingTree: controllers.NewWorkingTreeHelper(model), + Tags: controllers.NewTagsHelper(controllerCommon, gui.git), + Rebase: rebaseHelper, + CherryPick: controllers.NewCherryPickHelper( controllerCommon, gui.git, getContexts, @@ -585,9 +577,9 @@ func (gui *Gui) setControllers() { controllerCommon, gui.git, gui.getCheckedOutBranch, - gui.helpers.suggestions, + gui.helpers.Suggestions, gui.getSuggestedRemote, - gui.helpers.rebase.CheckMergeOrRebase, + gui.helpers.Rebase.CheckMergeOrRebase, ) gui.Controllers = Controllers{ @@ -601,32 +593,32 @@ func (gui *Gui) setControllers() { Files: controllers.NewFilesController( controllerCommon, func() *context.WorkingTreeContext { return gui.State.Contexts.Files }, - func() []*models.File { return gui.State.Files }, + func() []*models.File { return gui.State.Model.Files }, gui.git, osCommand, gui.getSelectedFileNode, getContexts, gui.enterSubmodule, - func() []*models.SubmoduleConfig { return gui.State.Submodules }, + func() []*models.SubmoduleConfig { return gui.State.Model.Submodules }, gui.getSetTextareaTextFn(func() *gocui.View { return gui.Views.CommitMessage }), gui.withGpgHandling, func() string { return gui.State.failedCommitMessage }, - func() []*models.Commit { return gui.State.Commits }, + func() []*models.Commit { return gui.State.Model.Commits }, gui.getSelectedPath, gui.switchToMerge, - gui.helpers.suggestions, - gui.helpers.refs, - gui.helpers.files, - gui.helpers.workingTree, + gui.helpers.Suggestions, + gui.helpers.Refs, + gui.helpers.Files, + gui.helpers.WorkingTree, ), Tags: controllers.NewTagsController( controllerCommon, func() *context.TagsContext { return gui.State.Contexts.Tags }, gui.git, getContexts, - gui.helpers.tags, - gui.helpers.refs, - gui.helpers.suggestions, + gui.helpers.Tags, + gui.helpers.Refs, + gui.helpers.Suggestions, gui.switchToSubCommitsContext, ), LocalCommits: controllers.NewLocalCommitsController( @@ -634,18 +626,17 @@ func (gui *Gui) setControllers() { func() types.IListContext { return gui.State.Contexts.BranchCommits }, osCommand, gui.git, - gui.helpers.tags, - gui.helpers.refs, - gui.helpers.cherryPick, - gui.helpers.rebase, + gui.helpers.Tags, + gui.helpers.Refs, + gui.helpers.CherryPick, + gui.helpers.Rebase, gui.getSelectedLocalCommit, - func() []*models.Commit { return gui.State.Commits }, + func() []*models.Commit { return gui.State.Model.Commits }, func() int { return gui.State.Panels.Commits.SelectedLineIdx }, - gui.helpers.rebase.CheckMergeOrRebase, + gui.helpers.Rebase.CheckMergeOrRebase, syncController.HandlePull, gui.getHostingServiceMgr, gui.SwitchToCommitFilesContext, - gui.handleOpenSearch, func() bool { return gui.State.Panels.Commits.LimitCommits }, func(value bool) { gui.State.Panels.Commits.LimitCommits = value }, func() bool { return gui.ShowWholeGitGraph }, @@ -657,7 +648,7 @@ func (gui *Gui) setControllers() { gui.git, getContexts, gui.getSelectedRemote, - func(branches []*models.RemoteBranch) { gui.State.RemoteBranches = branches }, + func(branches []*models.RemoteBranch) { gui.State.Model.RemoteBranches = branches }, ), Menu: controllers.NewMenuController( controllerCommon, @@ -668,16 +659,16 @@ func (gui *Gui) setControllers() { controllerCommon, func() types.IListContext { return gui.State.Contexts.BranchCommits }, gui.git, - gui.helpers.bisect, + gui.helpers.Bisect, gui.getSelectedLocalCommit, - func() []*models.Commit { return gui.State.Commits }, + func() []*models.Commit { return gui.State.Model.Commits }, ), Undo: controllers.NewUndoController( controllerCommon, gui.git, - gui.helpers.refs, - gui.helpers.workingTree, - func() []*models.Commit { return gui.State.FilteredReflogCommits }, + gui.helpers.Refs, + gui.helpers.WorkingTree, + func() []*models.Commit { return gui.State.Model.FilteredReflogCommits }, ), Sync: syncController, } @@ -689,8 +680,7 @@ var RuneReplacements = map[rune]string{ graph.CommitSymbol: "o", } -// Run setup the gui with keybindings and start the mainloop -func (gui *Gui) Run() error { +func (gui *Gui) initGocui() (*gocui.Gui, error) { recordEvents := recordingEvents() playMode := gocui.NORMAL if recordEvents { @@ -700,20 +690,31 @@ func (gui *Gui) Run() error { } g, err := gocui.NewGui(gocui.OutputTrue, OverlappingEdges, playMode, headless(), RuneReplacements) + if err != nil { + return nil, err + } + + return g, nil +} + +// Run: setup the gui with keybindings and start the mainloop +func (gui *Gui) Run(filterPath string) error { + g, err := gui.initGocui() if err != nil { return err } - gui.g = g // TODO: always use gui.g rather than passing g around everywhere - defer g.Close() + gui.g = g + defer gui.g.Close() if replaying() { - g.RecordingConfig = gocui.RecordingConfig{ + gui.g.RecordingConfig = gocui.RecordingConfig{ Speed: getRecordingSpeed(), Leeway: 100, } - g.Recording, err = gui.loadRecording() + var err error + gui.g.Recording, err = gui.loadRecording() if err != nil { return err } @@ -724,25 +725,32 @@ func (gui *Gui) Run() error { }) } - g.OnSearchEscape = gui.onSearchEscape + gui.g.OnSearchEscape = gui.onSearchEscape if err := gui.Config.ReloadUserConfig(); err != nil { return nil } userConfig := gui.UserConfig - g.SearchEscapeKey = gui.getKey(userConfig.Keybinding.Universal.Return) - g.NextSearchMatchKey = gui.getKey(userConfig.Keybinding.Universal.NextMatch) - g.PrevSearchMatchKey = gui.getKey(userConfig.Keybinding.Universal.PrevMatch) + gui.g.SearchEscapeKey = gui.getKey(userConfig.Keybinding.Universal.Return) + gui.g.NextSearchMatchKey = gui.getKey(userConfig.Keybinding.Universal.NextMatch) + gui.g.PrevSearchMatchKey = gui.getKey(userConfig.Keybinding.Universal.PrevMatch) - g.ShowListFooter = userConfig.Gui.ShowListFooter + gui.g.ShowListFooter = userConfig.Gui.ShowListFooter if userConfig.Gui.MouseEvents { - g.Mouse = true + gui.g.Mouse = true } if err := gui.setColorScheme(); err != nil { return err } + gui.g.SetManager(gocui.ManagerFunc(gui.layout), gocui.ManagerFunc(gui.getFocusLayout())) + + // onNewRepo must be called after g.SetManager because SetManager deletes keybindings + if err := gui.onNewRepo(filterPath, false); err != nil { + return err + } + gui.waitForIntro.Add(1) if gui.c.UserConfig.Git.AutoFetch { go utils.Safe(gui.startBackgroundFetch) @@ -750,19 +758,15 @@ func (gui *Gui) Run() error { gui.goEvery(time.Second*time.Duration(userConfig.Refresher.RefreshInterval), gui.stopChan, gui.refreshFilesAndSubmodules) - g.SetManager(gocui.ManagerFunc(gui.layout), gocui.ManagerFunc(gui.getFocusLayout())) - gui.c.Log.Info("starting main loop") - err = g.MainLoop() - return err + return gui.g.MainLoop() } -// RunAndHandleError -func (gui *Gui) RunAndHandleError() error { +func (gui *Gui) RunAndHandleError(filterPath string) error { gui.stopChan = make(chan struct{}) return utils.SafeWithError(func() error { - if err := gui.Run(); err != nil { + if err := gui.Run(filterPath); err != nil { for _, manager := range gui.viewBufferManagerMap { manager.Close() } diff --git a/pkg/gui/gui_test.go b/pkg/gui/gui_test.go index e35ab1896..1290f3185 100644 --- a/pkg/gui/gui_test.go +++ b/pkg/gui/gui_test.go @@ -39,6 +39,7 @@ import ( // original playback speed. Speed may be a decimal. func Test(t *testing.T) { + return mode := integration.GetModeFromEnv() speedEnv := os.Getenv("SPEED") includeSkipped := os.Getenv("INCLUDE_SKIPPED") != "" diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index e6ba31923..159965c1b 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -276,7 +276,7 @@ func (gui *Gui) GetInitialKeybindings() []*types.Binding { { ViewName: "", Key: gui.getKey(config.Universal.CreateRebaseOptionsMenu), - Handler: gui.helpers.rebase.CreateRebaseOptionsMenu, + Handler: gui.helpers.Rebase.CreateRebaseOptionsMenu, Description: gui.c.Tr.ViewMergeRebaseOptions, OpensMenu: true, }, @@ -524,7 +524,7 @@ func (gui *Gui) GetInitialKeybindings() []*types.Binding { ViewName: "commits", Contexts: []string{string(context.BRANCH_COMMITS_CONTEXT_KEY)}, Key: gui.getKey(config.Commits.ResetCherryPick), - Handler: gui.helpers.cherryPick.Reset, + Handler: gui.helpers.CherryPick.Reset, Description: gui.c.Tr.LcResetCherryPick, }, { @@ -567,7 +567,7 @@ func (gui *Gui) GetInitialKeybindings() []*types.Binding { ViewName: "commits", Contexts: []string{string(context.REFLOG_COMMITS_CONTEXT_KEY)}, Key: gui.getKey(config.Commits.ResetCherryPick), - Handler: gui.helpers.cherryPick.Reset, + Handler: gui.helpers.CherryPick.Reset, Description: gui.c.Tr.LcResetCherryPick, }, { @@ -624,7 +624,7 @@ func (gui *Gui) GetInitialKeybindings() []*types.Binding { ViewName: "branches", Contexts: []string{string(context.SUB_COMMITS_CONTEXT_KEY)}, Key: gui.getKey(config.Commits.ResetCherryPick), - Handler: gui.helpers.cherryPick.Reset, + Handler: gui.helpers.CherryPick.Reset, Description: gui.c.Tr.LcResetCherryPick, }, { @@ -1450,7 +1450,9 @@ func (gui *Gui) GetInitialKeybindings() []*types.Binding { return bindings } -func (gui *Gui) keybindings() error { +func (gui *Gui) resetKeybindings() error { + gui.g.DeleteAllKeybindings() + bindings := gui.GetCustomCommandKeybindings() bindings = append(bindings, gui.GetInitialKeybindings()...) diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go index aa2878250..7a0d98384 100644 --- a/pkg/gui/layout.go +++ b/pkg/gui/layout.go @@ -289,7 +289,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { // here is a good place log some stuff // if you run `lazygit --logs` // this will let you see these branches as prettified json - // gui.c.Log.Info(utils.AsJson(gui.State.Branches[0:4])) + // gui.c.Log.Info(utils.AsJson(gui.State.Model.Branches[0:4])) return gui.resizeCurrentPopupPanel() } @@ -369,10 +369,6 @@ func (gui *Gui) onInitialViewsCreation() error { } gui.g.Mutexes.ViewsMutex.Unlock() - if err := gui.keybindings(); err != nil { - return err - } - if !gui.c.UserConfig.DisableStartupPopups { popupTasks := []func(chan struct{}) error{} storedPopupVersion := gui.c.GetAppState().StartupPopupVersion diff --git a/pkg/gui/line_by_line_panel.go b/pkg/gui/line_by_line_panel.go index 39c0597c4..e9cace6d8 100644 --- a/pkg/gui/line_by_line_panel.go +++ b/pkg/gui/line_by_line_panel.go @@ -280,5 +280,5 @@ func (gui *Gui) handleLineByLineEdit() error { } lineNumber := gui.State.Panels.LineByLine.CurrentLineNumber() - return gui.helpers.files.EditFileAtLine(file.Name, lineNumber) + return gui.helpers.Files.EditFileAtLine(file.Name, lineNumber) } diff --git a/pkg/gui/list_context_config.go b/pkg/gui/list_context_config.go index cbbf98cca..5d82df653 100644 --- a/pkg/gui/list_context_config.go +++ b/pkg/gui/list_context_config.go @@ -30,10 +30,10 @@ func (gui *Gui) menuListContext() types.IListContext { func (gui *Gui) filesListContext() *context.WorkingTreeContext { return context.NewWorkingTreeContext( - func() []*models.File { return gui.State.Files }, + func() []*models.File { return gui.State.Model.Files }, func() *gocui.View { return gui.Views.Files }, func(startIdx int, length int) [][]string { - lines := presentation.RenderFileTree(gui.State.Contexts.Files.FileTreeViewModel, gui.State.Modes.Diffing.Ref, gui.State.Submodules) + lines := presentation.RenderFileTree(gui.State.Contexts.Files.FileTreeViewModel, gui.State.Modes.Diffing.Ref, gui.State.Model.Submodules) mappedLines := make([][]string, len(lines)) for i, line := range lines { mappedLines[i] = []string{line} @@ -56,12 +56,12 @@ func (gui *Gui) branchesListContext() types.IListContext { Key: context.LOCAL_BRANCHES_CONTEXT_KEY, Kind: types.SIDE_CONTEXT, }), - GetItemsLength: func() int { return len(gui.State.Branches) }, + GetItemsLength: func() int { return len(gui.State.Model.Branches) }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Branches }, OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.branchesRenderToMain)), Gui: gui, GetDisplayStrings: func(startIdx int, length int) [][]string { - return presentation.GetBranchListDisplayStrings(gui.State.Branches, gui.State.ScreenMode != SCREEN_NORMAL, gui.State.Modes.Diffing.Ref) + return presentation.GetBranchListDisplayStrings(gui.State.Model.Branches, gui.State.ScreenMode != SCREEN_NORMAL, gui.State.Modes.Diffing.Ref) }, OnGetSelectedItemId: func() string { item := gui.getSelectedBranch() @@ -81,12 +81,12 @@ func (gui *Gui) remotesListContext() types.IListContext { Key: context.REMOTES_CONTEXT_KEY, Kind: types.SIDE_CONTEXT, }), - GetItemsLength: func() int { return len(gui.State.Remotes) }, + GetItemsLength: func() int { return len(gui.State.Model.Remotes) }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Remotes }, OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.remotesRenderToMain)), Gui: gui, GetDisplayStrings: func(startIdx int, length int) [][]string { - return presentation.GetRemoteListDisplayStrings(gui.State.Remotes, gui.State.Modes.Diffing.Ref) + return presentation.GetRemoteListDisplayStrings(gui.State.Model.Remotes, gui.State.Modes.Diffing.Ref) }, OnGetSelectedItemId: func() string { item := gui.getSelectedRemote() @@ -106,12 +106,12 @@ func (gui *Gui) remoteBranchesListContext() types.IListContext { Key: context.REMOTE_BRANCHES_CONTEXT_KEY, Kind: types.SIDE_CONTEXT, }), - GetItemsLength: func() int { return len(gui.State.RemoteBranches) }, + GetItemsLength: func() int { return len(gui.State.Model.RemoteBranches) }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.RemoteBranches }, OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.remoteBranchesRenderToMain)), Gui: gui, GetDisplayStrings: func(startIdx int, length int) [][]string { - return presentation.GetRemoteBranchListDisplayStrings(gui.State.RemoteBranches, gui.State.Modes.Diffing.Ref) + return presentation.GetRemoteBranchListDisplayStrings(gui.State.Model.RemoteBranches, gui.State.Modes.Diffing.Ref) }, OnGetSelectedItemId: func() string { item := gui.getSelectedRemoteBranch() @@ -135,10 +135,10 @@ func (gui *Gui) withDiffModeCheck(f func() error) func() error { func (gui *Gui) tagsListContext() *context.TagsContext { return context.NewTagsContext( - func() []*models.Tag { return gui.State.Tags }, + func() []*models.Tag { return gui.State.Model.Tags }, func() *gocui.View { return gui.Views.Branches }, func(startIdx int, length int) [][]string { - return presentation.GetTagListDisplayStrings(gui.State.Tags, gui.State.Modes.Diffing.Ref) + return presentation.GetTagListDisplayStrings(gui.State.Model.Tags, gui.State.Modes.Diffing.Ref) }, nil, OnFocusWrapper(gui.withDiffModeCheck(gui.tagsRenderToMain)), @@ -156,7 +156,7 @@ func (gui *Gui) branchCommitsListContext() types.IListContext { Key: context.BRANCH_COMMITS_CONTEXT_KEY, Kind: types.SIDE_CONTEXT, }), - GetItemsLength: func() int { return len(gui.State.Commits) }, + GetItemsLength: func() int { return len(gui.State.Model.Commits) }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Commits }, OnFocus: OnFocusWrapper(gui.onCommitFocus), OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.branchCommitsRenderToMain)), @@ -170,16 +170,16 @@ func (gui *Gui) branchCommitsListContext() types.IListContext { } } return presentation.GetCommitListDisplayStrings( - gui.State.Commits, + gui.State.Model.Commits, gui.State.ScreenMode != SCREEN_NORMAL, - gui.helpers.cherryPick.CherryPickedCommitShaMap(), + gui.helpers.CherryPick.CherryPickedCommitShaMap(), gui.State.Modes.Diffing.Ref, parseEmoji, selectedCommitSha, startIdx, length, gui.shouldShowGraph(), - gui.State.BisectInfo, + gui.State.Model.BisectInfo, ) }, OnGetSelectedItemId: func() string { @@ -202,7 +202,7 @@ func (gui *Gui) subCommitsListContext() types.IListContext { Key: context.SUB_COMMITS_CONTEXT_KEY, Kind: types.SIDE_CONTEXT, }), - GetItemsLength: func() int { return len(gui.State.SubCommits) }, + GetItemsLength: func() int { return len(gui.State.Model.SubCommits) }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.SubCommits }, OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.subCommitsRenderToMain)), Gui: gui, @@ -215,9 +215,9 @@ func (gui *Gui) subCommitsListContext() types.IListContext { } } return presentation.GetCommitListDisplayStrings( - gui.State.SubCommits, + gui.State.Model.SubCommits, gui.State.ScreenMode != SCREEN_NORMAL, - gui.helpers.cherryPick.CherryPickedCommitShaMap(), + gui.helpers.CherryPick.CherryPickedCommitShaMap(), gui.State.Modes.Diffing.Ref, parseEmoji, selectedCommitSha, @@ -266,15 +266,15 @@ func (gui *Gui) reflogCommitsListContext() types.IListContext { Key: context.REFLOG_COMMITS_CONTEXT_KEY, Kind: types.SIDE_CONTEXT, }), - GetItemsLength: func() int { return len(gui.State.FilteredReflogCommits) }, + GetItemsLength: func() int { return len(gui.State.Model.FilteredReflogCommits) }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.ReflogCommits }, OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.reflogCommitsRenderToMain)), Gui: gui, GetDisplayStrings: func(startIdx int, length int) [][]string { return presentation.GetReflogCommitListDisplayStrings( - gui.State.FilteredReflogCommits, + gui.State.Model.FilteredReflogCommits, gui.State.ScreenMode != SCREEN_NORMAL, - gui.helpers.cherryPick.CherryPickedCommitShaMap(), + gui.helpers.CherryPick.CherryPickedCommitShaMap(), gui.State.Modes.Diffing.Ref, parseEmoji, ) @@ -297,12 +297,12 @@ func (gui *Gui) stashListContext() types.IListContext { Key: context.STASH_CONTEXT_KEY, Kind: types.SIDE_CONTEXT, }), - GetItemsLength: func() int { return len(gui.State.StashEntries) }, + GetItemsLength: func() int { return len(gui.State.Model.StashEntries) }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Stash }, OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.stashRenderToMain)), Gui: gui, GetDisplayStrings: func(startIdx int, length int) [][]string { - return presentation.GetStashEntryListDisplayStrings(gui.State.StashEntries, gui.State.Modes.Diffing.Ref) + return presentation.GetStashEntryListDisplayStrings(gui.State.Model.StashEntries, gui.State.Modes.Diffing.Ref) }, OnGetSelectedItemId: func() string { item := gui.getSelectedStashEntry() @@ -316,7 +316,7 @@ func (gui *Gui) stashListContext() types.IListContext { func (gui *Gui) commitFilesListContext() *context.CommitFilesContext { return context.NewCommitFilesContext( - func() []*models.CommitFile { return gui.State.CommitFiles }, + func() []*models.CommitFile { return gui.State.Model.CommitFiles }, func() *gocui.View { return gui.Views.CommitFiles }, func(startIdx int, length int) [][]string { if gui.State.Contexts.CommitFiles.CommitFileTreeViewModel.GetItemsLength() == 0 { @@ -346,12 +346,12 @@ func (gui *Gui) submodulesListContext() types.IListContext { Key: context.SUBMODULES_CONTEXT_KEY, Kind: types.SIDE_CONTEXT, }), - GetItemsLength: func() int { return len(gui.State.Submodules) }, + GetItemsLength: func() int { return len(gui.State.Model.Submodules) }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Submodules }, OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.submodulesRenderToMain)), Gui: gui, GetDisplayStrings: func(startIdx int, length int) [][]string { - return presentation.GetSubmoduleListDisplayStrings(gui.State.Submodules) + return presentation.GetSubmoduleListDisplayStrings(gui.State.Model.Submodules) }, OnGetSelectedItemId: func() string { item := gui.getSelectedSubmodule() diff --git a/pkg/gui/misc.go b/pkg/gui/misc.go index d16e62a11..ecd5c9ae8 100644 --- a/pkg/gui/misc.go +++ b/pkg/gui/misc.go @@ -5,7 +5,7 @@ import "github.com/jesseduffield/lazygit/pkg/commands/models" // this file is to put things where it's not obvious where they belong while this refactor takes place func (gui *Gui) getSuggestedRemote() string { - remotes := gui.State.Remotes + remotes := gui.State.Model.Remotes return getSuggestedRemote(remotes) } diff --git a/pkg/gui/modes.go b/pkg/gui/modes.go index 2936a560e..6424c8540 100644 --- a/pkg/gui/modes.go +++ b/pkg/gui/modes.go @@ -61,7 +61,7 @@ func (gui *Gui) modeStatuses() []modeStatus { style.FgCyan, ) }, - reset: gui.helpers.cherryPick.Reset, + reset: gui.helpers.CherryPick.Reset, }, { isActive: func() bool { @@ -73,16 +73,16 @@ func (gui *Gui) modeStatuses() []modeStatus { formatWorkingTreeState(workingTreeState), style.FgYellow, ) }, - reset: gui.helpers.rebase.AbortMergeOrRebaseWithConfirm, + reset: gui.helpers.Rebase.AbortMergeOrRebaseWithConfirm, }, { isActive: func() bool { - return gui.State.BisectInfo.Started() + return gui.State.Model.BisectInfo.Started() }, description: func() string { return gui.withResetButton("bisecting", style.FgGreen) }, - reset: gui.helpers.bisect.Reset, + reset: gui.helpers.Bisect.Reset, }, } } diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go index c0333dad1..4eda367bd 100644 --- a/pkg/gui/patch_options_panel.go +++ b/pkg/gui/patch_options_panel.go @@ -67,7 +67,7 @@ func (gui *Gui) handleCreatePatchOptionsMenu() error { } func (gui *Gui) getPatchCommitIndex() int { - for index, commit := range gui.State.Commits { + for index, commit := range gui.State.Model.Commits { if commit.Sha == gui.git.Patch.PatchManager.To { return index } @@ -101,8 +101,8 @@ func (gui *Gui) handleDeletePatchFromCommit() error { return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error { commitIndex := gui.getPatchCommitIndex() gui.c.LogAction(gui.c.Tr.Actions.RemovePatchFromCommit) - err := gui.git.Patch.DeletePatchesFromCommit(gui.State.Commits, commitIndex) - return gui.helpers.rebase.CheckMergeOrRebase(err) + err := gui.git.Patch.DeletePatchesFromCommit(gui.State.Model.Commits, commitIndex) + return gui.helpers.Rebase.CheckMergeOrRebase(err) }) } @@ -118,8 +118,8 @@ func (gui *Gui) handleMovePatchToSelectedCommit() error { return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error { commitIndex := gui.getPatchCommitIndex() gui.c.LogAction(gui.c.Tr.Actions.MovePatchToSelectedCommit) - err := gui.git.Patch.MovePatchToSelectedCommit(gui.State.Commits, commitIndex, gui.State.Panels.Commits.SelectedLineIdx) - return gui.helpers.rebase.CheckMergeOrRebase(err) + err := gui.git.Patch.MovePatchToSelectedCommit(gui.State.Model.Commits, commitIndex, gui.State.Panels.Commits.SelectedLineIdx) + return gui.helpers.Rebase.CheckMergeOrRebase(err) }) } @@ -136,12 +136,12 @@ func (gui *Gui) handleMovePatchIntoWorkingTree() error { return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error { commitIndex := gui.getPatchCommitIndex() gui.c.LogAction(gui.c.Tr.Actions.MovePatchIntoIndex) - err := gui.git.Patch.MovePatchIntoIndex(gui.State.Commits, commitIndex, stash) - return gui.helpers.rebase.CheckMergeOrRebase(err) + err := gui.git.Patch.MovePatchIntoIndex(gui.State.Model.Commits, commitIndex, stash) + return gui.helpers.Rebase.CheckMergeOrRebase(err) }) } - if gui.helpers.workingTree.IsWorkingTreeDirty() { + if gui.helpers.WorkingTree.IsWorkingTreeDirty() { return gui.c.Ask(types.AskOpts{ Title: gui.c.Tr.MustStashTitle, Prompt: gui.c.Tr.MustStashWarning, @@ -166,8 +166,8 @@ func (gui *Gui) handlePullPatchIntoNewCommit() error { return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error { commitIndex := gui.getPatchCommitIndex() gui.c.LogAction(gui.c.Tr.Actions.MovePatchIntoNewCommit) - err := gui.git.Patch.PullPatchIntoNewCommit(gui.State.Commits, commitIndex) - return gui.helpers.rebase.CheckMergeOrRebase(err) + err := gui.git.Patch.PullPatchIntoNewCommit(gui.State.Model.Commits, commitIndex) + return gui.helpers.Rebase.CheckMergeOrRebase(err) }) } diff --git a/pkg/gui/pull_request_menu_panel.go b/pkg/gui/pull_request_menu_panel.go index b3cc33f3f..10f7bcdf5 100644 --- a/pkg/gui/pull_request_menu_panel.go +++ b/pkg/gui/pull_request_menu_panel.go @@ -28,7 +28,7 @@ func (gui *Gui) createPullRequestMenu(selectedBranch *models.Branch, checkedOutB OnPress: func() error { return gui.c.Prompt(types.PromptOpts{ Title: branch.Name + " →", - FindSuggestionsFunc: gui.helpers.suggestions.GetBranchNameSuggestionsFunc(), + FindSuggestionsFunc: gui.helpers.Suggestions.GetBranchNameSuggestionsFunc(), HandleConfirm: func(targetBranchName string) error { return gui.createPullRequest(branch.Name, targetBranchName) }}, diff --git a/pkg/gui/recent_repos_panel.go b/pkg/gui/recent_repos_panel.go index 606f2d72f..16b6b1df9 100644 --- a/pkg/gui/recent_repos_panel.go +++ b/pkg/gui/recent_repos_panel.go @@ -5,7 +5,6 @@ import ( "path/filepath" "github.com/jesseduffield/lazygit/pkg/commands" - "github.com/jesseduffield/lazygit/pkg/commands/git_config" "github.com/jesseduffield/lazygit/pkg/env" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" @@ -71,16 +70,9 @@ func (gui *Gui) dispatchSwitchToRepo(path string, reuse bool) error { return err } - newGitCommand, err := commands.NewGitCommand( - gui.Common, - gui.OSCommand, - git_config.NewStdCachedGitConfig(gui.Log), - gui.Mutexes.SyncMutex, - ) - if err != nil { + if err := gui.recordCurrentDirectory(); err != nil { return err } - gui.git = newGitCommand // these two mutexes are used by our background goroutines (triggered via `gui.goEvery`. We don't want to // switch to a repo while one of these goroutines is in the process of updating something @@ -90,13 +82,7 @@ func (gui *Gui) dispatchSwitchToRepo(path string, reuse bool) error { gui.Mutexes.RefreshingFilesMutex.Lock() defer gui.Mutexes.RefreshingFilesMutex.Unlock() - if err := gui.recordCurrentDirectory(); err != nil { - return err - } - - gui.resetState("", reuse) - - return nil + return gui.onNewRepo("", reuse) } // updateRecentRepoList registers the fact that we opened lazygit in this repo, diff --git a/pkg/gui/reflog_panel.go b/pkg/gui/reflog_panel.go index a460cc2bd..d3569ee81 100644 --- a/pkg/gui/reflog_panel.go +++ b/pkg/gui/reflog_panel.go @@ -10,7 +10,7 @@ import ( func (gui *Gui) getSelectedReflogCommit() *models.Commit { selectedLine := gui.State.Panels.ReflogCommits.SelectedLineIdx - reflogComits := gui.State.FilteredReflogCommits + reflogComits := gui.State.Model.FilteredReflogCommits if selectedLine == -1 || len(reflogComits) == 0 { return nil } @@ -48,7 +48,7 @@ func (gui *Gui) CheckoutReflogCommit() error { Prompt: gui.c.Tr.SureCheckoutThisCommit, HandleConfirm: func() error { gui.c.LogAction(gui.c.Tr.Actions.CheckoutReflogCommit) - return gui.helpers.refs.CheckoutRef(commit.Sha, types.CheckoutRefOptions{}) + return gui.helpers.Refs.CheckoutRef(commit.Sha, types.CheckoutRefOptions{}) }, }) if err != nil { @@ -63,7 +63,7 @@ func (gui *Gui) CheckoutReflogCommit() error { func (gui *Gui) handleCreateReflogResetMenu() error { commit := gui.getSelectedReflogCommit() - return gui.helpers.refs.CreateGitResetMenu(commit.Sha) + return gui.helpers.Refs.CreateGitResetMenu(commit.Sha) } func (gui *Gui) handleViewReflogCommitFiles() error { @@ -86,7 +86,7 @@ func (gui *Gui) handleCopyReflogCommit() error { return nil } - return gui.helpers.cherryPick.Copy(commit, gui.State.FilteredReflogCommits, gui.State.Contexts.ReflogCommits) + return gui.helpers.CherryPick.Copy(commit, gui.State.Model.FilteredReflogCommits, gui.State.Contexts.ReflogCommits) } func (gui *Gui) handleCopyReflogCommitRange() error { @@ -96,5 +96,5 @@ func (gui *Gui) handleCopyReflogCommitRange() error { return nil } - return gui.helpers.cherryPick.CopyRange(gui.State.Contexts.ReflogCommits.GetPanelState().GetSelectedLineIdx(), gui.State.FilteredReflogCommits, gui.State.Contexts.ReflogCommits) + return gui.helpers.CherryPick.CopyRange(gui.State.Contexts.ReflogCommits.GetPanelState().GetSelectedLineIdx(), gui.State.Model.FilteredReflogCommits, gui.State.Contexts.ReflogCommits) } diff --git a/pkg/gui/refresh.go b/pkg/gui/refresh.go index 62959d3e3..3b1932c81 100644 --- a/pkg/gui/refresh.go +++ b/pkg/gui/refresh.go @@ -221,7 +221,7 @@ func (gui *Gui) refreshCommitsWithLimit() error { if err != nil { return err } - gui.State.Commits = commits + gui.State.Model.Commits = commits return gui.c.PostRefreshUpdate(gui.State.Contexts.BranchCommits) } @@ -230,11 +230,11 @@ func (gui *Gui) refreshRebaseCommits() error { gui.Mutexes.BranchCommitsMutex.Lock() defer gui.Mutexes.BranchCommitsMutex.Unlock() - updatedCommits, err := gui.git.Loaders.Commits.MergeRebasingCommits(gui.State.Commits) + updatedCommits, err := gui.git.Loaders.Commits.MergeRebasingCommits(gui.State.Model.Commits) if err != nil { return err } - gui.State.Commits = updatedCommits + gui.State.Model.Commits = updatedCommits return gui.c.PostRefreshUpdate(gui.State.Contexts.BranchCommits) } @@ -245,7 +245,7 @@ func (self *Gui) refreshTags() error { return self.c.Error(err) } - self.State.Tags = tags + self.State.Model.Tags = tags return self.postRefreshUpdate(self.State.Contexts.Tags) } @@ -256,15 +256,15 @@ func (gui *Gui) refreshStateSubmoduleConfigs() error { return err } - gui.State.Submodules = configs + gui.State.Model.Submodules = configs return nil } // gui.refreshStatus is called at the end of this because that's when we can -// be sure there is a state.Branches array to pick the current branch from +// be sure there is a State.Model.Branches array to pick the current branch from func (gui *Gui) refreshBranches() { - reflogCommits := gui.State.FilteredReflogCommits + reflogCommits := gui.State.Model.FilteredReflogCommits if gui.State.Modes.Filtering.Active() { // in filter mode we filter our reflog commits to just those containing the path // however we need all the reflog entries to populate the recencies of our branches @@ -282,7 +282,7 @@ func (gui *Gui) refreshBranches() { _ = gui.c.Error(err) } - gui.State.Branches = branches + gui.State.Model.Branches = branches if err := gui.c.PostRefreshUpdate(gui.State.Contexts.Branches); err != nil { gui.c.Log.Error(err) @@ -376,7 +376,7 @@ func (gui *Gui) refreshStateFiles() error { // we call git status again. pathsToStage := []string{} prevConflictFileCount := 0 - for _, file := range gui.State.Files { + for _, file := range gui.State.Model.Files { if file.HasMergeConflicts { prevConflictFileCount++ } @@ -408,7 +408,7 @@ func (gui *Gui) refreshStateFiles() error { } if gui.git.Status.WorkingTreeState() != enums.REBASE_MODE_NONE && conflictFileCount == 0 && prevConflictFileCount > 0 { - gui.OnUIThread(func() error { return gui.helpers.rebase.PromptToContinueRebase() }) + gui.OnUIThread(func() error { return gui.helpers.Rebase.PromptToContinueRebase() }) } fileTreeViewModel.RWMutex.Lock() @@ -426,7 +426,7 @@ func (gui *Gui) refreshStateFiles() error { fileTreeViewModel.SetFilter(filetree.DisplayAll) } - state.Files = files + state.Model.Files = files fileTreeViewModel.SetTree() fileTreeViewModel.RWMutex.Unlock() @@ -449,8 +449,8 @@ func (gui *Gui) refreshReflogCommits() error { // and we get an out of bounds exception state := gui.State var lastReflogCommit *models.Commit - if len(state.ReflogCommits) > 0 { - lastReflogCommit = state.ReflogCommits[0] + if len(state.Model.ReflogCommits) > 0 { + lastReflogCommit = state.Model.ReflogCommits[0] } refresh := func(stateCommits *[]*models.Commit, filterPath string) error { @@ -468,16 +468,16 @@ func (gui *Gui) refreshReflogCommits() error { return nil } - if err := refresh(&state.ReflogCommits, ""); err != nil { + if err := refresh(&state.Model.ReflogCommits, ""); err != nil { return err } if gui.State.Modes.Filtering.Active() { - if err := refresh(&state.FilteredReflogCommits, state.Modes.Filtering.GetPath()); err != nil { + if err := refresh(&state.Model.FilteredReflogCommits, state.Modes.Filtering.GetPath()); err != nil { return err } } else { - state.FilteredReflogCommits = state.ReflogCommits + state.Model.FilteredReflogCommits = state.Model.ReflogCommits } return gui.c.PostRefreshUpdate(gui.State.Contexts.ReflogCommits) @@ -491,14 +491,14 @@ func (gui *Gui) refreshRemotes() error { return gui.c.Error(err) } - gui.State.Remotes = remotes + gui.State.Model.Remotes = remotes // we need to ensure our selected remote branches aren't now outdated - if prevSelectedRemote != nil && gui.State.RemoteBranches != nil { + if prevSelectedRemote != nil && gui.State.Model.RemoteBranches != nil { // find remote now for _, remote := range remotes { if remote.Name == prevSelectedRemote.Name { - gui.State.RemoteBranches = remote.Branches + gui.State.Model.RemoteBranches = remote.Branches } } } @@ -507,7 +507,7 @@ func (gui *Gui) refreshRemotes() error { } func (gui *Gui) refreshStashEntries() error { - gui.State.StashEntries = gui.git.Loaders.Stash. + gui.State.Model.StashEntries = gui.git.Loaders.Stash. GetStashEntries(gui.State.Modes.Filtering.GetPath()) return gui.postRefreshUpdate(gui.State.Contexts.Stash) diff --git a/pkg/gui/remote_branches_panel.go b/pkg/gui/remote_branches_panel.go index a611eb5c4..0c00f8d80 100644 --- a/pkg/gui/remote_branches_panel.go +++ b/pkg/gui/remote_branches_panel.go @@ -13,11 +13,11 @@ import ( func (gui *Gui) getSelectedRemoteBranch() *models.RemoteBranch { selectedLine := gui.State.Panels.RemoteBranches.SelectedLineIdx - if selectedLine == -1 || len(gui.State.RemoteBranches) == 0 { + if selectedLine == -1 || len(gui.State.Model.RemoteBranches) == 0 { return nil } - return gui.State.RemoteBranches[selectedLine] + return gui.State.Model.RemoteBranches[selectedLine] } func (gui *Gui) remoteBranchesRenderToMain() error { @@ -108,7 +108,7 @@ func (gui *Gui) handleCreateResetToRemoteBranchMenu() error { return nil } - return gui.helpers.refs.CreateGitResetMenu(selectedBranch.FullName()) + return gui.helpers.Refs.CreateGitResetMenu(selectedBranch.FullName()) } func (gui *Gui) handleEnterRemoteBranch() error { @@ -129,5 +129,5 @@ func (gui *Gui) handleNewBranchOffRemoteBranch() error { // will set to the remote's branch name without the remote name nameSuggestion := strings.SplitAfterN(selectedBranch.RefName(), "/", 2)[1] - return gui.helpers.refs.NewBranch(selectedBranch.RefName(), selectedBranch.RefName(), nameSuggestion) + return gui.helpers.Refs.NewBranch(selectedBranch.RefName(), selectedBranch.RefName(), nameSuggestion) } diff --git a/pkg/gui/remotes_panel.go b/pkg/gui/remotes_panel.go index 8e55cd33b..1273ee6ad 100644 --- a/pkg/gui/remotes_panel.go +++ b/pkg/gui/remotes_panel.go @@ -12,11 +12,11 @@ import ( func (gui *Gui) getSelectedRemote() *models.Remote { selectedLine := gui.State.Panels.Remotes.SelectedLineIdx - if selectedLine == -1 || len(gui.State.Remotes) == 0 { + if selectedLine == -1 || len(gui.State.Model.Remotes) == 0 { return nil } - return gui.State.Remotes[selectedLine] + return gui.State.Model.Remotes[selectedLine] } func (gui *Gui) remotesRenderToMain() error { diff --git a/pkg/gui/stash_panel.go b/pkg/gui/stash_panel.go index 9b7b03bb5..ed68d3cd4 100644 --- a/pkg/gui/stash_panel.go +++ b/pkg/gui/stash_panel.go @@ -14,7 +14,7 @@ func (gui *Gui) getSelectedStashEntry() *models.StashEntry { return nil } - return gui.State.StashEntries[selectedLine] + return gui.State.Model.StashEntries[selectedLine] } func (gui *Gui) stashRenderToMain() error { @@ -143,5 +143,5 @@ func (gui *Gui) handleNewBranchOffStashEntry() error { return nil } - return gui.helpers.refs.NewBranch(stashEntry.RefName(), stashEntry.Description(), "") + return gui.helpers.Refs.NewBranch(stashEntry.RefName(), stashEntry.Description(), "") } diff --git a/pkg/gui/status_panel.go b/pkg/gui/status_panel.go index 40a7f92b7..fd1d75133 100644 --- a/pkg/gui/status_panel.go +++ b/pkg/gui/status_panel.go @@ -48,7 +48,7 @@ func (gui *Gui) handleStatusClick() error { case enums.REBASE_MODE_REBASING, enums.REBASE_MODE_MERGING: workingTreeStatus := fmt.Sprintf("(%s)", formatWorkingTreeState(workingTreeState)) if cursorInSubstring(cx, upstreamStatus+" ", workingTreeStatus) { - return gui.helpers.rebase.CreateRebaseOptionsMenu() + return gui.helpers.Rebase.CreateRebaseOptionsMenu() } if cursorInSubstring(cx, upstreamStatus+" "+workingTreeStatus+" ", repoName) { return gui.handleCreateRecentReposMenu() @@ -122,11 +122,11 @@ func (gui *Gui) askForConfigFile(action func(file string) error) error { } func (gui *Gui) handleOpenConfig() error { - return gui.askForConfigFile(gui.helpers.files.OpenFile) + return gui.askForConfigFile(gui.helpers.Files.OpenFile) } func (gui *Gui) handleEditConfig() error { - return gui.askForConfigFile(gui.helpers.files.EditFile) + return gui.askForConfigFile(gui.helpers.Files.EditFile) } func lazygitTitle() string { diff --git a/pkg/gui/sub_commits_panel.go b/pkg/gui/sub_commits_panel.go index 5d81d5a9c..a5756649f 100644 --- a/pkg/gui/sub_commits_panel.go +++ b/pkg/gui/sub_commits_panel.go @@ -11,7 +11,7 @@ import ( func (gui *Gui) getSelectedSubCommit() *models.Commit { selectedLine := gui.State.Panels.SubCommits.SelectedLineIdx - commits := gui.State.SubCommits + commits := gui.State.Model.SubCommits if selectedLine == -1 || len(commits) == 0 { return nil } @@ -49,7 +49,7 @@ func (gui *Gui) handleCheckoutSubCommit() error { Prompt: gui.c.Tr.SureCheckoutThisCommit, HandleConfirm: func() error { gui.c.LogAction(gui.c.Tr.Actions.CheckoutCommit) - return gui.helpers.refs.CheckoutRef(commit.Sha, types.CheckoutRefOptions{}) + return gui.helpers.Refs.CheckoutRef(commit.Sha, types.CheckoutRefOptions{}) }, }) if err != nil { @@ -64,7 +64,7 @@ func (gui *Gui) handleCheckoutSubCommit() error { func (gui *Gui) handleCreateSubCommitResetMenu() error { commit := gui.getSelectedSubCommit() - return gui.helpers.refs.CreateGitResetMenu(commit.Sha) + return gui.helpers.Refs.CreateGitResetMenu(commit.Sha) } func (gui *Gui) handleViewSubCommitFiles() error { @@ -95,7 +95,7 @@ func (gui *Gui) switchToSubCommitsContext(refName string) error { return err } - gui.State.SubCommits = commits + gui.State.Model.SubCommits = commits gui.State.Panels.SubCommits.refName = refName gui.State.Contexts.SubCommits.GetPanelState().SetSelectedLineIdx(0) gui.State.Contexts.SubCommits.SetParentContext(gui.currentSideListContext()) @@ -109,7 +109,7 @@ func (gui *Gui) handleNewBranchOffSubCommit() error { return nil } - return gui.helpers.refs.NewBranch(commit.RefName(), commit.Description(), "") + return gui.helpers.Refs.NewBranch(commit.RefName(), commit.Description(), "") } func (gui *Gui) handleCopySubCommit() error { @@ -118,7 +118,7 @@ func (gui *Gui) handleCopySubCommit() error { return nil } - return gui.helpers.cherryPick.Copy(commit, gui.State.SubCommits, gui.State.Contexts.SubCommits) + return gui.helpers.CherryPick.Copy(commit, gui.State.Model.SubCommits, gui.State.Contexts.SubCommits) } func (gui *Gui) handleCopySubCommitRange() error { @@ -128,5 +128,5 @@ func (gui *Gui) handleCopySubCommitRange() error { return nil } - return gui.helpers.cherryPick.CopyRange(gui.State.Contexts.SubCommits.GetPanelState().GetSelectedLineIdx(), gui.State.SubCommits, gui.State.Contexts.SubCommits) + return gui.helpers.CherryPick.CopyRange(gui.State.Contexts.SubCommits.GetPanelState().GetSelectedLineIdx(), gui.State.Model.SubCommits, gui.State.Contexts.SubCommits) } diff --git a/pkg/gui/submodules_panel.go b/pkg/gui/submodules_panel.go index 297887207..490347c5d 100644 --- a/pkg/gui/submodules_panel.go +++ b/pkg/gui/submodules_panel.go @@ -10,11 +10,11 @@ import ( func (gui *Gui) getSelectedSubmodule() *models.SubmoduleConfig { selectedLine := gui.State.Panels.Submodules.SelectedLineIdx - if selectedLine == -1 || len(gui.State.Submodules) == 0 { + if selectedLine == -1 || len(gui.State.Model.Submodules) == 0 { return nil } - return gui.State.Submodules[selectedLine] + return gui.State.Model.Submodules[selectedLine] } func (gui *Gui) submodulesRenderToMain() error { @@ -30,7 +30,7 @@ func (gui *Gui) submodulesRenderToMain() error { style.FgCyan.Sprint(submodule.Url), ) - file := gui.helpers.workingTree.FileForSubmodule(submodule) + file := gui.helpers.WorkingTree.FileForSubmodule(submodule) if file == nil { task = NewRenderStringTask(prefix) } else { diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go index 4dbb0eca3..748a2484b 100644 --- a/pkg/gui/types/common.go +++ b/pkg/gui/types/common.go @@ -1,9 +1,12 @@ package types import ( + "github.com/jesseduffield/lazygit/pkg/commands/git_commands" + "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/config" + "gopkg.in/ozeidan/fuzzy-patricia.v3/patricia" ) type ControllerCommon struct { @@ -90,3 +93,29 @@ type MenuItem struct { // only applies when displayString is used OpensMenu bool } + +type Model struct { + CommitFiles []*models.CommitFile + Files []*models.File + Submodules []*models.SubmoduleConfig + Branches []*models.Branch + Commits []*models.Commit + StashEntries []*models.StashEntry + SubCommits []*models.Commit + Remotes []*models.Remote + + // FilteredReflogCommits are the ones that appear in the reflog panel. + // when in filtering mode we only include the ones that match the given path + FilteredReflogCommits []*models.Commit + // ReflogCommits are the ones used by the branches panel to obtain recency values + // if we're not in filtering mode, CommitFiles and FilteredReflogCommits will be + // one and the same + ReflogCommits []*models.Commit + + BisectInfo *git_commands.BisectInfo + RemoteBranches []*models.RemoteBranch + Tags []*models.Tag + + // for displaying suggestions while typing in a file name + FilesTrie *patricia.Trie +} diff --git a/pkg/gui/workspace_reset_options_panel.go b/pkg/gui/workspace_reset_options_panel.go index 205f8b9dd..97984029f 100644 --- a/pkg/gui/workspace_reset_options_panel.go +++ b/pkg/gui/workspace_reset_options_panel.go @@ -11,7 +11,7 @@ func (gui *Gui) handleCreateResetMenu() error { red := style.FgRed nukeStr := "reset --hard HEAD && git clean -fd" - if len(gui.State.Submodules) > 0 { + if len(gui.State.Model.Submodules) > 0 { nukeStr = fmt.Sprintf("%s (%s)", nukeStr, gui.c.Tr.LcAndResetSubmodules) } diff --git a/vendor/github.com/go-errors/errors/README.md b/vendor/github.com/go-errors/errors/README.md index 2ee13f117..3d7852594 100644 --- a/vendor/github.com/go-errors/errors/README.md +++ b/vendor/github.com/go-errors/errors/README.md @@ -79,3 +79,4 @@ This package is licensed under the MIT license, see LICENSE.MIT for details. > ``` * v1.4.0 *BREAKING* v1.4.0 reverted all changes from v1.3.0 and is identical to v1.2.0 * v1.4.1 no code change, but now without an unnecessary cover.out file. +* v1.4.2 performance improvement to ErrorStack() to avoid unnecessary work https://github.com/go-errors/errors/pull/40 diff --git a/vendor/github.com/go-errors/errors/stackframe.go b/vendor/github.com/go-errors/errors/stackframe.go index f420849d2..ef4a8b3f3 100644 --- a/vendor/github.com/go-errors/errors/stackframe.go +++ b/vendor/github.com/go-errors/errors/stackframe.go @@ -53,7 +53,7 @@ func (frame *StackFrame) Func() *runtime.Func { func (frame *StackFrame) String() string { str := fmt.Sprintf("%s:%d (0x%x)\n", frame.File, frame.LineNumber, frame.ProgramCounter) - source, err := frame.SourceLine() + source, err := frame.sourceLine() if err != nil { return str } @@ -63,13 +63,21 @@ func (frame *StackFrame) String() string { // SourceLine gets the line of code (from File and Line) of the original source if possible. func (frame *StackFrame) SourceLine() (string, error) { + source, err := frame.sourceLine() + if err != nil { + return source, New(err) + } + return source, err +} + +func (frame *StackFrame) sourceLine() (string, error) { if frame.LineNumber <= 0 { return "???", nil } file, err := os.Open(frame.File) if err != nil { - return "", New(err) + return "", err } defer file.Close() @@ -82,7 +90,7 @@ func (frame *StackFrame) SourceLine() (string, error) { currentLine++ } if err := scanner.Err(); err != nil { - return "", New(err) + return "", err } return "???", nil diff --git a/vendor/github.com/jesseduffield/gocui/gui.go b/vendor/github.com/jesseduffield/gocui/gui.go index 86d1393bd..1c3b4a9cb 100644 --- a/vendor/github.com/jesseduffield/gocui/gui.go +++ b/vendor/github.com/jesseduffield/gocui/gui.go @@ -469,7 +469,13 @@ func (g *Gui) DeleteKeybinding(viewname string, key interface{}, mod Modifier) e } // DeleteKeybindings deletes all keybindings of view. -func (g *Gui) DeleteKeybindings(viewname string) { +func (g *Gui) DeleteAllKeybindings() { + g.keybindings = []*keybinding{} + g.tabClickBindings = []*tabClickBinding{} +} + +// DeleteKeybindings deletes all keybindings of view. +func (g *Gui) DeleteViewKeybindings(viewname string) { var s []*keybinding for _, kb := range g.keybindings { if kb.viewName != viewname { diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index bcc45d108..4e5420586 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -741,6 +741,7 @@ const ( ETH_P_QINQ2 = 0x9200 ETH_P_QINQ3 = 0x9300 ETH_P_RARP = 0x8035 + ETH_P_REALTEK = 0x8899 ETH_P_SCA = 0x6007 ETH_P_SLOW = 0x8809 ETH_P_SNAP = 0x5 @@ -810,10 +811,12 @@ const ( FAN_EPIDFD = -0x2 FAN_EVENT_INFO_TYPE_DFID = 0x3 FAN_EVENT_INFO_TYPE_DFID_NAME = 0x2 + FAN_EVENT_INFO_TYPE_ERROR = 0x5 FAN_EVENT_INFO_TYPE_FID = 0x1 FAN_EVENT_INFO_TYPE_PIDFD = 0x4 FAN_EVENT_METADATA_LEN = 0x18 FAN_EVENT_ON_CHILD = 0x8000000 + FAN_FS_ERROR = 0x8000 FAN_MARK_ADD = 0x1 FAN_MARK_DONT_FOLLOW = 0x4 FAN_MARK_FILESYSTEM = 0x100 @@ -1827,6 +1830,8 @@ const ( PERF_MEM_BLK_DATA = 0x2 PERF_MEM_BLK_NA = 0x1 PERF_MEM_BLK_SHIFT = 0x28 + PERF_MEM_HOPS_0 = 0x1 + PERF_MEM_HOPS_SHIFT = 0x2b PERF_MEM_LOCK_LOCKED = 0x2 PERF_MEM_LOCK_NA = 0x1 PERF_MEM_LOCK_SHIFT = 0x18 @@ -1986,6 +1991,9 @@ const ( PR_SCHED_CORE_CREATE = 0x1 PR_SCHED_CORE_GET = 0x0 PR_SCHED_CORE_MAX = 0x4 + PR_SCHED_CORE_SCOPE_PROCESS_GROUP = 0x2 + PR_SCHED_CORE_SCOPE_THREAD = 0x0 + PR_SCHED_CORE_SCOPE_THREAD_GROUP = 0x1 PR_SCHED_CORE_SHARE_FROM = 0x3 PR_SCHED_CORE_SHARE_TO = 0x2 PR_SET_CHILD_SUBREAPER = 0x24 @@ -2167,12 +2175,23 @@ const ( RTCF_NAT = 0x800000 RTCF_VALVE = 0x200000 RTC_AF = 0x20 + RTC_BSM_DIRECT = 0x1 + RTC_BSM_DISABLED = 0x0 + RTC_BSM_LEVEL = 0x2 + RTC_BSM_STANDBY = 0x3 RTC_FEATURE_ALARM = 0x0 + RTC_FEATURE_ALARM_RES_2S = 0x3 RTC_FEATURE_ALARM_RES_MINUTE = 0x1 - RTC_FEATURE_CNT = 0x3 + RTC_FEATURE_BACKUP_SWITCH_MODE = 0x6 + RTC_FEATURE_CNT = 0x7 + RTC_FEATURE_CORRECTION = 0x5 RTC_FEATURE_NEED_WEEK_DAY = 0x2 + RTC_FEATURE_UPDATE_INTERRUPT = 0x4 RTC_IRQF = 0x80 RTC_MAX_FREQ = 0x2000 + RTC_PARAM_BACKUP_SWITCH_MODE = 0x2 + RTC_PARAM_CORRECTION = 0x1 + RTC_PARAM_FEATURES = 0x0 RTC_PF = 0x40 RTC_UF = 0x10 RTF_ADDRCLASSMASK = 0xf8000000 @@ -2532,6 +2551,8 @@ const ( SO_VM_SOCKETS_BUFFER_MIN_SIZE = 0x1 SO_VM_SOCKETS_BUFFER_SIZE = 0x0 SO_VM_SOCKETS_CONNECT_TIMEOUT = 0x6 + SO_VM_SOCKETS_CONNECT_TIMEOUT_NEW = 0x8 + SO_VM_SOCKETS_CONNECT_TIMEOUT_OLD = 0x6 SO_VM_SOCKETS_NONBLOCK_TXRX = 0x7 SO_VM_SOCKETS_PEER_HOST_VM_ID = 0x3 SO_VM_SOCKETS_TRUSTED = 0x5 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index 3ca40ca7f..234fd4a5d 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -250,6 +250,8 @@ const ( RTC_EPOCH_SET = 0x4004700e RTC_IRQP_READ = 0x8004700b RTC_IRQP_SET = 0x4004700c + RTC_PARAM_GET = 0x40187013 + RTC_PARAM_SET = 0x40187014 RTC_PIE_OFF = 0x7006 RTC_PIE_ON = 0x7005 RTC_PLL_GET = 0x801c7011 @@ -327,6 +329,7 @@ const ( SO_RCVTIMEO = 0x14 SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_OLD = 0x14 + SO_RESERVE_MEM = 0x49 SO_REUSEADDR = 0x2 SO_REUSEPORT = 0xf SO_RXQ_OVFL = 0x28 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index ead332091..58619b758 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -251,6 +251,8 @@ const ( RTC_EPOCH_SET = 0x4008700e RTC_IRQP_READ = 0x8008700b RTC_IRQP_SET = 0x4008700c + RTC_PARAM_GET = 0x40187013 + RTC_PARAM_SET = 0x40187014 RTC_PIE_OFF = 0x7006 RTC_PIE_ON = 0x7005 RTC_PLL_GET = 0x80207011 @@ -328,6 +330,7 @@ const ( SO_RCVTIMEO = 0x14 SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_OLD = 0x14 + SO_RESERVE_MEM = 0x49 SO_REUSEADDR = 0x2 SO_REUSEPORT = 0xf SO_RXQ_OVFL = 0x28 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 39bdc9455..3a64ff59d 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -257,6 +257,8 @@ const ( RTC_EPOCH_SET = 0x4004700e RTC_IRQP_READ = 0x8004700b RTC_IRQP_SET = 0x4004700c + RTC_PARAM_GET = 0x40187013 + RTC_PARAM_SET = 0x40187014 RTC_PIE_OFF = 0x7006 RTC_PIE_ON = 0x7005 RTC_PLL_GET = 0x801c7011 @@ -334,6 +336,7 @@ const ( SO_RCVTIMEO = 0x14 SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_OLD = 0x14 + SO_RESERVE_MEM = 0x49 SO_REUSEADDR = 0x2 SO_REUSEPORT = 0xf SO_RXQ_OVFL = 0x28 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 9aec987db..abe0b9257 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -247,6 +247,8 @@ const ( RTC_EPOCH_SET = 0x4008700e RTC_IRQP_READ = 0x8008700b RTC_IRQP_SET = 0x4008700c + RTC_PARAM_GET = 0x40187013 + RTC_PARAM_SET = 0x40187014 RTC_PIE_OFF = 0x7006 RTC_PIE_ON = 0x7005 RTC_PLL_GET = 0x80207011 @@ -324,6 +326,7 @@ const ( SO_RCVTIMEO = 0x14 SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_OLD = 0x14 + SO_RESERVE_MEM = 0x49 SO_REUSEADDR = 0x2 SO_REUSEPORT = 0xf SO_RXQ_OVFL = 0x28 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index a8bba9491..14d7a8439 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -250,6 +250,8 @@ const ( RTC_EPOCH_SET = 0x8004700e RTC_IRQP_READ = 0x4004700b RTC_IRQP_SET = 0x8004700c + RTC_PARAM_GET = 0x80187013 + RTC_PARAM_SET = 0x80187014 RTC_PIE_OFF = 0x20007006 RTC_PIE_ON = 0x20007005 RTC_PLL_GET = 0x401c7011 @@ -327,6 +329,7 @@ const ( SO_RCVTIMEO = 0x1006 SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_OLD = 0x1006 + SO_RESERVE_MEM = 0x49 SO_REUSEADDR = 0x4 SO_REUSEPORT = 0x200 SO_RXQ_OVFL = 0x28 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index ee9e7e202..99e7c4ac0 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -250,6 +250,8 @@ const ( RTC_EPOCH_SET = 0x8008700e RTC_IRQP_READ = 0x4008700b RTC_IRQP_SET = 0x8008700c + RTC_PARAM_GET = 0x80187013 + RTC_PARAM_SET = 0x80187014 RTC_PIE_OFF = 0x20007006 RTC_PIE_ON = 0x20007005 RTC_PLL_GET = 0x40207011 @@ -327,6 +329,7 @@ const ( SO_RCVTIMEO = 0x1006 SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_OLD = 0x1006 + SO_RESERVE_MEM = 0x49 SO_REUSEADDR = 0x4 SO_REUSEPORT = 0x200 SO_RXQ_OVFL = 0x28 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index ba4b288a3..496364c33 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -250,6 +250,8 @@ const ( RTC_EPOCH_SET = 0x8008700e RTC_IRQP_READ = 0x4008700b RTC_IRQP_SET = 0x8008700c + RTC_PARAM_GET = 0x80187013 + RTC_PARAM_SET = 0x80187014 RTC_PIE_OFF = 0x20007006 RTC_PIE_ON = 0x20007005 RTC_PLL_GET = 0x40207011 @@ -327,6 +329,7 @@ const ( SO_RCVTIMEO = 0x1006 SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_OLD = 0x1006 + SO_RESERVE_MEM = 0x49 SO_REUSEADDR = 0x4 SO_REUSEPORT = 0x200 SO_RXQ_OVFL = 0x28 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index bc93afc36..3e4083085 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -250,6 +250,8 @@ const ( RTC_EPOCH_SET = 0x8004700e RTC_IRQP_READ = 0x4004700b RTC_IRQP_SET = 0x8004700c + RTC_PARAM_GET = 0x80187013 + RTC_PARAM_SET = 0x80187014 RTC_PIE_OFF = 0x20007006 RTC_PIE_ON = 0x20007005 RTC_PLL_GET = 0x401c7011 @@ -327,6 +329,7 @@ const ( SO_RCVTIMEO = 0x1006 SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_OLD = 0x1006 + SO_RESERVE_MEM = 0x49 SO_REUSEADDR = 0x4 SO_REUSEPORT = 0x200 SO_RXQ_OVFL = 0x28 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 9295e6947..1151a7dfa 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -305,6 +305,8 @@ const ( RTC_EPOCH_SET = 0x8004700e RTC_IRQP_READ = 0x4004700b RTC_IRQP_SET = 0x8004700c + RTC_PARAM_GET = 0x80187013 + RTC_PARAM_SET = 0x80187014 RTC_PIE_OFF = 0x20007006 RTC_PIE_ON = 0x20007005 RTC_PLL_GET = 0x401c7011 @@ -382,6 +384,7 @@ const ( SO_RCVTIMEO = 0x12 SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_OLD = 0x12 + SO_RESERVE_MEM = 0x49 SO_REUSEADDR = 0x2 SO_REUSEPORT = 0xf SO_RXQ_OVFL = 0x28 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index 1fa081c9a..ed17f249e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -309,6 +309,8 @@ const ( RTC_EPOCH_SET = 0x8008700e RTC_IRQP_READ = 0x4008700b RTC_IRQP_SET = 0x8008700c + RTC_PARAM_GET = 0x80187013 + RTC_PARAM_SET = 0x80187014 RTC_PIE_OFF = 0x20007006 RTC_PIE_ON = 0x20007005 RTC_PLL_GET = 0x40207011 @@ -386,6 +388,7 @@ const ( SO_RCVTIMEO = 0x12 SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_OLD = 0x12 + SO_RESERVE_MEM = 0x49 SO_REUSEADDR = 0x2 SO_REUSEPORT = 0xf SO_RXQ_OVFL = 0x28 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index 74b321149..d84a37c1a 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -309,6 +309,8 @@ const ( RTC_EPOCH_SET = 0x8008700e RTC_IRQP_READ = 0x4008700b RTC_IRQP_SET = 0x8008700c + RTC_PARAM_GET = 0x80187013 + RTC_PARAM_SET = 0x80187014 RTC_PIE_OFF = 0x20007006 RTC_PIE_ON = 0x20007005 RTC_PLL_GET = 0x40207011 @@ -386,6 +388,7 @@ const ( SO_RCVTIMEO = 0x12 SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_OLD = 0x12 + SO_RESERVE_MEM = 0x49 SO_REUSEADDR = 0x2 SO_REUSEPORT = 0xf SO_RXQ_OVFL = 0x28 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index c91c8ac5b..5cafba83f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -238,6 +238,8 @@ const ( RTC_EPOCH_SET = 0x4008700e RTC_IRQP_READ = 0x8008700b RTC_IRQP_SET = 0x4008700c + RTC_PARAM_GET = 0x40187013 + RTC_PARAM_SET = 0x40187014 RTC_PIE_OFF = 0x7006 RTC_PIE_ON = 0x7005 RTC_PLL_GET = 0x80207011 @@ -315,6 +317,7 @@ const ( SO_RCVTIMEO = 0x14 SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_OLD = 0x14 + SO_RESERVE_MEM = 0x49 SO_REUSEADDR = 0x2 SO_REUSEPORT = 0xf SO_RXQ_OVFL = 0x28 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index b66bf2228..6d122da41 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -313,6 +313,8 @@ const ( RTC_EPOCH_SET = 0x4008700e RTC_IRQP_READ = 0x8008700b RTC_IRQP_SET = 0x4008700c + RTC_PARAM_GET = 0x40187013 + RTC_PARAM_SET = 0x40187014 RTC_PIE_OFF = 0x7006 RTC_PIE_ON = 0x7005 RTC_PLL_GET = 0x80207011 @@ -390,6 +392,7 @@ const ( SO_RCVTIMEO = 0x14 SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_OLD = 0x14 + SO_RESERVE_MEM = 0x49 SO_REUSEADDR = 0x2 SO_REUSEPORT = 0xf SO_RXQ_OVFL = 0x28 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index f7fb149b0..6bd19e51d 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -304,6 +304,8 @@ const ( RTC_EPOCH_SET = 0x8008700e RTC_IRQP_READ = 0x4008700b RTC_IRQP_SET = 0x8008700c + RTC_PARAM_GET = 0x80187013 + RTC_PARAM_SET = 0x80187014 RTC_PIE_OFF = 0x20007006 RTC_PIE_ON = 0x20007005 RTC_PLL_GET = 0x40207011 @@ -381,6 +383,7 @@ const ( SO_RCVTIMEO = 0x2000 SO_RCVTIMEO_NEW = 0x44 SO_RCVTIMEO_OLD = 0x2000 + SO_RESERVE_MEM = 0x52 SO_REUSEADDR = 0x4 SO_REUSEPORT = 0x200 SO_RXQ_OVFL = 0x24 diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index 31847d230..cac1f758b 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -445,4 +445,5 @@ const ( SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_MEMFD_SECRET = 447 SYS_PROCESS_MRELEASE = 448 + SYS_FUTEX_WAITV = 449 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index 3503cbbde..f327e4a0b 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -367,4 +367,5 @@ const ( SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_MEMFD_SECRET = 447 SYS_PROCESS_MRELEASE = 448 + SYS_FUTEX_WAITV = 449 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index 5ecd24bf6..fb06a08d4 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -409,4 +409,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_PROCESS_MRELEASE = 448 + SYS_FUTEX_WAITV = 449 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index 7e5c94cc7..58285646e 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -312,4 +312,5 @@ const ( SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_MEMFD_SECRET = 447 SYS_PROCESS_MRELEASE = 448 + SYS_FUTEX_WAITV = 449 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index e1e2a2bf5..3b0418e68 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -429,4 +429,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 4445 SYS_LANDLOCK_RESTRICT_SELF = 4446 SYS_PROCESS_MRELEASE = 4448 + SYS_FUTEX_WAITV = 4449 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 7651915a3..314ebf166 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -359,4 +359,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 5445 SYS_LANDLOCK_RESTRICT_SELF = 5446 SYS_PROCESS_MRELEASE = 5448 + SYS_FUTEX_WAITV = 5449 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index a26a2c050..b8fbb937a 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -359,4 +359,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 5445 SYS_LANDLOCK_RESTRICT_SELF = 5446 SYS_PROCESS_MRELEASE = 5448 + SYS_FUTEX_WAITV = 5449 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index fda9a6a99..ee309b2ba 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -429,4 +429,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 4445 SYS_LANDLOCK_RESTRICT_SELF = 4446 SYS_PROCESS_MRELEASE = 4448 + SYS_FUTEX_WAITV = 4449 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index e8496150d..ac3748104 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -436,4 +436,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_PROCESS_MRELEASE = 448 + SYS_FUTEX_WAITV = 449 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index 5ee0678a3..5aa472111 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -408,4 +408,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_PROCESS_MRELEASE = 448 + SYS_FUTEX_WAITV = 449 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index 29c0f9a39..0793ac1a6 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -408,4 +408,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_PROCESS_MRELEASE = 448 + SYS_FUTEX_WAITV = 449 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index 5c9a9a3b6..a520962e3 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -310,4 +310,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_PROCESS_MRELEASE = 448 + SYS_FUTEX_WAITV = 449 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 913f50f98..d1738586b 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -373,4 +373,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_PROCESS_MRELEASE = 448 + SYS_FUTEX_WAITV = 449 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 0de03a722..dfd5660f9 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -387,4 +387,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_PROCESS_MRELEASE = 448 + SYS_FUTEX_WAITV = 449 ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index f6f0d79c4..66788f156 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -1144,7 +1144,8 @@ const ( PERF_RECORD_BPF_EVENT = 0x12 PERF_RECORD_CGROUP = 0x13 PERF_RECORD_TEXT_POKE = 0x14 - PERF_RECORD_MAX = 0x15 + PERF_RECORD_AUX_OUTPUT_HW_ID = 0x15 + PERF_RECORD_MAX = 0x16 PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0x0 PERF_RECORD_KSYMBOL_TYPE_BPF = 0x1 PERF_RECORD_KSYMBOL_TYPE_OOL = 0x2 @@ -1784,7 +1785,8 @@ const ( const ( NF_NETDEV_INGRESS = 0x0 - NF_NETDEV_NUMHOOKS = 0x1 + NF_NETDEV_EGRESS = 0x1 + NF_NETDEV_NUMHOOKS = 0x2 ) const ( @@ -3166,7 +3168,13 @@ const ( DEVLINK_ATTR_RELOAD_ACTION_INFO = 0xa2 DEVLINK_ATTR_RELOAD_ACTION_STATS = 0xa3 DEVLINK_ATTR_PORT_PCI_SF_NUMBER = 0xa4 - DEVLINK_ATTR_MAX = 0xa9 + DEVLINK_ATTR_RATE_TYPE = 0xa5 + DEVLINK_ATTR_RATE_TX_SHARE = 0xa6 + DEVLINK_ATTR_RATE_TX_MAX = 0xa7 + DEVLINK_ATTR_RATE_NODE_NAME = 0xa8 + DEVLINK_ATTR_RATE_PARENT_NODE_NAME = 0xa9 + DEVLINK_ATTR_REGION_MAX_SNAPSHOTS = 0xaa + DEVLINK_ATTR_MAX = 0xaa DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE = 0x0 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX = 0x1 DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT = 0x0 @@ -3463,7 +3471,14 @@ const ( ETHTOOL_MSG_CABLE_TEST_ACT = 0x1a ETHTOOL_MSG_CABLE_TEST_TDR_ACT = 0x1b ETHTOOL_MSG_TUNNEL_INFO_GET = 0x1c - ETHTOOL_MSG_USER_MAX = 0x21 + ETHTOOL_MSG_FEC_GET = 0x1d + ETHTOOL_MSG_FEC_SET = 0x1e + ETHTOOL_MSG_MODULE_EEPROM_GET = 0x1f + ETHTOOL_MSG_STATS_GET = 0x20 + ETHTOOL_MSG_PHC_VCLOCKS_GET = 0x21 + ETHTOOL_MSG_MODULE_GET = 0x22 + ETHTOOL_MSG_MODULE_SET = 0x23 + ETHTOOL_MSG_USER_MAX = 0x23 ETHTOOL_MSG_KERNEL_NONE = 0x0 ETHTOOL_MSG_STRSET_GET_REPLY = 0x1 ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2 @@ -3494,7 +3509,14 @@ const ( ETHTOOL_MSG_CABLE_TEST_NTF = 0x1b ETHTOOL_MSG_CABLE_TEST_TDR_NTF = 0x1c ETHTOOL_MSG_TUNNEL_INFO_GET_REPLY = 0x1d - ETHTOOL_MSG_KERNEL_MAX = 0x22 + ETHTOOL_MSG_FEC_GET_REPLY = 0x1e + ETHTOOL_MSG_FEC_NTF = 0x1f + ETHTOOL_MSG_MODULE_EEPROM_GET_REPLY = 0x20 + ETHTOOL_MSG_STATS_GET_REPLY = 0x21 + ETHTOOL_MSG_PHC_VCLOCKS_GET_REPLY = 0x22 + ETHTOOL_MSG_MODULE_GET_REPLY = 0x23 + ETHTOOL_MSG_MODULE_NTF = 0x24 + ETHTOOL_MSG_KERNEL_MAX = 0x24 ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_NAME = 0x2 diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index 200b62a00..cf44e6933 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -363,6 +363,8 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys SetProcessWorkingSetSizeEx(hProcess Handle, dwMinimumWorkingSetSize uintptr, dwMaximumWorkingSetSize uintptr, flags uint32) (err error) //sys GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) //sys SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) +//sys GetActiveProcessorCount(groupNumber uint16) (ret uint32) +//sys GetMaximumProcessorCount(groupNumber uint16) (ret uint32) // Volume Management Functions //sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go index bb31abda4..e19471c6a 100644 --- a/vendor/golang.org/x/sys/windows/types_windows.go +++ b/vendor/golang.org/x/sys/windows/types_windows.go @@ -3172,3 +3172,5 @@ type ModuleInfo struct { SizeOfImage uint32 EntryPoint uintptr } + +const ALL_PROCESSOR_GROUPS = 0xFFFF diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index 1055d47ed..9ea1a44f0 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -226,6 +226,7 @@ var ( procFreeLibrary = modkernel32.NewProc("FreeLibrary") procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent") procGetACP = modkernel32.NewProc("GetACP") + procGetActiveProcessorCount = modkernel32.NewProc("GetActiveProcessorCount") procGetCommTimeouts = modkernel32.NewProc("GetCommTimeouts") procGetCommandLineW = modkernel32.NewProc("GetCommandLineW") procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") @@ -251,6 +252,7 @@ var ( procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW") procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives") procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW") + procGetMaximumProcessorCount = modkernel32.NewProc("GetMaximumProcessorCount") procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW") procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW") procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW") @@ -1967,6 +1969,12 @@ func GetACP() (acp uint32) { return } +func GetActiveProcessorCount(groupNumber uint16) (ret uint32) { + r0, _, _ := syscall.Syscall(procGetActiveProcessorCount.Addr(), 1, uintptr(groupNumber), 0, 0) + ret = uint32(r0) + return +} + func GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) { r1, _, e1 := syscall.Syscall(procGetCommTimeouts.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(timeouts)), 0) if r1 == 0 { @@ -2169,6 +2177,12 @@ func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err er return } +func GetMaximumProcessorCount(groupNumber uint16) (ret uint32) { + r0, _, _ := syscall.Syscall(procGetMaximumProcessorCount.Addr(), 1, uintptr(groupNumber), 0, 0) + ret = uint32(r0) + return +} + func GetModuleFileName(module Handle, filename *uint16, size uint32) (n uint32, err error) { r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(filename)), uintptr(size)) n = uint32(r0) diff --git a/vendor/modules.txt b/vendor/modules.txt index 61e66d73c..417adb1dc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -74,7 +74,7 @@ github.com/gdamore/tcell/v2/terminfo/x/xfce github.com/gdamore/tcell/v2/terminfo/x/xterm github.com/gdamore/tcell/v2/terminfo/x/xterm_kitty github.com/gdamore/tcell/v2/terminfo/x/xterm_termite -# github.com/go-errors/errors v1.4.1 +# github.com/go-errors/errors v1.4.2 ## explicit github.com/go-errors/errors # github.com/go-git/gcfg v1.5.0 @@ -159,7 +159,7 @@ github.com/jesseduffield/go-git/v5/utils/merkletrie/filesystem github.com/jesseduffield/go-git/v5/utils/merkletrie/index github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame github.com/jesseduffield/go-git/v5/utils/merkletrie/noder -# github.com/jesseduffield/gocui v0.3.1-0.20220108045521-1945d7b9ed8b +# github.com/jesseduffield/gocui v0.3.1-0.20220131110921-82fe47ec96ba ## explicit github.com/jesseduffield/gocui # github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e @@ -255,7 +255,7 @@ golang.org/x/crypto/ssh/knownhosts golang.org/x/net/context golang.org/x/net/internal/socks golang.org/x/net/proxy -# golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e +# golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 ## explicit golang.org/x/sys/cpu golang.org/x/sys/internal/unsafeheader