From 621d7993b26e80791af71e83e28c4a63fe9220b6 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 7 Oct 2026 13:49:41 +0200 Subject: [PATCH] Add a test for staging a line with diff.noprefix set If diff.noprefix is set, pressing space on a line of a file under a top-level directory named a or b does nothing. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../stage_diff_lines_with_no_prefixes.go | 50 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 51 insertions(+) create mode 100644 pkg/integration/tests/main_view/stage_diff_lines_with_no_prefixes.go diff --git a/pkg/integration/tests/main_view/stage_diff_lines_with_no_prefixes.go b/pkg/integration/tests/main_view/stage_diff_lines_with_no_prefixes.go new file mode 100644 index 000000000..7da4ba77b --- /dev/null +++ b/pkg/integration/tests/main_view/stage_diff_lines_with_no_prefixes.go @@ -0,0 +1,50 @@ +package main_view + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var StageDiffLinesWithNoPrefixes = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Stage a line of a file in a directory named b from the focused main view when diff.noprefix is set", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Gui.UseHunkModeInDiffView = false + }, + SetupRepo: func(shell *Shell) { + shell.CreateFileAndAdd("b/file1", "one\ntwo\nthree\n") + shell.Commit("one") + + shell.UpdateFile("b/file1", "one\nADD1\nADD2\ntwo\nthree\n") + + // git then leaves out the a/ and b/ in front of the paths of a diff. The b/ + // that the paths of this file start with is its directory. + shell.SetConfig("diff.noprefix", "true") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Files(). + IsFocused(). + Lines( + Contains("▼ b").IsSelected(), + Contains(" M file1"), + ). + SelectNextItem(). + Press(keys.Universal.FocusMainView) + + t.Views().Main(). + IsFocused(). + SelectedLines( + Contains("+ADD1"), + ). + PressPrimaryAction() + + t.Views().Files().Lines( + Contains("▼ b"), + /* 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 54fe8f2b3..bf1450119 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -487,6 +487,7 @@ var tests = []*components.IntegrationTest{ main_view.StageDeletedFile, main_view.StageDiffLines, main_view.StageDiffLinesOfAPathWithASpace, + main_view.StageDiffLinesWithNoPrefixes, main_view.StageHunksWithRapidKeypresses, main_view.StagePartialBlockOfChangesFirstLines, main_view.StagePartialBlockOfChangesLastLines,