From b499eba1a8907db6ad95bec5bb0f8817145a327a Mon Sep 17 00:00:00 2001 From: stk Date: Tue, 14 Feb 2023 09:43:22 +0100 Subject: [PATCH] Select next stageable line correctly after staging a range of lines We already have this very convenient behavior of jumping to the next stageable line after staging something. However, while this worked well for staging single lines or hunks, it didn't work correctly when staging a range of lines; in this case we want to start searching from the first line of the range. --- pkg/gui/controllers/staging_controller.go | 3 ++- pkg/integration/tests/commit/stage_range_of_lines.go | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/gui/controllers/staging_controller.go b/pkg/gui/controllers/staging_controller.go index 78129ebe0..0a8ca5521 100644 --- a/pkg/gui/controllers/staging_controller.go +++ b/pkg/gui/controllers/staging_controller.go @@ -200,7 +200,8 @@ func (self *StagingController) applySelection(reverse bool) error { } if state.SelectingRange() { - state.SetLineSelectMode() + firstLine, _ := state.SelectedRange() + state.SelectLine(firstLine) } return nil diff --git a/pkg/integration/tests/commit/stage_range_of_lines.go b/pkg/integration/tests/commit/stage_range_of_lines.go index 8c7b9c8a6..ef63b4838 100644 --- a/pkg/integration/tests/commit/stage_range_of_lines.go +++ b/pkg/integration/tests/commit/stage_range_of_lines.go @@ -34,9 +34,6 @@ var StageRangeOfLines = NewIntegrationTest(NewIntegrationTestArgs{ Content( Contains(" 3rd\n 4th\n-5th\n+5th changed\n 6th"), ). - /* EXPECTED: SelectedLine(Equals("-5th")) - ACTUAL */ - SelectedLine(Equals("+5th changed")) }, })