From c0d230777af5912e4ffd93106ac3729f737ab226 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 7 Oct 2026 13:52:02 +0200 Subject: [PATCH] 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) --- .../stage_diff_lines_with_custom_prefixes.go | 49 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 50 insertions(+) create mode 100644 pkg/integration/tests/main_view/stage_diff_lines_with_custom_prefixes.go diff --git a/pkg/integration/tests/main_view/stage_diff_lines_with_custom_prefixes.go b/pkg/integration/tests/main_view/stage_diff_lines_with_custom_prefixes.go new file mode 100644 index 000000000..9d5c063c3 --- /dev/null +++ b/pkg/integration/tests/main_view/stage_diff_lines_with_custom_prefixes.go @@ -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"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 0791cd001..39b2cb5a8 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -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,