mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-20 05:19:24 +02:00
align Gui struct with GitCommand
This commit is contained in:
parent
03b946cc8f
commit
01ea5813a8
@ -41,8 +41,6 @@ type AppConfigurer interface {
|
||||
GetUserConfigDir() string
|
||||
GetAppState() *AppState
|
||||
SaveAppState() error
|
||||
SetIsNewRepo(bool)
|
||||
GetIsNewRepo() bool
|
||||
ReloadUserConfig() error
|
||||
ShowCommandLogOnStartup() bool
|
||||
}
|
||||
@ -166,37 +164,22 @@ func loadUserConfig(configFiles []string, base *UserConfig) (*UserConfig, error)
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// GetIsNewRepo returns known repo boolean
|
||||
func (c *AppConfig) GetIsNewRepo() bool {
|
||||
return c.IsNewRepo
|
||||
}
|
||||
|
||||
// SetIsNewRepo set if the current repo is known
|
||||
func (c *AppConfig) SetIsNewRepo(toSet bool) {
|
||||
c.IsNewRepo = toSet
|
||||
}
|
||||
|
||||
// GetDebug returns debug flag
|
||||
func (c *AppConfig) GetDebug() bool {
|
||||
return c.Debug
|
||||
}
|
||||
|
||||
// GetVersion returns debug flag
|
||||
func (c *AppConfig) GetVersion() string {
|
||||
return c.Version
|
||||
}
|
||||
|
||||
// GetCommit returns debug flag
|
||||
func (c *AppConfig) GetCommit() string {
|
||||
return c.Commit
|
||||
}
|
||||
|
||||
// GetBuildDate returns debug flag
|
||||
func (c *AppConfig) GetBuildDate() string {
|
||||
return c.BuildDate
|
||||
}
|
||||
|
||||
// GetName returns debug flag
|
||||
func (c *AppConfig) GetName() string {
|
||||
return c.Name
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func (gui *Gui) getMidSectionWeights() (int, int) {
|
||||
currentWindow := gui.currentWindow()
|
||||
|
||||
// we originally specified this as a ratio i.e. .20 would correspond to a weight of 1 against 4
|
||||
sidePanelWidthRatio := gui.Config.GetUserConfig().Gui.SidePanelWidth
|
||||
sidePanelWidthRatio := gui.UserConfig.Gui.SidePanelWidth
|
||||
// we could make this better by creating ratios like 2:3 rather than always 1:something
|
||||
mainSectionWeight := int(1/sidePanelWidthRatio) - 1
|
||||
sideSectionWeight := 1
|
||||
@ -115,7 +115,7 @@ func (gui *Gui) splitMainPanelSideBySide() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
mainPanelSplitMode := gui.Config.GetUserConfig().Gui.MainPanelSplitMode
|
||||
mainPanelSplitMode := gui.UserConfig.Gui.MainPanelSplitMode
|
||||
width, height := gui.g.Size()
|
||||
|
||||
switch mainPanelSplitMode {
|
||||
@ -143,7 +143,7 @@ func (gui *Gui) getExtrasWindowSize(screenHeight int) int {
|
||||
} else if screenHeight < 40 {
|
||||
baseSize = 1
|
||||
} else {
|
||||
baseSize = gui.Config.GetUserConfig().Gui.CommandLogSize
|
||||
baseSize = gui.UserConfig.Gui.CommandLogSize
|
||||
}
|
||||
|
||||
frameSize := 2
|
||||
@ -259,7 +259,7 @@ func (gui *Gui) sidePanelChildren(width int, height int) []*boxlayout.Box {
|
||||
fullHeightBox("stash"),
|
||||
}
|
||||
} else if height >= 28 {
|
||||
accordionMode := gui.Config.GetUserConfig().Gui.ExpandFocusedSidePanel
|
||||
accordionMode := gui.UserConfig.Gui.ExpandFocusedSidePanel
|
||||
accordionBox := func(defaultBox *boxlayout.Box) *boxlayout.Box {
|
||||
if accordionMode && defaultBox.Window == currentWindow {
|
||||
return &boxlayout.Box{
|
||||
|
@ -41,11 +41,11 @@ func (gui *Gui) GetOnRunCommand() func(entry oscommands.CmdLogEntry) {
|
||||
func (gui *Gui) printCommandLogHeader() {
|
||||
introStr := fmt.Sprintf(
|
||||
gui.Tr.CommandLogHeader,
|
||||
gui.getKeyDisplay(gui.Config.GetUserConfig().Keybinding.Universal.ExtrasMenu),
|
||||
gui.getKeyDisplay(gui.UserConfig.Keybinding.Universal.ExtrasMenu),
|
||||
)
|
||||
fmt.Fprintln(gui.Views.Extras, style.FgCyan.Sprint(introStr))
|
||||
|
||||
if gui.Config.GetUserConfig().Gui.ShowRandomTip {
|
||||
if gui.UserConfig.Gui.ShowRandomTip {
|
||||
fmt.Fprintf(
|
||||
gui.Views.Extras,
|
||||
"%s: %s",
|
||||
@ -56,7 +56,7 @@ func (gui *Gui) printCommandLogHeader() {
|
||||
}
|
||||
|
||||
func (gui *Gui) getRandomTip() string {
|
||||
config := gui.Config.GetUserConfig().Keybinding
|
||||
config := gui.UserConfig.Keybinding
|
||||
|
||||
formattedKey := func(key string) string {
|
||||
return gui.getKeyDisplay(key)
|
||||
|
@ -15,12 +15,12 @@ func (gui *Gui) handleCommitConfirm() error {
|
||||
return gui.createErrorPanel(gui.Tr.CommitWithoutMessageErr)
|
||||
}
|
||||
flags := []string{}
|
||||
skipHookPrefix := gui.Config.GetUserConfig().Git.SkipHookPrefix
|
||||
skipHookPrefix := gui.UserConfig.Git.SkipHookPrefix
|
||||
if skipHookPrefix != "" && strings.HasPrefix(message, skipHookPrefix) {
|
||||
flags = append(flags, "--no-verify")
|
||||
}
|
||||
|
||||
if gui.Config.GetUserConfig().Git.Commit.SignOff {
|
||||
if gui.UserConfig.Git.Commit.SignOff {
|
||||
flags = append(flags, "--signoff")
|
||||
}
|
||||
|
||||
@ -42,9 +42,9 @@ func (gui *Gui) handleCommitMessageFocused() error {
|
||||
message := utils.ResolvePlaceholderString(
|
||||
gui.Tr.CommitMessageConfirm,
|
||||
map[string]string{
|
||||
"keyBindClose": gui.getKeyDisplay(gui.Config.GetUserConfig().Keybinding.Universal.Return),
|
||||
"keyBindConfirm": gui.getKeyDisplay(gui.Config.GetUserConfig().Keybinding.Universal.Confirm),
|
||||
"keyBindNewLine": gui.getKeyDisplay(gui.Config.GetUserConfig().Keybinding.Universal.AppendNewline),
|
||||
"keyBindClose": gui.getKeyDisplay(gui.UserConfig.Keybinding.Universal.Return),
|
||||
"keyBindConfirm": gui.getKeyDisplay(gui.UserConfig.Keybinding.Universal.Confirm),
|
||||
"keyBindNewLine": gui.getKeyDisplay(gui.UserConfig.Keybinding.Universal.AppendNewline),
|
||||
},
|
||||
)
|
||||
|
||||
@ -58,7 +58,7 @@ func (gui *Gui) getBufferLength(view *gocui.View) string {
|
||||
|
||||
// RenderCommitLength is a function.
|
||||
func (gui *Gui) RenderCommitLength() {
|
||||
if !gui.Config.GetUserConfig().Gui.CommitLength.Show {
|
||||
if !gui.UserConfig.Gui.CommitLength.Show {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -733,7 +733,7 @@ func (gui *Gui) handleOpenLogMenu() error {
|
||||
opensMenu: true,
|
||||
onPress: func() error {
|
||||
onSelect := func(value string) {
|
||||
gui.Config.GetUserConfig().Git.Log.ShowGraph = value
|
||||
gui.UserConfig.Git.Log.ShowGraph = value
|
||||
gui.render()
|
||||
}
|
||||
return gui.createMenu(gui.Tr.LogMenuTitle, []*menuItem{
|
||||
@ -766,7 +766,7 @@ func (gui *Gui) handleOpenLogMenu() error {
|
||||
opensMenu: true,
|
||||
onPress: func() error {
|
||||
onSelect := func(value string) error {
|
||||
gui.Config.GetUserConfig().Git.Log.Order = value
|
||||
gui.UserConfig.Git.Log.Order = value
|
||||
return gui.WithWaitingStatus(gui.Tr.LcLoadingCommits, func() error {
|
||||
return gui.refreshSidePanels(refreshOptions{mode: SYNC, scope: []RefreshableView{COMMITS}})
|
||||
})
|
||||
|
@ -173,7 +173,7 @@ func (gui *Gui) prepareConfirmationPanel(
|
||||
suggestionsView.FgColor = theme.GocuiDefaultTextColor
|
||||
gui.setSuggestions(findSuggestionsFunc(""))
|
||||
suggestionsView.Visible = true
|
||||
suggestionsView.Title = fmt.Sprintf(gui.Tr.SuggestionsTitle, gui.Config.GetUserConfig().Keybinding.Universal.TogglePanel)
|
||||
suggestionsView.Title = fmt.Sprintf(gui.Tr.SuggestionsTitle, gui.UserConfig.Keybinding.Universal.TogglePanel)
|
||||
}
|
||||
|
||||
gui.g.Update(func(g *gocui.Gui) error {
|
||||
@ -240,7 +240,7 @@ func (gui *Gui) setKeyBindings(opts createPopupPanelOpts) error {
|
||||
handler func() error
|
||||
}
|
||||
|
||||
keybindingConfig := gui.Config.GetUserConfig().Keybinding
|
||||
keybindingConfig := gui.UserConfig.Keybinding
|
||||
onSuggestionConfirm := gui.wrappedPromptConfirmationFunction(
|
||||
opts.handlersManageFocus,
|
||||
opts.handleConfirmPrompt,
|
||||
@ -305,7 +305,7 @@ func (gui *Gui) setKeyBindings(opts createPopupPanelOpts) error {
|
||||
}
|
||||
|
||||
func (gui *Gui) clearConfirmationViewKeyBindings() {
|
||||
keybindingConfig := gui.Config.GetUserConfig().Keybinding
|
||||
keybindingConfig := gui.UserConfig.Keybinding
|
||||
_ = gui.g.DeleteKeybinding("confirmation", gui.getKey(keybindingConfig.Universal.Confirm), gocui.ModNone)
|
||||
_ = gui.g.DeleteKeybinding("confirmation", gui.getKey(keybindingConfig.Universal.ConfirmAlt1), gocui.ModNone)
|
||||
_ = gui.g.DeleteKeybinding("confirmation", gui.getKey(keybindingConfig.Universal.Return), gocui.ModNone)
|
||||
|
@ -57,7 +57,7 @@ func (gui *Gui) handleCloseCredentialsView() error {
|
||||
}
|
||||
|
||||
func (gui *Gui) handleCredentialsViewFocused() error {
|
||||
keybindingConfig := gui.Config.GetUserConfig().Keybinding
|
||||
keybindingConfig := gui.UserConfig.Keybinding
|
||||
|
||||
message := utils.ResolvePlaceholderString(
|
||||
gui.Tr.CloseConfirm,
|
||||
|
@ -296,7 +296,7 @@ func (gui *Gui) handleCustomCommandKeybinding(customCommand config.CustomCommand
|
||||
|
||||
func (gui *Gui) GetCustomCommandKeybindings() []*Binding {
|
||||
bindings := []*Binding{}
|
||||
customCommands := gui.Config.GetUserConfig().CustomCommands
|
||||
customCommands := gui.UserConfig.CustomCommands
|
||||
|
||||
for _, customCommand := range customCommands {
|
||||
var viewName string
|
||||
|
@ -16,7 +16,7 @@ func (gui *Gui) IncreaseContextInDiffView() error {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
|
||||
gui.Config.GetUserConfig().Git.DiffContextSize = gui.Config.GetUserConfig().Git.DiffContextSize + 1
|
||||
gui.UserConfig.Git.DiffContextSize = gui.UserConfig.Git.DiffContextSize + 1
|
||||
return gui.currentStaticContext().HandleRenderToMain()
|
||||
}
|
||||
|
||||
@ -24,14 +24,14 @@ func (gui *Gui) IncreaseContextInDiffView() error {
|
||||
}
|
||||
|
||||
func (gui *Gui) DecreaseContextInDiffView() error {
|
||||
old_size := gui.Config.GetUserConfig().Git.DiffContextSize
|
||||
old_size := gui.UserConfig.Git.DiffContextSize
|
||||
|
||||
if isShowingDiff(gui) && old_size > 1 {
|
||||
if err := gui.CheckCanChangeContext(); err != nil {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
|
||||
gui.Config.GetUserConfig().Git.DiffContextSize = old_size - 1
|
||||
gui.UserConfig.Git.DiffContextSize = old_size - 1
|
||||
return gui.currentStaticContext().HandleRenderToMain()
|
||||
}
|
||||
|
||||
|
@ -46,12 +46,12 @@ func TestIncreasesContextInDiffViewByOneInContextWithDiff(t *testing.T) {
|
||||
gui := NewDummyGui()
|
||||
context := c(gui)
|
||||
setupGuiForTest(gui)
|
||||
gui.Config.GetUserConfig().Git.DiffContextSize = 1
|
||||
gui.UserConfig.Git.DiffContextSize = 1
|
||||
_ = gui.pushContextDirect(context)
|
||||
|
||||
_ = gui.IncreaseContextInDiffView()
|
||||
|
||||
assert.Equal(t, 2, gui.Config.GetUserConfig().Git.DiffContextSize, string(context.GetKey()))
|
||||
assert.Equal(t, 2, gui.UserConfig.Git.DiffContextSize, string(context.GetKey()))
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,12 +72,12 @@ func TestDoesntIncreaseContextInDiffViewInContextWithoutDiff(t *testing.T) {
|
||||
gui := NewDummyGui()
|
||||
context := c(gui)
|
||||
setupGuiForTest(gui)
|
||||
gui.Config.GetUserConfig().Git.DiffContextSize = 1
|
||||
gui.UserConfig.Git.DiffContextSize = 1
|
||||
_ = gui.pushContextDirect(context)
|
||||
|
||||
_ = gui.IncreaseContextInDiffView()
|
||||
|
||||
assert.Equal(t, 1, gui.Config.GetUserConfig().Git.DiffContextSize, string(context.GetKey()))
|
||||
assert.Equal(t, 1, gui.UserConfig.Git.DiffContextSize, string(context.GetKey()))
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,12 +96,12 @@ func TestDecreasesContextInDiffViewByOneInContextWithDiff(t *testing.T) {
|
||||
gui := NewDummyGui()
|
||||
context := c(gui)
|
||||
setupGuiForTest(gui)
|
||||
gui.Config.GetUserConfig().Git.DiffContextSize = 2
|
||||
gui.UserConfig.Git.DiffContextSize = 2
|
||||
_ = gui.pushContextDirect(context)
|
||||
|
||||
_ = gui.DecreaseContextInDiffView()
|
||||
|
||||
assert.Equal(t, 1, gui.Config.GetUserConfig().Git.DiffContextSize, string(context.GetKey()))
|
||||
assert.Equal(t, 1, gui.UserConfig.Git.DiffContextSize, string(context.GetKey()))
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,19 +122,19 @@ func TestDoesntDecreaseContextInDiffViewInContextWithoutDiff(t *testing.T) {
|
||||
gui := NewDummyGui()
|
||||
context := c(gui)
|
||||
setupGuiForTest(gui)
|
||||
gui.Config.GetUserConfig().Git.DiffContextSize = 2
|
||||
gui.UserConfig.Git.DiffContextSize = 2
|
||||
_ = gui.pushContextDirect(context)
|
||||
|
||||
_ = gui.DecreaseContextInDiffView()
|
||||
|
||||
assert.Equal(t, 2, gui.Config.GetUserConfig().Git.DiffContextSize, string(context.GetKey()))
|
||||
assert.Equal(t, 2, gui.UserConfig.Git.DiffContextSize, string(context.GetKey()))
|
||||
}
|
||||
}
|
||||
|
||||
func TestDoesntIncreaseContextInDiffViewInContextWhenInPatchBuildingMode(t *testing.T) {
|
||||
gui := NewDummyGui()
|
||||
setupGuiForTest(gui)
|
||||
gui.Config.GetUserConfig().Git.DiffContextSize = 2
|
||||
gui.UserConfig.Git.DiffContextSize = 2
|
||||
_ = gui.pushContextDirect(gui.State.Contexts.CommitFiles)
|
||||
gui.GitCommand.PatchManager.Start("from", "to", false, false)
|
||||
|
||||
@ -150,13 +150,13 @@ func TestDoesntIncreaseContextInDiffViewInContextWhenInPatchBuildingMode(t *test
|
||||
_ = gui.IncreaseContextInDiffView()
|
||||
|
||||
assert.Equal(t, 1, errorCount)
|
||||
assert.Equal(t, 2, gui.Config.GetUserConfig().Git.DiffContextSize)
|
||||
assert.Equal(t, 2, gui.UserConfig.Git.DiffContextSize)
|
||||
}
|
||||
|
||||
func TestDoesntDecreaseContextInDiffViewInContextWhenInPatchBuildingMode(t *testing.T) {
|
||||
gui := NewDummyGui()
|
||||
setupGuiForTest(gui)
|
||||
gui.Config.GetUserConfig().Git.DiffContextSize = 2
|
||||
gui.UserConfig.Git.DiffContextSize = 2
|
||||
_ = gui.pushContextDirect(gui.State.Contexts.CommitFiles)
|
||||
gui.GitCommand.PatchManager.Start("from", "to", false, false)
|
||||
|
||||
@ -171,15 +171,15 @@ func TestDoesntDecreaseContextInDiffViewInContextWhenInPatchBuildingMode(t *test
|
||||
|
||||
_ = gui.DecreaseContextInDiffView()
|
||||
|
||||
assert.Equal(t, 2, gui.Config.GetUserConfig().Git.DiffContextSize)
|
||||
assert.Equal(t, 2, gui.UserConfig.Git.DiffContextSize)
|
||||
}
|
||||
|
||||
func TestDecreasesContextInDiffViewNoFurtherThanOne(t *testing.T) {
|
||||
gui := NewDummyGui()
|
||||
setupGuiForTest(gui)
|
||||
gui.Config.GetUserConfig().Git.DiffContextSize = 1
|
||||
gui.UserConfig.Git.DiffContextSize = 1
|
||||
|
||||
_ = gui.DecreaseContextInDiffView()
|
||||
|
||||
assert.Equal(t, 1, gui.Config.GetUserConfig().Git.DiffContextSize)
|
||||
assert.Equal(t, 1, gui.UserConfig.Git.DiffContextSize)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func (gui *Gui) handleEditorKeypress(textArea *gocui.TextArea, key gocui.Key, ch rune, mod gocui.Modifier, allowMultiline bool) bool {
|
||||
newlineKey, ok := gui.getKey(gui.Config.GetUserConfig().Keybinding.Universal.AppendNewline).(gocui.Key)
|
||||
newlineKey, ok := gui.getKey(gui.UserConfig.Keybinding.Universal.AppendNewline).(gocui.Key)
|
||||
if !ok {
|
||||
newlineKey = gocui.KeyAltEnter
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ func (gui *Gui) handleIgnoreFile() error {
|
||||
}
|
||||
|
||||
func (gui *Gui) handleWIPCommitPress() error {
|
||||
skipHookPrefix := gui.Config.GetUserConfig().Git.SkipHookPrefix
|
||||
skipHookPrefix := gui.UserConfig.Git.SkipHookPrefix
|
||||
if skipHookPrefix == "" {
|
||||
return gui.createErrorPanel(gui.Tr.SkipHookPrefixNotConfigured)
|
||||
}
|
||||
@ -344,7 +344,7 @@ func (gui *Gui) handleWIPCommitPress() error {
|
||||
}
|
||||
|
||||
func (gui *Gui) commitPrefixConfigForRepo() *config.CommitPrefixConfig {
|
||||
cfg, ok := gui.Config.GetUserConfig().Git.CommitPrefixes[utils.GetCurrentRepoName()]
|
||||
cfg, ok := gui.UserConfig.Git.CommitPrefixes[utils.GetCurrentRepoName()]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
@ -354,7 +354,7 @@ func (gui *Gui) commitPrefixConfigForRepo() *config.CommitPrefixConfig {
|
||||
|
||||
func (gui *Gui) prepareFilesForCommit() error {
|
||||
noStagedFiles := len(gui.stagedFiles()) == 0
|
||||
if noStagedFiles && gui.Config.GetUserConfig().Gui.SkipNoStagedFilesWarning {
|
||||
if noStagedFiles && gui.UserConfig.Gui.SkipNoStagedFilesWarning {
|
||||
err := gui.GitCommand.WithSpan(gui.Tr.Spans.StageAllFiles).StageAll()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -458,7 +458,7 @@ func (gui *Gui) handleCommitEditorPress() error {
|
||||
|
||||
args := []string{"commit"}
|
||||
|
||||
if gui.Config.GetUserConfig().Git.Commit.SignOff {
|
||||
if gui.UserConfig.Git.Commit.SignOff {
|
||||
args = append(args, "--signoff")
|
||||
}
|
||||
|
||||
@ -741,7 +741,7 @@ func (gui *Gui) push(opts pushOpts) error {
|
||||
})
|
||||
|
||||
if err != nil && !opts.force && strings.Contains(err.Error(), "Updates were rejected") {
|
||||
forcePushDisabled := gui.Config.GetUserConfig().Git.DisableForcePushing
|
||||
forcePushDisabled := gui.UserConfig.Git.DisableForcePushing
|
||||
if forcePushDisabled {
|
||||
_ = gui.createErrorPanel(gui.Tr.UpdatesRejectedAndForcePushDisabled)
|
||||
return
|
||||
@ -846,7 +846,7 @@ func getSuggestedRemote(remotes []*models.Remote) string {
|
||||
}
|
||||
|
||||
func (gui *Gui) requestToForcePush() error {
|
||||
forcePushDisabled := gui.Config.GetUserConfig().Git.DisableForcePushing
|
||||
forcePushDisabled := gui.UserConfig.Git.DisableForcePushing
|
||||
if forcePushDisabled {
|
||||
return gui.createErrorPanel(gui.Tr.ForcePushDisabled)
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func (gui *Gui) prevScreenMode() error {
|
||||
|
||||
func (gui *Gui) scrollUpView(view *gocui.View) error {
|
||||
ox, oy := view.Origin()
|
||||
newOy := int(math.Max(0, float64(oy-gui.Config.GetUserConfig().Gui.ScrollHeight)))
|
||||
newOy := int(math.Max(0, float64(oy-gui.UserConfig.Gui.ScrollHeight)))
|
||||
return view.SetOrigin(ox, newOy)
|
||||
}
|
||||
|
||||
@ -86,12 +86,12 @@ func (gui *Gui) scrollDownView(view *gocui.View) error {
|
||||
func (gui *Gui) linesToScrollDown(view *gocui.View) int {
|
||||
_, oy := view.Origin()
|
||||
y := oy
|
||||
canScrollPastBottom := gui.Config.GetUserConfig().Gui.ScrollPastBottom
|
||||
canScrollPastBottom := gui.UserConfig.Gui.ScrollPastBottom
|
||||
if !canScrollPastBottom {
|
||||
_, sy := view.Size()
|
||||
y += sy
|
||||
}
|
||||
scrollHeight := gui.Config.GetUserConfig().Gui.ScrollHeight
|
||||
scrollHeight := gui.UserConfig.Gui.ScrollHeight
|
||||
scrollableLines := view.ViewLinesHeight() - y
|
||||
if scrollableLines < 0 {
|
||||
return 0
|
||||
|
@ -47,7 +47,7 @@ func (gui *Gui) RunAndStream(cmdObj oscommands.ICmdObj, waitingStatus string, on
|
||||
_ = gui.refreshSidePanels(refreshOptions{mode: ASYNC})
|
||||
return gui.surfaceError(
|
||||
fmt.Errorf(
|
||||
gui.Tr.GitCommandFailed, gui.Config.GetUserConfig().Keybinding.Universal.ExtrasMenu,
|
||||
gui.Tr.GitCommandFailed, gui.UserConfig.Keybinding.Universal.ExtrasMenu,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -120,6 +120,8 @@ type Gui struct {
|
||||
suggestionsAsyncHandler *tasks.AsyncHandler
|
||||
|
||||
PopupHandler PopupHandler
|
||||
|
||||
IsNewRepo bool
|
||||
}
|
||||
|
||||
type listPanelState struct {
|
||||
@ -371,7 +373,7 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) {
|
||||
}
|
||||
}
|
||||
|
||||
showTree := gui.Config.GetUserConfig().Gui.ShowFileTree
|
||||
showTree := gui.UserConfig.Gui.ShowFileTree
|
||||
|
||||
contexts := gui.contextTree()
|
||||
|
||||
@ -455,7 +457,7 @@ func NewGui(cmn *common.Common, gitCommand *commands.GitCommand, oSCommand *osco
|
||||
gui.OnRunCommand = onRunCommand
|
||||
gui.PopupHandler = &RealPopupHandler{gui: gui}
|
||||
|
||||
authors.SetCustomAuthors(gui.Config.GetUserConfig().Gui.AuthorColors)
|
||||
authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors)
|
||||
|
||||
return gui, nil
|
||||
}
|
||||
@ -505,7 +507,7 @@ func (gui *Gui) Run() error {
|
||||
if err := gui.Config.ReloadUserConfig(); err != nil {
|
||||
return nil
|
||||
}
|
||||
userConfig := gui.Config.GetUserConfig()
|
||||
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)
|
||||
@ -521,7 +523,7 @@ func (gui *Gui) Run() error {
|
||||
}
|
||||
|
||||
gui.waitForIntro.Add(1)
|
||||
if gui.Config.GetUserConfig().Git.AutoFetch {
|
||||
if gui.UserConfig.Git.AutoFetch {
|
||||
go utils.Safe(gui.startBackgroundFetch)
|
||||
}
|
||||
|
||||
@ -707,8 +709,8 @@ func (gui *Gui) goEvery(interval time.Duration, stop chan struct{}, function fun
|
||||
|
||||
func (gui *Gui) startBackgroundFetch() {
|
||||
gui.waitForIntro.Wait()
|
||||
isNew := gui.Config.GetIsNewRepo()
|
||||
userConfig := gui.Config.GetUserConfig()
|
||||
isNew := gui.IsNewRepo
|
||||
userConfig := gui.UserConfig
|
||||
if !isNew {
|
||||
time.After(time.Duration(userConfig.Refresher.FetchInterval) * time.Second)
|
||||
}
|
||||
@ -729,7 +731,7 @@ func (gui *Gui) startBackgroundFetch() {
|
||||
|
||||
// setColorScheme sets the color scheme for the app based on the user config
|
||||
func (gui *Gui) setColorScheme() error {
|
||||
userConfig := gui.Config.GetUserConfig()
|
||||
userConfig := gui.UserConfig
|
||||
theme.UpdateTheme(userConfig.Gui.Theme)
|
||||
|
||||
gui.g.FgColor = theme.InactiveBorderColor
|
||||
|
@ -204,7 +204,7 @@ func (gui *Gui) getKey(key string) interface{} {
|
||||
|
||||
// GetInitialKeybindings is a function.
|
||||
func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
config := gui.Config.GetUserConfig().Keybinding
|
||||
config := gui.UserConfig.Keybinding
|
||||
|
||||
bindings := []*Binding{
|
||||
{
|
||||
|
@ -374,7 +374,7 @@ func (gui *Gui) onInitialViewsCreation() error {
|
||||
return err
|
||||
}
|
||||
|
||||
if !gui.Config.GetUserConfig().DisableStartupPopups {
|
||||
if !gui.UserConfig.DisableStartupPopups {
|
||||
popupTasks := []func(chan struct{}) error{}
|
||||
storedPopupVersion := gui.Config.GetAppState().StartupPopupVersion
|
||||
if storedPopupVersion < StartupPopupVersion {
|
||||
|
@ -145,7 +145,7 @@ func (gui *Gui) tagsListContext() IListContext {
|
||||
}
|
||||
|
||||
func (gui *Gui) branchCommitsListContext() IListContext {
|
||||
parseEmoji := gui.Config.GetUserConfig().Git.ParseEmoji
|
||||
parseEmoji := gui.UserConfig.Git.ParseEmoji
|
||||
return &ListContext{
|
||||
BasicContext: &BasicContext{
|
||||
ViewName: "commits",
|
||||
@ -188,7 +188,7 @@ func (gui *Gui) branchCommitsListContext() IListContext {
|
||||
}
|
||||
|
||||
func (gui *Gui) subCommitsListContext() IListContext {
|
||||
parseEmoji := gui.Config.GetUserConfig().Git.ParseEmoji
|
||||
parseEmoji := gui.UserConfig.Git.ParseEmoji
|
||||
return &ListContext{
|
||||
BasicContext: &BasicContext{
|
||||
ViewName: "branches",
|
||||
@ -229,7 +229,7 @@ func (gui *Gui) subCommitsListContext() IListContext {
|
||||
}
|
||||
|
||||
func (gui *Gui) shouldShowGraph() bool {
|
||||
value := gui.Config.GetUserConfig().Git.Log.ShowGraph
|
||||
value := gui.UserConfig.Git.Log.ShowGraph
|
||||
switch value {
|
||||
case "always":
|
||||
return true
|
||||
@ -244,7 +244,7 @@ func (gui *Gui) shouldShowGraph() bool {
|
||||
}
|
||||
|
||||
func (gui *Gui) reflogCommitsListContext() IListContext {
|
||||
parseEmoji := gui.Config.GetUserConfig().Git.ParseEmoji
|
||||
parseEmoji := gui.UserConfig.Git.ParseEmoji
|
||||
return &ListContext{
|
||||
BasicContext: &BasicContext{
|
||||
ViewName: "commits",
|
||||
@ -387,7 +387,7 @@ func (gui *Gui) getListContexts() []IListContext {
|
||||
func (gui *Gui) getListContextKeyBindings() []*Binding {
|
||||
bindings := make([]*Binding, 0)
|
||||
|
||||
keybindingConfig := gui.Config.GetUserConfig().Keybinding
|
||||
keybindingConfig := gui.UserConfig.Keybinding
|
||||
|
||||
for _, listContext := range gui.getListContexts() {
|
||||
listContext := listContext
|
||||
|
@ -29,7 +29,7 @@ func (i *menuItem) ID() string {
|
||||
// specific functions
|
||||
|
||||
func (gui *Gui) getMenuOptions() map[string]string {
|
||||
keybindingConfig := gui.Config.GetUserConfig().Keybinding
|
||||
keybindingConfig := gui.UserConfig.Keybinding
|
||||
|
||||
return map[string]string{
|
||||
gui.getKeyDisplay(keybindingConfig.Universal.Return): gui.Tr.LcClose,
|
||||
|
@ -227,7 +227,7 @@ func (gui *Gui) centerYPos(view *gocui.View, y int) {
|
||||
}
|
||||
|
||||
func (gui *Gui) getMergingOptions() map[string]string {
|
||||
keybindingConfig := gui.Config.GetUserConfig().Keybinding
|
||||
keybindingConfig := gui.UserConfig.Keybinding
|
||||
|
||||
return map[string]string{
|
||||
fmt.Sprintf("%s %s", gui.getKeyDisplay(keybindingConfig.Universal.PrevItem), gui.getKeyDisplay(keybindingConfig.Universal.NextItem)): gui.Tr.LcSelectHunk,
|
||||
|
@ -73,6 +73,6 @@ func (gui *Gui) createPullRequest(from string, to string) error {
|
||||
|
||||
func (gui *Gui) getHostingServiceMgr() *hosting_service.HostingServiceMgr {
|
||||
remoteUrl := gui.GitCommand.GetRemoteURL()
|
||||
configServices := gui.Config.GetUserConfig().Services
|
||||
configServices := gui.UserConfig.Services
|
||||
return hosting_service.NewHostingServiceMgr(gui.Log, gui.Tr, remoteUrl, configServices)
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ func (gui *Gui) handleTopLevelReturn() error {
|
||||
return gui.dispatchSwitchToRepo(path, true)
|
||||
}
|
||||
|
||||
if gui.Config.GetUserConfig().QuitOnTopLevelReturn {
|
||||
if gui.UserConfig.QuitOnTopLevelReturn {
|
||||
return gui.handleQuit()
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ func (gui *Gui) quit() error {
|
||||
return gui.createUpdateQuitConfirmation()
|
||||
}
|
||||
|
||||
if gui.Config.GetUserConfig().ConfirmOnQuit {
|
||||
if gui.UserConfig.ConfirmOnQuit {
|
||||
return gui.ask(askOpts{
|
||||
title: "",
|
||||
prompt: gui.Tr.ConfirmQuit,
|
||||
|
@ -57,7 +57,7 @@ func (gui *Gui) genericMergeCommand(command string) error {
|
||||
// we should end up with a command like 'git merge --continue'
|
||||
|
||||
// it's impossible for a rebase to require a commit so we'll use a subprocess only if it's a merge
|
||||
if status == commands.REBASE_MODE_MERGING && command != REBASE_OPTION_ABORT && gui.Config.GetUserConfig().Git.Merging.ManualCommit {
|
||||
if status == commands.REBASE_MODE_MERGING && command != REBASE_OPTION_ABORT && gui.UserConfig.Git.Merging.ManualCommit {
|
||||
sub := gitCommand.NewCmdObj("git " + commandType + " --" + command)
|
||||
if sub != nil {
|
||||
return gui.runSubprocessWithSuspenseAndRefresh(sub)
|
||||
|
@ -39,7 +39,7 @@ func (gui *Gui) handleCreateRecentReposMenu() error {
|
||||
|
||||
func (gui *Gui) handleShowAllBranchLogs() error {
|
||||
cmdObj := gui.OSCommand.NewCmdObj(
|
||||
gui.Config.GetUserConfig().Git.AllBranchesLogCmd,
|
||||
gui.UserConfig.Git.AllBranchesLogCmd,
|
||||
)
|
||||
task := NewRunPtyTask(cmdObj.GetCmd())
|
||||
|
||||
@ -113,7 +113,7 @@ func (gui *Gui) updateRecentRepoList() error {
|
||||
return err
|
||||
}
|
||||
known, recentRepos := newRecentReposList(recentRepos, currentRepo)
|
||||
gui.Config.SetIsNewRepo(known)
|
||||
gui.IsNewRepo = known
|
||||
gui.Config.GetAppState().RecentRepos = recentRepos
|
||||
return gui.Config.SaveAppState()
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ func (gui *Gui) handleSearch() error {
|
||||
}
|
||||
|
||||
func (gui *Gui) onSelectItemWrapper(innerFunc func(int) error) func(int, int, int) error {
|
||||
keybindingConfig := gui.Config.GetUserConfig().Keybinding
|
||||
keybindingConfig := gui.UserConfig.Keybinding
|
||||
|
||||
return func(y int, index int, total int) error {
|
||||
if total == 0 {
|
||||
|
@ -100,7 +100,7 @@ func (gui *Gui) handleResetSelection() error {
|
||||
return gui.applySelection(true, state)
|
||||
}
|
||||
|
||||
if !gui.Config.GetUserConfig().Gui.SkipUnstageLineWarning {
|
||||
if !gui.UserConfig.Gui.SkipUnstageLineWarning {
|
||||
return gui.ask(askOpts{
|
||||
title: gui.Tr.UnstageLinesTitle,
|
||||
prompt: gui.Tr.UnstageLinesPrompt,
|
||||
|
@ -45,7 +45,7 @@ func (gui *Gui) refreshStashEntries() error {
|
||||
// specific functions
|
||||
|
||||
func (gui *Gui) handleStashApply() error {
|
||||
skipStashWarning := gui.Config.GetUserConfig().Gui.SkipStashWarning
|
||||
skipStashWarning := gui.UserConfig.Gui.SkipStashWarning
|
||||
|
||||
apply := func() error {
|
||||
return gui.stashDo("apply")
|
||||
@ -65,7 +65,7 @@ func (gui *Gui) handleStashApply() error {
|
||||
}
|
||||
|
||||
func (gui *Gui) handleStashPop() error {
|
||||
skipStashWarning := gui.Config.GetUserConfig().Gui.SkipStashWarning
|
||||
skipStashWarning := gui.UserConfig.Gui.SkipStashWarning
|
||||
|
||||
pop := func() error {
|
||||
return gui.stashDo("pop")
|
||||
|
@ -36,7 +36,7 @@ func (gui *Gui) onBackgroundUpdateCheckFinish(newVersion string, err error) erro
|
||||
if newVersion == "" {
|
||||
return nil
|
||||
}
|
||||
if gui.Config.GetUserConfig().Update.Method == "background" {
|
||||
if gui.UserConfig.Update.Method == "background" {
|
||||
gui.startUpdating(newVersion)
|
||||
return nil
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ func (gui *Gui) renderDisplayStringsAtPos(v *gocui.View, y int, displayStrings [
|
||||
}
|
||||
|
||||
func (gui *Gui) globalOptionsMap() map[string]string {
|
||||
keybindingConfig := gui.Config.GetUserConfig().Keybinding
|
||||
keybindingConfig := gui.UserConfig.Keybinding
|
||||
|
||||
return map[string]string{
|
||||
fmt.Sprintf("%s/%s", gui.getKeyDisplay(keybindingConfig.Universal.ScrollUpMain), gui.getKeyDisplay(keybindingConfig.Universal.ScrollDownMain)): gui.Tr.LcScroll,
|
||||
|
Loading…
x
Reference in New Issue
Block a user