diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-10-23 12:45:02 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-10-23 12:54:57 +1100 |
commit | 3eb124c732326d3680465c864fe6d0c1422d07bd (patch) | |
tree | 03c04194583aefecb807881f16e1ef4ac755b177 /pkg | |
parent | ef544e6ce961add2fcac4004ba6587b2de378e64 (diff) |
easier hiding of command logv0.30
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/config/app_config.go | 13 | ||||
-rw-r--r-- | pkg/config/dummies.go | 1 | ||||
-rw-r--r-- | pkg/gui/extras_panel.go | 9 | ||||
-rw-r--r-- | pkg/gui/gui.go | 2 | ||||
-rw-r--r-- | pkg/i18n/english.go | 2 |
5 files changed, 21 insertions, 6 deletions
diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 74f675576..b1b1acb0c 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -45,6 +45,7 @@ type AppConfigurer interface { SetIsNewRepo(bool) GetIsNewRepo() bool ReloadUserConfig() error + ShowCommandLogOnStartup() bool } // NewAppConfig makes a new app config @@ -276,6 +277,17 @@ func (c *AppConfig) SaveAppState() error { return err } +// originally we could only hide the command log permanently via the config +// but now we do it via state. So we need to still support the config for the +// sake of backwards compatibility +func (c *AppConfig) ShowCommandLogOnStartup() bool { + if !c.UserConfig.Gui.ShowCommandLog { + return false + } + + return !c.AppState.HideCommandLog +} + // loadAppState loads recorded AppState from file func loadAppState() (*AppState, error) { filepath, err := configFilePath("state.yml") @@ -314,6 +326,7 @@ type AppState struct { // these are for custom commands typed in directly, not for custom commands in the lazygit config CustomCommandsHistory []string + HideCommandLog bool } func getDefaultAppState() *AppState { diff --git a/pkg/config/dummies.go b/pkg/config/dummies.go index 40548d732..bd973909a 100644 --- a/pkg/config/dummies.go +++ b/pkg/config/dummies.go @@ -14,6 +14,7 @@ func NewDummyAppConfig() *AppConfig { Debug: false, BuildSource: "", UserConfig: GetDefaultConfig(), + AppState: &AppState{}, } _ = yaml.Unmarshal([]byte{}, appConfig.AppState) return appConfig diff --git a/pkg/gui/extras_panel.go b/pkg/gui/extras_panel.go index 463da4c55..ee106223e 100644 --- a/pkg/gui/extras_panel.go +++ b/pkg/gui/extras_panel.go @@ -11,15 +11,16 @@ func (gui *Gui) handleCreateExtrasMenuPanel() error { return err } } - gui.ShowExtrasWindow = !gui.ShowExtrasWindow + show := !gui.ShowExtrasWindow + gui.ShowExtrasWindow = show + gui.Config.GetAppState().HideCommandLog = !show + _ = gui.Config.SaveAppState() return nil }, }, { displayString: gui.Tr.FocusCommandLog, - onPress: func() error { - return gui.handleFocusCommandLog() - }, + onPress: gui.handleFocusCommandLog, }, } diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 1349920e5..4212d3dcd 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -440,7 +440,7 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom RepoPathStack: []string{}, RepoStateMap: map[Repo]*guiState{}, CmdLog: []string{}, - ShowExtrasWindow: config.GetUserConfig().Gui.ShowCommandLog, + ShowExtrasWindow: config.ShowCommandLogOnStartup(), suggestionsAsyncHandler: tasks.NewAsyncHandler(), } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index a0a485c60..2f72c151c 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -945,7 +945,7 @@ func englishTranslationSet() TranslationSet { CommandLog: "Command Log", ToggleShowCommandLog: "Toggle show/hide command log", FocusCommandLog: "Focus command log", - CommandLogHeader: "You can hide/focus this panel by pressing '%s' or hide it permanently in your config with `gui.showCommandLog: false`\n", + CommandLogHeader: "You can hide/focus this panel by pressing '%s'\n", RandomTip: "Random Tip", SelectParentCommitForMerge: "Select parent commit for merge", ToggleWhitespaceInDiffView: "Toggle whether or not whitespace changes are shown in the diff view", |