1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-23 12:18:51 +02:00

easier hiding of command log

This commit is contained in:
Jesse Duffield 2021-10-23 12:45:02 +11:00
parent ef544e6ce9
commit 3eb124c732
5 changed files with 21 additions and 6 deletions

View File

@ -45,6 +45,7 @@ type AppConfigurer interface {
SetIsNewRepo(bool) SetIsNewRepo(bool)
GetIsNewRepo() bool GetIsNewRepo() bool
ReloadUserConfig() error ReloadUserConfig() error
ShowCommandLogOnStartup() bool
} }
// NewAppConfig makes a new app config // NewAppConfig makes a new app config
@ -276,6 +277,17 @@ func (c *AppConfig) SaveAppState() error {
return err 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 // loadAppState loads recorded AppState from file
func loadAppState() (*AppState, error) { func loadAppState() (*AppState, error) {
filepath, err := configFilePath("state.yml") 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 // these are for custom commands typed in directly, not for custom commands in the lazygit config
CustomCommandsHistory []string CustomCommandsHistory []string
HideCommandLog bool
} }
func getDefaultAppState() *AppState { func getDefaultAppState() *AppState {

View File

@ -14,6 +14,7 @@ func NewDummyAppConfig() *AppConfig {
Debug: false, Debug: false,
BuildSource: "", BuildSource: "",
UserConfig: GetDefaultConfig(), UserConfig: GetDefaultConfig(),
AppState: &AppState{},
} }
_ = yaml.Unmarshal([]byte{}, appConfig.AppState) _ = yaml.Unmarshal([]byte{}, appConfig.AppState)
return appConfig return appConfig

View File

@ -11,15 +11,16 @@ func (gui *Gui) handleCreateExtrasMenuPanel() error {
return err return err
} }
} }
gui.ShowExtrasWindow = !gui.ShowExtrasWindow show := !gui.ShowExtrasWindow
gui.ShowExtrasWindow = show
gui.Config.GetAppState().HideCommandLog = !show
_ = gui.Config.SaveAppState()
return nil return nil
}, },
}, },
{ {
displayString: gui.Tr.FocusCommandLog, displayString: gui.Tr.FocusCommandLog,
onPress: func() error { onPress: gui.handleFocusCommandLog,
return gui.handleFocusCommandLog()
},
}, },
} }

View File

@ -440,7 +440,7 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom
RepoPathStack: []string{}, RepoPathStack: []string{},
RepoStateMap: map[Repo]*guiState{}, RepoStateMap: map[Repo]*guiState{},
CmdLog: []string{}, CmdLog: []string{},
ShowExtrasWindow: config.GetUserConfig().Gui.ShowCommandLog, ShowExtrasWindow: config.ShowCommandLogOnStartup(),
suggestionsAsyncHandler: tasks.NewAsyncHandler(), suggestionsAsyncHandler: tasks.NewAsyncHandler(),
} }

View File

@ -945,7 +945,7 @@ func englishTranslationSet() TranslationSet {
CommandLog: "Command Log", CommandLog: "Command Log",
ToggleShowCommandLog: "Toggle show/hide command log", ToggleShowCommandLog: "Toggle show/hide command log",
FocusCommandLog: "Focus 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", RandomTip: "Random Tip",
SelectParentCommitForMerge: "Select parent commit for merge", SelectParentCommitForMerge: "Select parent commit for merge",
ToggleWhitespaceInDiffView: "Toggle whether or not whitespace changes are shown in the diff view", ToggleWhitespaceInDiffView: "Toggle whether or not whitespace changes are shown in the diff view",