Skip to content

Commit

Permalink
easier hiding of command log
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Oct 23, 2021
1 parent ef544e6 commit 3eb124c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
13 changes: 13 additions & 0 deletions pkg/config/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type AppConfigurer interface {
SetIsNewRepo(bool)
GetIsNewRepo() bool
ReloadUserConfig() error
ShowCommandLogOnStartup() bool
}

// NewAppConfig makes a new app config
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions pkg/config/dummies.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func NewDummyAppConfig() *AppConfig {
Debug: false,
BuildSource: "",
UserConfig: GetDefaultConfig(),
AppState: &AppState{},
}
_ = yaml.Unmarshal([]byte{}, appConfig.AppState)
return appConfig
Expand Down
9 changes: 5 additions & 4 deletions pkg/gui/extras_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 3eb124c

Please sign in to comment.