From c431698dba30ca7d3df09ec560d452cc77891ded Mon Sep 17 00:00:00 2001 From: Aaron Hoffman Date: Tue, 30 Jan 2024 21:56:12 -0600 Subject: [PATCH] Fix range select bug After discarding file changes from the commit, the was still referencing these indexes as being part of the range select. The consequence was needing to hit escape twice to exit commit files in some situations. Canceling the range select after discarding changes fixes that. --- pkg/gui/controllers/commits_files_controller.go | 5 ++++- pkg/integration/tests/commit/discard_old_file_changes.go | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 2a5b8139a..59e0a7f4e 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -217,7 +217,10 @@ func (self *CommitFilesController) discard(selectedNodes []*filetree.CommitFileN return err } - return self.c.Refresh(types.RefreshOptions{Mode: types.BLOCK_UI}) + if self.context().RangeSelectEnabled() { + self.context().GetList().CancelRangeSelect() + } + return self.c.Refresh(types.RefreshOptions{Mode: types.SYNC}) }) }, }) diff --git a/pkg/integration/tests/commit/discard_old_file_changes.go b/pkg/integration/tests/commit/discard_old_file_changes.go index 4b97a30b7..1ab189264 100644 --- a/pkg/integration/tests/commit/discard_old_file_changes.go +++ b/pkg/integration/tests/commit/discard_old_file_changes.go @@ -105,9 +105,6 @@ var DiscardOldFileChanges = NewIntegrationTest(NewIntegrationTestArgs{ Lines( Contains("(none)"), ). - // for some reason I need to press escape twice. Seems like it happens every time - // more than one file is removed from a commit - PressEscape(). PressEscape() // Check removing multiple files from 2 directories w/ a custom patch.