diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-12-29 11:50:20 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-04 09:07:15 +1100 |
commit | 01ea5813a8e3b8e914332002e744e3328f55f6cd (patch) | |
tree | 5684bcf7f081c5230518394ddc732316e36674e7 /pkg | |
parent | 03b946cc8f9e94fe3fd53ac619ace2af2662aac2 (diff) |
align Gui struct with GitCommand
Diffstat (limited to 'pkg')
29 files changed, 78 insertions, 93 deletions
diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index cb740fd62..7ce467335 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -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 } diff --git a/pkg/gui/arrangement.go b/pkg/gui/arrangement.go index db1c3c172..fa2e7f29d 100644 --- a/pkg/gui/arrangement.go +++ b/pkg/gui/arrangement.go @@ -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{ diff --git a/pkg/gui/command_log_panel.go b/pkg/gui/command_log_panel.go index 261ceda90..08e09dd90 100644 --- a/pkg/gui/command_log_panel.go +++ b/pkg/gui/command_log_panel.go @@ -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) diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go index 9e74f26f9..f12d0f28f 100644 --- a/pkg/gui/commit_message_panel.go +++ b/pkg/gui/commit_message_panel.go @@ -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 } diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 8f65ab56e..edff7a055 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -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}}) }) diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go index c540aa0d0..bf17bcc52 100644 --- a/pkg/gui/confirmation_panel.go +++ b/pkg/gui/confirmation_panel.go @@ -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) diff --git a/pkg/gui/credentials_panel.go b/pkg/gui/credentials_panel.go index 320f535f5..2570a53e3 100644 --- a/pkg/gui/credentials_panel.go +++ b/pkg/gui/credentials_panel.go @@ -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, diff --git a/pkg/gui/custom_commands.go b/pkg/gui/custom_commands.go index 06526b6f0..3abeee28a 100644 --- a/pkg/gui/custom_commands.go +++ b/pkg/gui/custom_commands.go @@ -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 diff --git a/pkg/gui/diff_context_size.go b/pkg/gui/diff_context_size.go index fdf147496..5e37c18af 100644 --- a/pkg/gui/diff_context_size.go +++ b/pkg/gui/diff_context_size.go @@ -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() } diff --git a/pkg/gui/diff_context_size_test.go b/pkg/gui/diff_context_size_test.go index 6007228a4..bab2fd553 100644 --- a/pkg/gui/diff_context_size_test.go +++ b/pkg/gui/diff_context_size_test.go @@ -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) } diff --git a/pkg/gui/editors.go b/pkg/gui/editors.go index 430dcfdfe..054a36094 100644 --- a/pkg/gui/editors.go +++ b/pkg/gui/editors.go @@ -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 } diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 91415e1a7..977f23cae 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -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) } diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go index e0f05ca44..83abe6535 100644 --- a/pkg/gui/global_handlers.go +++ b/pkg/gui/global_handlers.go @@ -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 diff --git a/pkg/gui/gpg.go b/pkg/gui/gpg.go index 9bd8b5d15..942a5bb89 100644 --- a/pkg/gui/gpg.go +++ b/pkg/gui/gpg.go @@ -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, ), ) } diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 259bfb411..243af8b84 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -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 diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 6a65e63fc..7e39edffc 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -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{ { diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go index 59c6a761e..ffcace092 100644 --- a/pkg/gui/layout.go +++ b/pkg/gui/layout.go @@ -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 { diff --git a/pkg/gui/list_context_config.go b/pkg/gui/list_context_config.go index cd936623c..cb6a55d53 100644 --- a/pkg/gui/list_context_config.go +++ b/pkg/gui/list_context_config.go @@ -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 diff --git a/pkg/gui/menu_panel.go b/pkg/gui/menu_panel.go index 45b5cbf50..be17d352d 100644 --- a/pkg/gui/menu_panel.go +++ b/pkg/gui/menu_panel.go @@ -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{ |