Add a test for staging a line with diff.srcPrefix and diff.dstPrefix set

If diff.srcPrefix and diff.dstPrefix are set, pressing space on a line
in the focused main view does nothing.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Stefan Haller
2026-10-07 13:52:02 +02:00
co-authored by Claude Opus 5.5
parent 5cf1fbf168
commit c0d230777a
2 changed files with 50 additions and 0 deletions
@@ -0,0 +1,49 @@
package main_view
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var StageDiffLinesWithCustomPrefixes = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Stage a line from the focused main view when diff.srcPrefix and diff.dstPrefix are set",
ExtraCmdArgs: []string{},
Skip: false,
GitVersion: AtLeast("2.45.0"),
SetupConfig: func(cfg *config.AppConfig) {
cfg.GetUserConfig().Gui.UseHunkModeInDiffView = false
},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file1", "one\ntwo\nthree\n")
shell.Commit("one")
shell.UpdateFile("file1", "one\nADD1\nADD2\ntwo\nthree\n")
// git then puts these strings in front of the paths of a diff instead of
// a/ and b/. Without a slash, nothing tells where they end.
shell.SetConfig("diff.srcPrefix", "old:")
shell.SetConfig("diff.dstPrefix", "new:")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
IsFocused().
Lines(
Contains("file1").IsSelected(),
).
Press(keys.Universal.FocusMainView)
t.Views().Main().
IsFocused().
SelectedLines(
Contains("+ADD1"),
).
PressPrimaryAction()
t.Views().Files().Lines(
/* EXPECTED:
Contains("MM file1"),
ACTUAL: */
Contains(" M file1"),
)
},
})
+1
View File
@@ -488,6 +488,7 @@ var tests = []*components.IntegrationTest{
main_view.StageDeletedFile,
main_view.StageDiffLines,
main_view.StageDiffLinesOfAPathWithASpace,
main_view.StageDiffLinesWithCustomPrefixes,
main_view.StageDiffLinesWithNoPrefixes,
main_view.StageHunksWithRapidKeypresses,
main_view.StagePartialBlockOfChangesFirstLines,