From 0091757e18bd3f555d38a681f696f89aa7ab44dc Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 20 Aug 2026 19:02:25 +0200 Subject: [PATCH] Expose the missing whole-file semantics in the focused diff The patch-building panel could move an added file as a file, while selecting every visible change through the focused diff currently moves only its content and leaves the empty file behind. Keep the intended index state beside the current one so the replacement flow demonstrates that gap before it is fixed. Co-Authored-By: GitHub Copilot --- .../move_patch_to_index.go} | 45 ++++++++----------- pkg/integration/tests/test_list.go | 2 +- 2 files changed, 20 insertions(+), 27 deletions(-) rename pkg/integration/tests/{patch_building/move_to_index.go => main_view/move_patch_to_index.go} (68%) diff --git a/pkg/integration/tests/patch_building/move_to_index.go b/pkg/integration/tests/main_view/move_patch_to_index.go similarity index 68% rename from pkg/integration/tests/patch_building/move_to_index.go rename to pkg/integration/tests/main_view/move_patch_to_index.go index f51ad4819..d6fae2f32 100644 --- a/pkg/integration/tests/patch_building/move_to_index.go +++ b/pkg/integration/tests/main_view/move_patch_to_index.go @@ -1,11 +1,11 @@ -package patch_building +package main_view import ( "github.com/jesseduffield/lazygit/pkg/config" . "github.com/jesseduffield/lazygit/pkg/integration/components" ) -var MoveToIndex = NewIntegrationTest(NewIntegrationTestArgs{ +var MovePatchToIndex = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Move a patch from a commit to the index", ExtraCmdArgs: []string{}, Skip: false, @@ -30,39 +30,32 @@ var MoveToIndex = NewIntegrationTest(NewIntegrationTestArgs{ Contains("file1"), Contains("file2"), ). - SelectNextItem(). + Press(keys.Universal.FocusMainView) + + t.Views().Main(). + IsFocused(). + SelectedLines(Contains("+file1 content")). PressPrimaryAction() t.Views().Information().Content(Contains("Building patch")) - t.Views().Secondary().Content(Contains("+file1 content")) t.Common().SelectPatchOption(Contains("Move patch out into index")) - t.Views().Files(). - Lines( - Contains("A").Contains("file1"), - ) - - t.Views().CommitFiles(). - IsFocused(). - Lines( - Contains("file2").IsSelected(), - ). - PressEscape() - + t.Views().Files().Lines( + /* EXPECTED: + Contains("A").Contains("file1"), + ACTUAL: */ + Contains("M").Contains("file1"), + ) t.Views().Main(). + IsFocused(). Content(Contains("+file2 content")) + t.Views().Commits().Lines( + Contains("first commit").IsSelected(), + ) - t.Views().Commits(). - Lines( - Contains("first commit").IsSelected(), - ) - - t.Views().Files(). - Focus() - - t.Views().Secondary(). - Content(Contains("file1 content")) + t.Views().Files().Focus() + t.Views().Secondary().Content(Contains("file1 content")) }, }) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 936d9aa60..39c4b9420 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -410,6 +410,7 @@ var tests = []*components.IntegrationTest{ main_view.KeepSelectionAfterMovingPatchOut, main_view.KeepSelectionVisibleWhenDiffShrinks, main_view.MoveOnWhenThePatchMarksRewrapTheDiff, + main_view.MovePatchToIndex, main_view.NavigateByHunkAndFile, main_view.NoSelectionOverABinaryDiff, main_view.NoSelectionOverACommitLog, @@ -477,7 +478,6 @@ var tests = []*components.IntegrationTest{ patch_building.MoveRangeToIndex, patch_building.MoveToEarlierCommit, patch_building.MoveToEarlierCommitFromAddedFile, - patch_building.MoveToIndex, patch_building.MoveToIndexFromAddedFileWithConflict, patch_building.MoveToIndexPartOfAdjacentAddedLines, patch_building.MoveToIndexPartial,