summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-02-05 17:04:10 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-17 19:13:40 +1100
commitd82f175e79f18756769d91de94458b095130297c (patch)
tree63c0c5b17a698a5a202a85b930edd0cf9e85ebf7 /pkg/gui
parent145c69d9ae32ec8fbdd6d1e6116efec466a0a709 (diff)
refactor contexts
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/branches_panel.go55
-rw-r--r--pkg/gui/commit_files_panel.go26
-rw-r--r--pkg/gui/commits_panel.go14
-rw-r--r--pkg/gui/confirmation_panel.go32
-rw-r--r--pkg/gui/context.go1
-rw-r--r--pkg/gui/context/branches_context.go86
-rw-r--r--pkg/gui/context/commit_files_context.go58
-rw-r--r--pkg/gui/context/context.go32
-rw-r--r--pkg/gui/context/list_context_trait.go192
-rw-r--r--pkg/gui/context/local_commits_context.go87
-rw-r--r--pkg/gui/context/menu_context.go108
-rw-r--r--pkg/gui/context/reflog_commits_context.go86
-rw-r--r--pkg/gui/context/remote_branches_context.go86
-rw-r--r--pkg/gui/context/remotes_context.go86
-rw-r--r--pkg/gui/context/simple_context.go (renamed from pkg/gui/simple_context.go)23
-rw-r--r--pkg/gui/context/stash_context.go86
-rw-r--r--pkg/gui/context/sub_commits_context.go87
-rw-r--r--pkg/gui/context/submodules_context.go86
-rw-r--r--pkg/gui/context/suggestions_context.go85
-rw-r--r--pkg/gui/context/tags_context.go84
-rw-r--r--pkg/gui/context/view_trait.go46
-rw-r--r--pkg/gui/context/viewport_list_context_trait.go22
-rw-r--r--pkg/gui/context/working_tree_context.go56
-rw-r--r--pkg/gui/context_config.go44
-rw-r--r--pkg/gui/controllers/bisect_controller.go16
-rw-r--r--pkg/gui/controllers/files_controller.go8
-rw-r--r--pkg/gui/controllers/list_controller.go144
-rw-r--r--pkg/gui/controllers/local_commits_controller.go51
-rw-r--r--pkg/gui/controllers/menu_controller.go24
-rw-r--r--pkg/gui/controllers/remotes_controller.go18
-rw-r--r--pkg/gui/controllers/submodules_controller.go31
-rw-r--r--pkg/gui/controllers/tags_controller.go2
-rw-r--r--pkg/gui/custom_commands.go16
-rw-r--r--pkg/gui/diffing.go2
-rw-r--r--pkg/gui/filtering_menu_panel.go2
-rw-r--r--pkg/gui/git_flow.go2
-rw-r--r--pkg/gui/gui.go94
-rw-r--r--pkg/gui/list_context.go267
-rw-r--r--pkg/gui/list_context_config.go327
-rw-r--r--pkg/gui/menu_panel.go35
-rw-r--r--pkg/gui/options_menu_panel.go7
-rw-r--r--pkg/gui/patch_building_panel.go4
-rw-r--r--pkg/gui/patch_options_panel.go2
-rw-r--r--pkg/gui/presentation/menu.go7
-rw-r--r--pkg/gui/reflog_panel.go22
-rw-r--r--pkg/gui/refresh.go4
-rw-r--r--pkg/gui/remote_branches_panel.go26
-rw-r--r--pkg/gui/remotes_panel.go12
-rw-r--r--pkg/gui/stash_panel.go7
-rw-r--r--pkg/gui/sub_commits_panel.go28
-rw-r--r--pkg/gui/submodules_panel.go11
-rw-r--r--pkg/gui/suggestions_panel.go9
-rw-r--r--pkg/gui/tags_panel.go2
-rw-r--r--pkg/gui/types/context.go52
54 files changed, 1557 insertions, 1243 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index f295c9470..072ee257b 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -13,22 +13,9 @@ import (
// list panel functions
-func (gui *Gui) getSelectedBranch() *models.Branch {
- if len(gui.State.Model.Branches) == 0 {
- return nil
- }
-
- selectedLine := gui.State.Panels.Branches.SelectedLineIdx
- if selectedLine == -1 {
- return nil
- }
-
- return gui.State.Model.Branches[selectedLine]
-}
-
func (gui *Gui) branchesRenderToMain() error {
var task updateTask
- branch := gui.getSelectedBranch()
+ branch := gui.State.Contexts.Branches.GetSelected()
if branch == nil {
task = NewRenderStringTask(gui.c.Tr.NoBranchesThisRepo)
} else {
@@ -48,24 +35,26 @@ func (gui *Gui) branchesRenderToMain() error {
// specific functions
func (gui *Gui) handleBranchPress() error {
- if gui.State.Panels.Branches.SelectedLineIdx == -1 {
+ branch := gui.State.Contexts.Branches.GetSelected()
+ if branch == nil {
return nil
}
- if gui.State.Panels.Branches.SelectedLineIdx == 0 {
+
+ if branch == gui.getCheckedOutBranch() {
return gui.c.ErrorMsg(gui.c.Tr.AlreadyCheckedOutBranch)
}
- branch := gui.getSelectedBranch()
+
gui.c.LogAction(gui.c.Tr.Actions.CheckoutBranch)
return gui.helpers.Refs.CheckoutRef(branch.Name, types.CheckoutRefOptions{})
}
func (gui *Gui) handleCreatePullRequestPress() error {
- branch := gui.getSelectedBranch()
+ branch := gui.State.Contexts.Branches.GetSelected()
return gui.createPullRequest(branch.Name, "")
}
func (gui *Gui) handleCreatePullRequestMenu() error {
- selectedBranch := gui.getSelectedBranch()
+ selectedBranch := gui.State.Contexts.Branches.GetSelected()
if selectedBranch == nil {
return nil
}
@@ -77,7 +66,7 @@ func (gui *Gui) handleCreatePullRequestMenu() error {
func (gui *Gui) handleCopyPullRequestURLPress() error {
hostingServiceMgr := gui.getHostingServiceMgr()
- branch := gui.getSelectedBranch()
+ branch := gui.State.Contexts.Branches.GetSelected()
branchExistsOnRemote := gui.git.Remote.CheckRemoteBranchExists(branch.Name)
@@ -109,7 +98,7 @@ func (gui *Gui) handleGitFetch() error {
}
func (gui *Gui) handleForceCheckout() error {
- branch := gui.getSelectedBranch()
+ branch := gui.State.Contexts.Branches.GetSelected()
message := gui.c.Tr.SureForceCheckout
title := gui.c.Tr.ForceCheckoutBranch
@@ -156,7 +145,7 @@ func (gui *Gui) getCheckedOutBranch() *models.Branch {
}
func (gui *Gui) createNewBranchWithName(newBranchName string) error {
- branch := gui.getSelectedBranch()
+ branch := gui.State.Contexts.Branches.GetSelected()
if branch == nil {
return nil
}
@@ -165,7 +154,7 @@ func (gui *Gui) createNewBranchWithName(newBranchName string) error {
return gui.c.Error(err)
}
- gui.State.Panels.Branches.SelectedLineIdx = 0
+ gui.State.Contexts.Branches.SetSelectedLineIdx(0)
return gui.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
}
@@ -174,7 +163,7 @@ func (gui *Gui) handleDeleteBranch() error {
}
func (gui *Gui) deleteBranch(force bool) error {
- selectedBranch := gui.getSelectedBranch()
+ selectedBranch := gui.State.Contexts.Branches.GetSelected()
if selectedBranch == nil {
return nil
}
@@ -245,12 +234,12 @@ func (gui *Gui) mergeBranchIntoCheckedOutBranch(branchName string) error {
}
func (gui *Gui) handleMerge() error {
- selectedBranchName := gui.getSelectedBranch().Name
+ selectedBranchName := gui.State.Contexts.Branches.GetSelected().Name
return gui.mergeBranchIntoCheckedOutBranch(selectedBranchName)
}
func (gui *Gui) handleRebaseOntoLocalBranch() error {
- selectedBranchName := gui.getSelectedBranch().Name
+ selectedBranchName := gui.State.Contexts.Branches.GetSelected().Name
return gui.handleRebaseOntoBranch(selectedBranchName)
}
@@ -279,7 +268,7 @@ func (gui *Gui) handleRebaseOntoBranch(selectedBranchName string) error {
}
func (gui *Gui) handleFastForward() error {
- branch := gui.getSelectedBranch()
+ branch := gui.State.Contexts.Branches.GetSelected()
if branch == nil || !branch.IsRealBranch() {
return nil
}
@@ -305,7 +294,7 @@ func (gui *Gui) handleFastForward() error {
)
return gui.c.WithLoaderPanel(message, func() error {
- if gui.State.Panels.Branches.SelectedLineIdx == 0 {
+ if branch == gui.getCheckedOutBranch() {
gui.c.LogAction(action)
err := gui.git.Sync.Pull(
@@ -334,7 +323,7 @@ func (gui *Gui) handleFastForward() error {
}
func (gui *Gui) handleCreateResetToBranchMenu() error {
- branch := gui.getSelectedBranch()
+ branch := gui.State.Contexts.Branches.GetSelected()
if branch == nil {
return nil
}
@@ -343,7 +332,7 @@ func (gui *Gui) handleCreateResetToBranchMenu() error {
}
func (gui *Gui) handleRenameBranch() error {
- branch := gui.getSelectedBranch()
+ branch := gui.State.Contexts.Branches.GetSelected()
if branch == nil || !branch.IsRealBranch() {
return nil
}
@@ -364,7 +353,7 @@ func (gui *Gui) handleRenameBranch() error {
// now that we've got our stuff again we need to find that branch and reselect it.
for i, newBranch := range gui.State.Model.Branches {
if newBranch.Name == newBranchName {
- gui.State.Panels.Branches.SetSelectedLineIdx(i)
+ gui.State.Contexts.Branches.SetSelectedLineIdx(i)
if err := gui.State.Contexts.Branches.HandleRender(); err != nil {
return err
}
@@ -391,7 +380,7 @@ func (gui *Gui) handleRenameBranch() error {
}
func (gui *Gui) handleEnterBranch() error {
- branch := gui.getSelectedBranch()
+ branch := gui.State.Contexts.Branches.GetSelected()
if branch == nil {
return nil
}
@@ -400,7 +389,7 @@ func (gui *Gui) handleEnterBranch() error {
}
func (gui *Gui) handleNewBranchOffBranch() error {
- selectedBranch := gui.getSelectedBranch()
+ selectedBranch := gui.State.Contexts.Branches.GetSelected()
if selectedBranch == nil {
return nil
}
diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go
index d4cef7b14..fbbedcb6f 100644
--- a/pkg/gui/commit_files_panel.go
+++ b/pkg/gui/commit_files_panel.go
@@ -5,16 +5,11 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands/patch"
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/controllers"
- "github.com/jesseduffield/lazygit/pkg/gui/filetree"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
-func (gui *Gui) getSelectedCommitFileNode() *filetree.CommitFileNode {
- return gui.State.Contexts.CommitFiles.GetSelectedFileNode()
-}
-
func (gui *Gui) getSelectedCommitFile() *models.CommitFile {
- node := gui.getSelectedCommitFileNode()
+ node := gui.State.Contexts.CommitFiles.GetSelectedFileNode()
if node == nil {
return nil
}
@@ -22,20 +17,21 @@ func (gui *Gui) getSelectedCommitFile() *models.CommitFile {
}
func (gui *Gui) getSelectedCommitFilePath() string {
- node := gui.getSelectedCommitFileNode()
+ node := gui.State.Contexts.CommitFiles.GetSelectedFileNode()
if node == nil {
return ""
}
return node.GetPath()
}
+// TODO: do we need this?
func (gui *Gui) onCommitFileFocus() error {
gui.escapeLineByLinePanel()
return nil
}
func (gui *Gui) commitFilesRenderToMain() error {
- node := gui.getSelectedCommitFileNode()
+ node := gui.State.Contexts.CommitFiles.GetSelectedFileNode()
if node == nil {
return nil
}
@@ -62,7 +58,7 @@ func (gui *Gui) commitFilesRenderToMain() error {
}
func (gui *Gui) handleCheckoutCommitFile() error {
- node := gui.getSelectedCommitFileNode()
+ node := gui.State.Contexts.CommitFiles.GetSelectedFileNode()
if node == nil {
return nil
}
@@ -88,7 +84,7 @@ 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.Model.Commits, gui.State.Panels.Commits.SelectedLineIdx, fileName); err != nil {
+ if err := gui.git.Rebase.DiscardOldFileChanges(gui.State.Model.Commits, gui.State.Contexts.BranchCommits.GetSelectedLineIdx(), fileName); err != nil {
if err := gui.helpers.Rebase.CheckMergeOrRebase(err); err != nil {
return err
}
@@ -122,7 +118,7 @@ func (gui *Gui) refreshCommitFilesView() error {
}
func (gui *Gui) handleOpenOldCommitFile() error {
- node := gui.getSelectedCommitFileNode()
+ node := gui.State.Contexts.CommitFiles.GetSelectedFileNode()
if node == nil {
return nil
}
@@ -131,7 +127,7 @@ func (gui *Gui) handleOpenOldCommitFile() error {
}
func (gui *Gui) handleEditCommitFile() error {
- node := gui.getSelectedCommitFileNode()
+ node := gui.State.Contexts.CommitFiles.GetSelectedFileNode()
if node == nil {
return nil
}
@@ -144,7 +140,7 @@ func (gui *Gui) handleEditCommitFile() error {
}
func (gui *Gui) handleToggleFileForPatch() error {
- node := gui.getSelectedCommitFileNode()
+ node := gui.State.Contexts.CommitFiles.GetSelectedFileNode()
if node == nil {
return nil
}
@@ -212,7 +208,7 @@ func (gui *Gui) handleEnterCommitFile() error {
}
func (gui *Gui) enterCommitFile(opts types.OnFocusOpts) error {
- node := gui.getSelectedCommitFileNode()
+ node := gui.State.Contexts.CommitFiles.GetSelectedFileNode()
if node == nil {
return nil
}
@@ -246,7 +242,7 @@ func (gui *Gui) enterCommitFile(opts types.OnFocusOpts) error {
}
func (gui *Gui) handleToggleCommitFileDirCollapsed() error {
- node := gui.getSelectedCommitFileNode()
+ node := gui.State.Contexts.CommitFiles.GetSelectedFileNode()
if node == nil {
return nil
}
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index 4175918ea..37e234e82 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -11,18 +11,12 @@ const COMMIT_THRESHOLD = 200
// list panel functions
func (gui *Gui) getSelectedLocalCommit() *models.Commit {
- selectedLine := gui.State.Panels.Commits.SelectedLineIdx
- if selectedLine == -1 || selectedLine > len(gui.State.Model.Commits)-1 {
- return nil
- }
-
- return gui.State.Model.Commits[selectedLine]
+ return gui.State.Contexts.BranchCommits.GetSelected()
}
func (gui *Gui) onCommitFocus() error {
- state := gui.State.Panels.Commits
- if state.SelectedLineIdx > COMMIT_THRESHOLD && state.LimitCommits {
- state.LimitCommits = false
+ if gui.State.Contexts.BranchCommits.GetSelectedLineIdx() > COMMIT_THRESHOLD && gui.State.LimitCommits {
+ gui.State.LimitCommits = false
go utils.Safe(func() {
if err := gui.refreshCommitsWithLimit(); err != nil {
_ = gui.c.Error(err)
@@ -37,7 +31,7 @@ func (gui *Gui) onCommitFocus() error {
func (gui *Gui) branchCommitsRenderToMain() error {
var task updateTask
- commit := gui.getSelectedLocalCommit()
+ commit := gui.State.Contexts.BranchCommits.GetSelected()
if commit == nil {
task = NewRenderStringTask(gui.c.Tr.NoCommitsThisBranch)
} else {
diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go
index 8ed16ea39..b2cfabfab 100644
--- a/pkg/gui/confirmation_panel.go
+++ b/pkg/gui/confirmation_panel.go
@@ -77,7 +77,29 @@ func (gui *Gui) getMessageHeight(wrap bool, message string, width int) int {
}
func (gui *Gui) getConfirmationPanelDimensions(wrap bool, prompt string) (int, int, int, int) {
+ panelWidth := gui.getConfirmationPanelWidth()
+ panelHeight := gui.getMessageHeight(wrap, prompt, panelWidth)
+ return gui.getConfirmationPanelDimensionsAux(panelWidth, panelHeight)
+}
+
+func (gui *Gui) getConfirmationPanelDimensionsForContentHeight(contentHeight int) (int, int, int, int) {
+ panelWidth := gui.getConfirmationPanelWidth()
+ return gui.getConfirmationPanelDimensionsAux(panelWidth, contentHeight)
+}
+
+func (gui *Gui) getConfirmationPanelDimensionsAux(panelWidth int, panelHeight int) (int, int, int, int) {
width, height := gui.g.Size()
+ if panelHeight > height*3/4 {
+ panelHeight = height * 3 / 4
+ }
+ return width/2 - panelWidth/2,
+ height/2 - panelHeight/2 - panelHeight%2 - 1,
+ width/2 + panelWidth/2,
+ height/2 + panelHeight/2
+}
+
+func (gui *Gui) getConfirmationPanelWidth() int {
+ width, _ := gui.g.Size()
// we want a minimum width up to a point, then we do it based on ratio.
panelWidth := 4 * width / 7
minWidth := 80
@@ -88,14 +110,8 @@ func (gui *Gui) getConfirmationPanelDimensions(wrap bool, prompt string) (int, i
panelWidth = minWidth
}
}
- panelHeight := gui.getMessageHeight(wrap, prompt, panelWidth)
- if panelHeight > height*3/4 {
- panelHeight = height * 3 / 4
- }
- return width/2 - panelWidth/2,
- height/2 - panelHeight/2 - panelHeight%2 - 1,
- width/2 + panelWidth/2,
- height/2 + panelHeight/2
+
+ return panelWidth
}
func (gui *Gui) prepareConfirmationPanel(
diff --git a/pkg/gui/context.go b/pkg/gui/context.go
index f8aa9134e..b59f0a448 100644
--- a/pkg/gui/context.go
+++ b/pkg/gui/context.go
@@ -65,7 +65,6 @@ func (gui *Gui) pushContext(c types.Context, opts ...types.OnFocusOpts) error {
}
if !c.IsFocusable() {
- panic(c.GetKey())
return nil
}
diff --git a/pkg/gui/context/branches_context.go b/pkg/gui/context/branches_context.go
new file mode 100644
index 000000000..0be6e1dce
--- /dev/null
+++ b/pkg/gui/context/branches_context.go
@@ -0,0 +1,86 @@
+package context
+
+import (
+ "github.com/jesseduffield/gocui"
+ "github.com/jesseduffield/lazygit/pkg/commands/models"
+ "github.com/jesseduffield/lazygit/pkg/gui/context/traits"
+ "github.com/jesseduffield/lazygit/pkg/gui/types"
+)
+
+type BranchesContext struct {
+ *BranchesViewModel
+ *ListContextTrait
+}
+
+var _ types.IListContext = (*BranchesContext)(nil)
+
+func NewBranchesContext(
+ getModel func() []*models.Branch,
+ view *gocui.View,
+ getDisplayStrings func(startIdx int, length int) [][]string,
+
+ onFocus func(...types.OnFocusOpts) error,
+ onRenderToMain func(...types.OnFocusOpts) error,
+ onFocusLost func() error,
+
+ c *types.ControllerCommon,
+) *BranchesContext {
+ viewModel := NewBranchesViewModel(getModel)
+
+ return &BranchesContext{
+ BranchesViewModel: viewModel,
+ ListContextTrait: &ListContextTrait{
+ Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{
+ ViewName: "branches",
+ WindowName: "branches",
+ Key: LOCAL_BRANCHES_CONTEXT_KEY,
+ Kind: types.SIDE_CONTEXT,
+ Focusable: true,
+ }), ContextCallbackOpts{
+ OnFocus: onFocus,
+ OnFocusLost: onFocusLost,
+ OnRenderToMain: onRenderToMain,
+ }),
+ list: viewModel,
+ viewTrait: NewViewTrait(view),
+ getDisplayStrings: getDisplayStrings,
+ c: c,
+ },
+ }
+}
+
+func (self *BranchesContext) GetSelectedItemId() string {
+ item := self.GetSelected()
+ if item == nil {
+ return ""
+ }
+
+ return item.ID()
+}
+
+type BranchesViewModel struct {
+ *traits.ListCursor
+ getModel func() []*models.Branch
+}
+
+func NewBranchesViewModel(getModel func() []*models.Branch) *BranchesViewModel {
+ self := &BranchesViewModel{
+ getModel: getModel,
+ }
+
+ self.ListCursor = traits.NewListCursor(self)
+
+ return self
+}
+
+func (self *BranchesViewModel) GetItemsLength() int {
+ return len(self.getModel())
+}
+
+func (self *BranchesViewModel) GetSelected() *models.Branch {
+ if self.GetItemsLength() == 0 {
+ return nil
+ }
+
+ return self.getModel()[self.GetSelectedLineIdx()]
+}
diff --git a/pkg/gui/context/commit_files_context.go b/pkg/gui/context/commit_files_context.go
index e729fb3c1..1c555387b 100644
--- a/pkg/gui/context/commit_files_context.go
+++ b/pkg/gui/context/commit_files_context.go
@@ -9,7 +9,6 @@ import (
type CommitFilesContext struct {
*filetree.CommitFileTreeViewModel
- *BaseContext
*ListContextTrait
}
@@ -17,7 +16,7 @@ var _ types.IListContext = (*CommitFilesContext)(nil)
func NewCommitFilesContext(
getModel func() []*models.CommitFile,
- getView func() *gocui.View,
+ view *gocui.View,
getDisplayStrings func(startIdx int, length int) [][]string,
onFocus func(...types.OnFocusOpts) error,
@@ -26,43 +25,30 @@ func NewCommitFilesContext(
c *types.ControllerCommon,
) *CommitFilesContext {
- baseContext := NewBaseContext(NewBaseContextOpts{
- ViewName: "commitFiles",
- WindowName: "commits",
- Key: COMMIT_FILES_CONTEXT_KEY,
- Kind: types.SIDE_CONTEXT,
- Focusable: true,
- })
-
- self := &CommitFilesContext{}
- takeFocus := func() error { return c.PushContext(self) }
-
viewModel := filetree.NewCommitFileTreeViewModel(getModel, c.Log, c.UserConfig.Gui.ShowFileTree)
- viewTrait := NewViewTrait(getView)
- listContextTrait := &ListContextTrait{
- base: baseContext,
- list: viewModel,
- viewTrait: viewTrait,
-
- GetDisplayStrings: getDisplayStrings,
- OnFocus: onFocus,
- OnRenderToMain: onRenderToMain,
- OnFocusLost: onFocusLost,
- takeFocus: takeFocus,
-
- // TODO: handle this in a trait
- RenderSelection: false,
- c: c,
+ return &CommitFilesContext{
+ CommitFileTreeViewModel: viewModel,
+ ListContextTrait: &ListContextTrait{
+ Context: NewSimpleContext(
+ NewBaseContext(NewBaseContextOpts{
+ ViewName: "commitFiles",
+ WindowName: "commits",
+ Key: COMMIT_FILES_CONTEXT_KEY,
+ Kind: types.SIDE_CONTEXT,
+ Focusable: true,
+ }),
+ ContextCallbackOpts{
+ OnFocus: onFocus,
+ OnFocusLost: onFocusLost,
+ OnRenderToMain: onRenderToMain,
+ }),
+ list: viewModel,
+ viewTrait: NewViewTrait(view),
+ getDisplayStrings: getDisplayStrings,
+ c: c,
+ },
}
-
- baseContext.AddKeybindingsFn(listContextTrait.keybindings)
-
- self.BaseContext = baseContext
- self.ListContextTrait = listContextTrait
- self.CommitFileTreeViewModel = viewModel
-
- return self
}
func (self *CommitFilesContext) GetSelectedItemId() string {
diff --git a/pkg/gui/context/context.go b/pkg/gui/context/context.go
index 710e9a590..5f7c8f163 100644
--- a/pkg/gui/context/context.go
+++ b/pkg/gui/context/context.go
@@ -1,6 +1,10 @@
package context
-import "github.com/jesseduffield/lazygit/pkg/gui/types"
+import (
+ "sync"