summaryrefslogtreecommitdiffstats
path: root/pkg/integration
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2024-01-14 13:28:30 +1100
committerJesse Duffield <jessedduffield@gmail.com>2024-01-19 10:47:21 +1100
commitd08fafb1c446572c40151e88f8025e28a62bd819 (patch)
treee601682b8b74e4cf577ac77d660c4044f6da5632 /pkg/integration
parentf3eb180f75496637719895902abf76af10b8425f (diff)
Clear range select upon pressing 'escape'
This is the highest priority of the escape actions because it's the thing you're most likely to want to do upon hitting escape if you have a range selected. Applying this to the staging/patch-building views is tricky: if we want this logic for when a range of lines is selected, we'll also need to apply it when a hunk is selected too. I still think it's worth it though: I've often accidentally escaped from the staging view when trying to cancel a range selection.
Diffstat (limited to 'pkg/integration')
-rw-r--r--pkg/integration/tests/patch_building/specific_selection.go8
-rw-r--r--pkg/integration/tests/ui/range_select.go26
2 files changed, 29 insertions, 5 deletions
diff --git a/pkg/integration/tests/patch_building/specific_selection.go b/pkg/integration/tests/patch_building/specific_selection.go
index b9c9da8a6..a9dbf9f11 100644
--- a/pkg/integration/tests/patch_building/specific_selection.go
+++ b/pkg/integration/tests/patch_building/specific_selection.go
@@ -88,6 +88,9 @@ var SpecificSelection = NewIntegrationTest(NewIntegrationTestArgs{
Contains(" 1f"),
)
}).
+ // Cancel hunk select
+ PressEscape().
+ // Escape the view
PressEscape()
t.Views().CommitFiles().
@@ -97,11 +100,6 @@ var SpecificSelection = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().PatchBuilding().
IsFocused().
- // hunk is selected because selection mode persists across files
- ContainsLines(
- Contains("@@ -0,0 +1,26 @@").IsSelected(),
- ).
- Press(keys.Main.ToggleSelectHunk).
SelectedLines(
Contains("+2a"),
).
diff --git a/pkg/integration/tests/ui/range_select.go b/pkg/integration/tests/ui/range_select.go
index 84441701c..4885c7cb4 100644
--- a/pkg/integration/tests/ui/range_select.go
+++ b/pkg/integration/tests/ui/range_select.go
@@ -12,9 +12,11 @@ import (
// (no range, press arrow) -> no range
// (no range, press shift+arrow) -> nonsticky range
// (sticky range, press 'v') -> no range
+// (sticky range, press 'escape') -> no range
// (sticky range, press arrow) -> sticky range
// (sticky range, press shift+arrow) -> nonsticky range
// (nonsticky range, press 'v') -> no range
+// (nonsticky range, press 'escape') -> no range
// (nonsticky range, press arrow) -> no range
// (nonsticky range, press shift+arrow) -> nonsticky range
@@ -125,6 +127,30 @@ var RangeSelect = NewIntegrationTest(NewIntegrationTestArgs{
Press(keys.Universal.ToggleRangeSelect).
SelectedLines(
Contains("line 7"),
+ ).
+ Press(keys.Universal.RangeSelectDown).
+ SelectedLines(
+ Contains("line 7"),
+ Contains("line 8"),
+ ).
+ // (nonsticky range, press 'escape') -> no range
+ PressEscape().
+ SelectedLines(
+ Contains("line 8"),
+ ).
+ Press(keys.Universal.ToggleRangeSelect).
+ SelectedLines(
+ Contains("line 8"),
+ ).
+ SelectNextItem().
+ SelectedLines(
+ Contains("line 8"),
+ Contains("line 9"),
+ ).
+ // (sticky range, press 'escape') -> no range
+ PressEscape().
+ SelectedLines(
+ Contains("line 9"),
)
}