diff --git a/internal/control/cli/controller.go b/internal/control/cli/controller.go index 5675e26b..2b7ec038 100644 --- a/internal/control/cli/controller.go +++ b/internal/control/cli/controller.go @@ -115,6 +115,7 @@ func NewController( "C": "delete-to-end-and-insert", "c$": "delete-to-end-and-insert", "c0": "backspace-to-beginning-and-insert", + "S": "delete-everything-and-insert", "x": "delete-rune", "s": "delete-rune-and-insert", "i": "swap-mode-insert", diff --git a/internal/control/edit/editors/string_editor.go b/internal/control/edit/editors/string_editor.go index cd79f408..f13f8761 100644 --- a/internal/control/edit/editors/string_editor.go +++ b/internal/control/edit/editors/string_editor.go @@ -118,6 +118,12 @@ func (e *StringEditor) BackspaceToBeginning() { e.CursorPos = 0 } +// DeleteEverything deletes all runes in the editor. +func (e *StringEditor) DeleteEverything() { + e.Content = "" + e.CursorPos = 0 +} + // DeleteToEnd deletes all runes after the cursor position. func (e *StringEditor) DeleteToEnd() { nameBeforeCursor := []rune(e.Content)[:e.CursorPos] @@ -283,6 +289,8 @@ func (e *StringEditor) CreateInputProcessor(cfg input.InputConfig) (input.ModalI "quit": e.Quit, "backspace": e.BackspaceRune, "backspace-to-beginning": e.BackspaceToBeginning, + "delete-everything": e.DeleteEverything, + "delete-everything-and-insert": func() { e.DeleteEverything(); enterInsertMode() }, "backspace-to-beginning-and-insert": func() { e.BackspaceToBeginning(); enterInsertMode() }, "delete-rune": e.DeleteRune, "delete-rune-and-insert": func() { e.DeleteRune(); enterInsertMode() },