diff --git a/pkg/gui/controllers/patch_building_controller.go b/pkg/gui/controllers/patch_building_controller.go index 94f987404..8b27c941a 100644 --- a/pkg/gui/controllers/patch_building_controller.go +++ b/pkg/gui/controllers/patch_building_controller.go @@ -155,6 +155,8 @@ func (self *PatchBuildingController) toggleSelection() error { state.SetLineSelectMode() } + state.SelectNextStageableLine() + return nil } diff --git a/pkg/gui/patch_exploring/state.go b/pkg/gui/patch_exploring/state.go index 53e120849..b76bdd568 100644 --- a/pkg/gui/patch_exploring/state.go +++ b/pkg/gui/patch_exploring/state.go @@ -324,3 +324,9 @@ func wrapPatchLines(diff string, view *gocui.View) ([]int, []int) { view.Wrap, view.Editable, strings.TrimSuffix(diff, "\n"), view.InnerWidth(), view.TabWidth) return viewLineIndices, patchLineIndices } + +func (s *State) SelectNextStageableLine() { + _, lastLineIdx := s.SelectedPatchRange() + patchLineIdx := s.patch.GetNextChangeIdx(lastLineIdx + 1) + s.SelectLine(s.viewLineIndices[patchLineIdx]) +} diff --git a/pkg/integration/tests/patch_building/move_to_index_partial.go b/pkg/integration/tests/patch_building/move_to_index_partial.go index 827a3aedb..409f86a57 100644 --- a/pkg/integration/tests/patch_building/move_to_index_partial.go +++ b/pkg/integration/tests/patch_building/move_to_index_partial.go @@ -48,7 +48,6 @@ var MoveToIndexPartial = NewIntegrationTest(NewIntegrationTestArgs{ Contains(`+third line2`), ). PressPrimaryAction(). - SelectNextItem(). PressPrimaryAction(). Tap(func() { t.Views().Information().Content(Contains("Building patch")) diff --git a/pkg/integration/tests/patch_building/specific_selection.go b/pkg/integration/tests/patch_building/specific_selection.go index 9027a34e6..5b4f62a03 100644 --- a/pkg/integration/tests/patch_building/specific_selection.go +++ b/pkg/integration/tests/patch_building/specific_selection.go @@ -66,18 +66,20 @@ var SpecificSelection = NewIntegrationTest(NewIntegrationTestArgs{ Contains(` 1f`), ). PressPrimaryAction(). - // unlike in the staging panel, we don't remove lines from the patch building panel - // upon 'adding' them. So the same lines will be selected SelectedLines( - Contains(`@@ -1,6 +1,6 @@`), - Contains(`-1a`), - Contains(`+aa`), - Contains(` 1b`), - Contains(`-1c`), - Contains(`+cc`), - Contains(` 1d`), - Contains(` 1e`), - Contains(` 1f`), + Contains(`@@ -17,9 +17,9 @@`), + Contains(` 1q`), + Contains(` 1r`), + Contains(` 1s`), + Contains(`-1t`), + Contains(`-1u`), + Contains(`-1v`), + Contains(`+tt`), + Contains(`+uu`), + Contains(`+vv`), + Contains(` 1w`), + Contains(` 1x`), + Contains(` 1y`), ). Tap(func() { t.Views().Information().Content(Contains("Building patch")) @@ -106,12 +108,21 @@ var SpecificSelection = NewIntegrationTest(NewIntegrationTestArgs{ Contains("+2a"), ). PressPrimaryAction(). + SelectedLines( + Contains("+2b"), + ). NavigateToLine(Contains("+2c")). Press(keys.Universal.ToggleRangeSelect). NavigateToLine(Contains("+2e")). PressPrimaryAction(). + SelectedLines( + Contains("+2f"), + ). NavigateToLine(Contains("+2g")). PressPrimaryAction(). + SelectedLines( + Contains("+2h"), + ). Tap(func() { t.Views().Information().Content(Contains("Building patch"))