1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-05 15:15:49 +02:00

appease linter

This commit is contained in:
Jesse Duffield 2022-02-13 10:48:41 +11:00
parent 3188526ecb
commit 41527270ed
6 changed files with 19 additions and 105 deletions

View File

@ -313,6 +313,10 @@ func (gui *Gui) sidePanelChildren(width int, height int) []*boxlayout.Box {
}
}
func (gui *Gui) getCyclableWindows() []string {
return []string{"status", "files", "branches", "commits", "stash"}
}
func (gui *Gui) currentSideWindowName() string {
// there is always one and only one cyclable context in the context stack. We'll look from top to bottom
gui.State.ContextManager.RLock()

View File

@ -3,6 +3,8 @@ package gui
import (
"errors"
"fmt"
"sort"
"strings"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/context"
@ -222,6 +224,19 @@ func (gui *Gui) activateContext(c types.Context, opts ...types.OnFocusOpts) erro
return nil
}
func (gui *Gui) optionsMapToString(optionsMap map[string]string) string {
optionsArray := make([]string, 0)
for key, description := range optionsMap {
optionsArray = append(optionsArray, key+": "+description)
}
sort.Strings(optionsArray)
return strings.Join(optionsArray, ", ")
}
func (gui *Gui) renderOptionsMap(optionsMap map[string]string) {
_ = gui.renderString(gui.Views.Options, gui.optionsMapToString(optionsMap))
}
// also setting context on view for now. We'll need to pick one of these two approaches to stick with.
func (gui *Gui) ViewContextMapSet(viewName string, c types.Context) {
gui.State.ViewContextMap.Set(viewName, c)

View File

@ -5,34 +5,6 @@ import (
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
func (gui *Gui) allContexts2() []types.Context {
return []types.Context{
gui.State.Contexts.Global,
gui.State.Contexts.Status,
gui.State.Contexts.Files,
gui.State.Contexts.Submodules,
gui.State.Contexts.Branches,
gui.State.Contexts.Remotes,
gui.State.Contexts.RemoteBranches,
gui.State.Contexts.Tags,
gui.State.Contexts.BranchCommits,
gui.State.Contexts.CommitFiles,
gui.State.Contexts.ReflogCommits,
gui.State.Contexts.Stash,
gui.State.Contexts.Menu,
gui.State.Contexts.Confirmation,
gui.State.Contexts.Credentials,
gui.State.Contexts.CommitMessage,
gui.State.Contexts.Normal,
gui.State.Contexts.Staging,
gui.State.Contexts.Merging,
gui.State.Contexts.PatchBuilding,
gui.State.Contexts.SubCommits,
gui.State.Contexts.Suggestions,
gui.State.Contexts.CommandLog,
}
}
func (gui *Gui) contextTree() *context.ContextTree {
return &context.ContextTree{
Global: context.NewSimpleContext(

View File

@ -212,18 +212,6 @@ type Controllers struct {
Global *controllers.GlobalController
}
type listPanelState struct {
SelectedLineIdx int
}
func (h *listPanelState) SetSelectedLineIdx(value int) {
h.SelectedLineIdx = value
}
func (h *listPanelState) GetSelectedLineIdx() int {
return h.SelectedLineIdx
}
// for now the staging panel state, unlike the other panel states, is going to be
// non-mutative, so that we don't accidentally end up
// with mismatches of data. We might change this in the future

View File

@ -1,17 +1,12 @@
package gui
import (
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/controllers"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
// list panel functions
func (gui *Gui) getSelectedReflogCommit() *models.Commit {
return gui.State.Contexts.ReflogCommits.GetSelected()
}
func (gui *Gui) reflogCommitsRenderToMain() error {
commit := gui.State.Contexts.ReflogCommits.GetSelected()
var task updateTask

View File

@ -2,19 +2,12 @@ package gui
import (
"fmt"
"sort"
"strings"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/spkg/bom"
)
func (gui *Gui) getCyclableWindows() []string {
return []string{"status", "files", "branches", "commits", "stash"}
}
func (gui *Gui) resetOrigin(v *gocui.View) error {
_ = v.SetCursor(0, 0)
return v.SetOrigin(0, 0)
@ -41,19 +34,6 @@ func (gui *Gui) renderString(view *gocui.View, s string) error {
return nil
}
func (gui *Gui) optionsMapToString(optionsMap map[string]string) string {
optionsArray := make([]string, 0)
for key, description := range optionsMap {
optionsArray = append(optionsArray, key+": "+description)
}
sort.Strings(optionsArray)
return strings.Join(optionsArray, ", ")
}
func (gui *Gui) renderOptionsMap(optionsMap map[string]string) {
_ = gui.renderString(gui.Views.Options, gui.optionsMapToString(optionsMap))
}
func (gui *Gui) currentViewName() string {
currentView := gui.g.CurrentView()
if currentView == nil {
@ -85,46 +65,6 @@ func (gui *Gui) resizePopupPanel(v *gocui.View, content string) error {
return err
}
func (gui *Gui) changeSelectedLine(panelState types.IListPanelState, total int, change int) {
// TODO: find out why we're doing this
line := panelState.GetSelectedLineIdx()
if line == -1 {
return
}
var newLine int
if line+change < 0 {
newLine = 0
} else if line+change >= total {
newLine = total - 1
} else {
newLine = line + change
}
panelState.SetSelectedLineIdx(newLine)
}
func (gui *Gui) refreshSelectedLine(panelState types.IListPanelState, total int) {
line := panelState.GetSelectedLineIdx()
if line == -1 && total > 0 {
panelState.SetSelectedLineIdx(0)
} else if total-1 < line {
panelState.SetSelectedLineIdx(total - 1)
}
}
func (gui *Gui) renderDisplayStrings(v *gocui.View, displayStrings [][]string) {
list := utils.RenderDisplayStrings(displayStrings)
v.SetContent(list)
}
func (gui *Gui) renderDisplayStringsInViewPort(v *gocui.View, displayStrings [][]string) {
list := utils.RenderDisplayStrings(displayStrings)
_, y := v.Origin()
v.OverwriteLines(y, list)
}
func (gui *Gui) globalOptionsMap() map[string]string {
keybindingConfig := gui.c.UserConfig.Keybinding