1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-10 04:07:18 +02:00

some more things

This commit is contained in:
Jesse Duffield 2020-08-19 21:13:43 +10:00
parent f601108c5d
commit dbf6bb5f27
3 changed files with 38 additions and 50 deletions

View File

@ -102,11 +102,7 @@ func (gui *Gui) refreshCommitFilesView() error {
} }
gui.State.CommitFiles = files gui.State.CommitFiles = files
if err := gui.renderCommitFiles(); err != nil { return gui.postRefreshUpdate(gui.Contexts.BranchCommits.Files.Context)
return err
}
return gui.handleCommitFileSelect()
} }
func (gui *Gui) renderCommitFiles() error { func (gui *Gui) renderCommitFiles() error {

View File

@ -105,6 +105,7 @@ func (gui *Gui) allContexts() []Context {
gui.Contexts.Branches.Context, gui.Contexts.Branches.Context,
gui.Contexts.Remotes.Context, gui.Contexts.Remotes.Context,
gui.Contexts.Remotes.Branches.Context, gui.Contexts.Remotes.Branches.Context,
gui.Contexts.Tags.Context,
gui.Contexts.BranchCommits.Context, gui.Contexts.BranchCommits.Context,
gui.Contexts.BranchCommits.Files.Context, gui.Contexts.BranchCommits.Files.Context,
gui.Contexts.ReflogCommits.Context, gui.Contexts.ReflogCommits.Context,
@ -256,6 +257,40 @@ func (gui *Gui) initialViewContextMap() map[string]Context {
} }
} }
func (gui *Gui) viewTabContextMap() map[string][]tabContext {
return map[string][]tabContext{
"branches": {
{
tab: "Local Branches",
contexts: []Context{gui.Contexts.Branches.Context},
},
{
tab: "Remotes",
contexts: []Context{
gui.Contexts.Remotes.Context,
gui.Contexts.Remotes.Branches.Context,
},
},
{
tab: "Tags",
contexts: []Context{gui.Contexts.Tags.Context},
},
},
"commits": {
{
tab: "Commits",
contexts: []Context{gui.Contexts.BranchCommits.Context},
},
{
tab: "Reflog",
contexts: []Context{
gui.Contexts.ReflogCommits.Context,
},
},
},
}
}
func (gui *Gui) switchContext(c Context) error { func (gui *Gui) switchContext(c Context) error {
gui.g.Update(func(*gocui.Gui) error { gui.g.Update(func(*gocui.Gui) error {
// push onto stack // push onto stack
@ -501,40 +536,6 @@ func (gui *Gui) changeMainViewsContext(context string) {
gui.State.MainContext = context gui.State.MainContext = context
} }
func (gui *Gui) viewTabContextMap() map[string][]tabContext {
return map[string][]tabContext{
"branches": {
{
tab: "Local Branches",
contexts: []Context{gui.Contexts.Branches.Context},
},
{
tab: "Remotes",
contexts: []Context{
gui.Contexts.Remotes.Context,
gui.Contexts.Remotes.Branches.Context,
},
},
{
tab: "Tags",
contexts: []Context{gui.Contexts.Tags.Context},
},
},
"commits": {
{
tab: "Commits",
contexts: []Context{gui.Contexts.BranchCommits.Context},
},
{
tab: "Reflog",
contexts: []Context{
gui.Contexts.ReflogCommits.Context,
},
},
},
}
}
func (gui *Gui) viewTabNames(viewName string) []string { func (gui *Gui) viewTabNames(viewName string) []string {
tabContexts := gui.ViewTabContextMap[viewName] tabContexts := gui.ViewTabContextMap[viewName]

View File

@ -53,11 +53,7 @@ func (gui *Gui) refreshTags() error {
gui.State.Tags = tags gui.State.Tags = tags
if gui.getBranchesView().Context == "tags" { return gui.postRefreshUpdate(gui.Contexts.Tags.Context)
return gui.renderTagsContext()
}
return nil
} }
func (gui *Gui) renderTagsContext() error { func (gui *Gui) renderTagsContext() error {
@ -66,11 +62,6 @@ func (gui *Gui) renderTagsContext() error {
gui.refreshSelectedLine(&gui.State.Panels.Tags.SelectedLine, len(gui.State.Tags)) gui.refreshSelectedLine(&gui.State.Panels.Tags.SelectedLine, len(gui.State.Tags))
displayStrings := presentation.GetTagListDisplayStrings(gui.State.Tags, gui.State.Diff.Ref) displayStrings := presentation.GetTagListDisplayStrings(gui.State.Tags, gui.State.Diff.Ref)
gui.renderDisplayStrings(branchesView, displayStrings) gui.renderDisplayStrings(branchesView, displayStrings)
if gui.g.CurrentView() == branchesView && branchesView.Context == "tags" {
if err := gui.handleTagSelect(); err != nil {
return gui.surfaceError(err)
}
}
return nil return nil
} }
@ -145,7 +136,7 @@ func (gui *Gui) handleCreateTag(g *gocui.Gui, v *gocui.View) error {
for i, tag := range gui.State.Tags { for i, tag := range gui.State.Tags {
if tag.Name == tagName { if tag.Name == tagName {
gui.State.Panels.Tags.SelectedLine = i gui.State.Panels.Tags.SelectedLine = i
gui.renderTagsContext() _ = gui.renderTagsContext()
return return
} }
} }