diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2024-01-30 12:04:02 +0100 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-05-19 07:06:18 +0200 |
commit | da3e0f7147a3400374d643f6d746b0911fc5eaaa (patch) | |
tree | 1ccd6f79dab19d9d35dff4bf06ee3361b651a06b /pkg/integration | |
parent | 269d01233f94631289111cec893c28be2cb0b522 (diff) |
Support deleting items from the custom commands history
In the custom commands panel you can now tab to the suggestions and hit 'd' to
delete items from there. Useful if you mistyped a command and don't want it to
appear in your history any more.
Diffstat (limited to 'pkg/integration')
-rw-r--r-- | pkg/integration/components/prompt_driver.go | 9 | ||||
-rw-r--r-- | pkg/integration/tests/custom_commands/delete_from_history.go | 41 | ||||
-rw-r--r-- | pkg/integration/tests/test_list.go | 1 |
3 files changed, 51 insertions, 0 deletions
diff --git a/pkg/integration/components/prompt_driver.go b/pkg/integration/components/prompt_driver.go index 023c2f438..d1cce878c 100644 --- a/pkg/integration/components/prompt_driver.go +++ b/pkg/integration/components/prompt_driver.go @@ -82,3 +82,12 @@ func (self *PromptDriver) ConfirmSuggestion(matcher *TextMatcher) { NavigateToLine(matcher). PressEnter() } + +func (self *PromptDriver) DeleteSuggestion(matcher *TextMatcher) *PromptDriver { + self.t.press(self.t.keys.Universal.TogglePanel) + self.t.Views().Suggestions(). + IsFocused(). + NavigateToLine(matcher) + self.t.press(self.t.keys.Universal.Remove) + return self +} diff --git a/pkg/integration/tests/custom_commands/delete_from_history.go b/pkg/integration/tests/custom_commands/delete_from_history.go new file mode 100644 index 000000000..e90e6c3c6 --- /dev/null +++ b/pkg/integration/tests/custom_commands/delete_from_history.go @@ -0,0 +1,41 @@ +package custom_commands + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var DeleteFromHistory = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Delete an entry from the custom commands history", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) {}, + SetupConfig: func(cfg *config.AppConfig) {}, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + createCustomCommand := func(command string) { + t.GlobalPress(keys.Universal.ExecuteCustomCommand) + t.ExpectPopup().Prompt(). + Title(Equals("Custom command:")). + Type(command). + Confirm() + } + + createCustomCommand("echo 1") + createCustomCommand("echo 2") + createCustomCommand("echo 3") + + t.GlobalPress(keys.Universal.ExecuteCustomCommand) + t.ExpectPopup().Prompt(). + Title(Equals("Custom command:")). + SuggestionLines( + Contains("3"), + Contains("2"), + Contains("1"), + ). + DeleteSuggestion(Contains("2")). + SuggestionLines( + Contains("3"), + Contains("1"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 2548702e9..eae6a5f7b 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -105,6 +105,7 @@ var tests = []*components.IntegrationTest{ custom_commands.BasicCmdFromConfig, custom_commands.CheckForConflicts, custom_commands.ComplexCmdAtRuntime, + custom_commands.DeleteFromHistory, custom_commands.FormPrompts, custom_commands.History, custom_commands.MenuFromCommand, |