diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2023-04-02 15:01:04 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2023-04-13 13:14:00 +0200 |
commit | 046b0d9daa46f2fa8da9f196dc50a5ae02239675 (patch) | |
tree | 02ee1dd14eaa3b04f048dac8785584a1a0abd471 /pkg/gui/gui.go | |
parent | e3c5e07b20aabd375db5ff3e84e89b0473274dba (diff) |
Show warning about deprecated edit configs
We print this to the terminal after lazygit quits rather than showing it in a
panel at startup, so as to not annoy people too much. Hopefully it will still be
prominent enough this way.
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r-- | pkg/gui/gui.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 69ff10c77..aed1d5430 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -495,6 +495,8 @@ func (gui *Gui) Run(startArgs appTypes.StartArgs) error { return err } + defer gui.checkForDeprecatedEditConfigs() + gui.g = g defer gui.g.Close() @@ -583,6 +585,37 @@ func (gui *Gui) RunAndHandleError(startArgs appTypes.StartArgs) error { }) } +func (gui *Gui) checkForDeprecatedEditConfigs() { + osConfig := &gui.UserConfig.OS + deprecatedConfigs := []struct { + config string + oldName string + newName string + }{ + {osConfig.EditCommand, "EditCommand", "Edit"}, + {osConfig.EditCommandTemplate, "EditCommandTemplate", "Edit,EditAtLine"}, + {osConfig.OpenCommand, "OpenCommand", "Open"}, + {osConfig.OpenLinkCommand, "OpenLinkCommand", "OpenLink"}, + } + deprecatedConfigStrings := []string{} + + for _, dc := range deprecatedConfigs { + if dc.config != "" { + deprecatedConfigStrings = append(deprecatedConfigStrings, fmt.Sprintf(" OS.%s -> OS.%s", dc.oldName, dc.newName)) + } + } + if len(deprecatedConfigStrings) != 0 { + warningMessage := utils.ResolvePlaceholderString( + gui.c.Tr.DeprecatedEditConfigWarning, + map[string]string{ + "configs": strings.Join(deprecatedConfigStrings, "\n"), + }, + ) + + os.Stdout.Write([]byte(warningMessage)) + } +} + // returns whether command exited without error or not func (gui *Gui) runSubprocessWithSuspenseAndRefresh(subprocess oscommands.ICmdObj) error { _, err := gui.runSubprocessWithSuspense(subprocess) |