Skip to content

Commit 1805696

Browse files
committed
feat: add startup warning for unsupported delta --navigate config
1 parent 9e455f4 commit 1805696

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

pkg/gui/layout.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package gui
22

33
import (
44
"errors"
5+
"strings"
56

67
"github.com/jesseduffield/gocui"
78
"github.com/jesseduffield/lazygit/pkg/gui/types"
@@ -257,6 +258,8 @@ func (gui *Gui) onInitialViewsCreation() error {
257258
}
258259
}
259260

261+
gui.checkForDeltaNavigateWarning()
262+
260263
gui.c.GetAppState().LastVersion = gui.Config.GetVersion()
261264
gui.c.SaveAppStateAndLogError()
262265

@@ -274,6 +277,21 @@ func (gui *Gui) onInitialViewsCreation() error {
274277
return nil
275278
}
276279

280+
func (gui *Gui) checkForDeltaNavigateWarning() {
281+
userConfig := gui.c.UserConfig()
282+
for _, pagerConfig := range userConfig.Git.Pagers {
283+
pagerCmd := string(pagerConfig.Pager)
284+
if strings.Contains(pagerCmd, "delta") && strings.Contains(pagerCmd, "--navigate") {
285+
gui.c.Log.Warn("Configuration warning: 'delta --navigate' detected. This flag is not supported in lazygit as it requires interactive input that lazygit cannot forward to the pager subprocess.")
286+
gui.c.OnUIThread(func() error {
287+
gui.c.Alert(gui.c.Tr.DeltaNavigateWarningTitle, gui.c.Tr.DeltaNavigateWarning)
288+
return nil
289+
})
290+
return
291+
}
292+
}
293+
}
294+
277295
func (gui *Gui) transientContexts() []types.Context {
278296
return lo.Filter(gui.State.Contexts.Flatten(), func(context types.Context, _ int) bool {
279297
return context.IsTransient()

pkg/i18n/english.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ type TranslationSet struct {
250250
IntroPopupMessage string
251251
NonReloadableConfigWarningTitle string
252252
NonReloadableConfigWarning string
253+
DeltaNavigateWarningTitle string
254+
DeltaNavigateWarning string
253255
GitconfigParseErr string
254256
EditFile string
255257
EditFileTooltip string
@@ -1344,6 +1346,8 @@ func EnglishTranslationSet() *TranslationSet {
13441346
IntroPopupMessage: englishIntroPopupMessage,
13451347
NonReloadableConfigWarningTitle: "Config changed",
13461348
NonReloadableConfigWarning: englishNonReloadableConfigWarning,
1349+
DeltaNavigateWarningTitle: "Delta --navigate Not Supported",
1350+
DeltaNavigateWarning: "You have 'delta --navigate' configured as your pager.\n\nThe --navigate flag requires interactive keyboard input (n/N keys) that lazygit cannot forward to the subprocess.\n\nPlease remove '--navigate' from your pager configuration.",
13471351
GitconfigParseErr: `Gogit failed to parse your gitconfig file due to the presence of unquoted '\' characters. Removing these should fix the issue.`,
13481352
EditFile: `Edit file`,
13491353
EditFileTooltip: "Open file in external editor.",

0 commit comments

Comments
 (0)