Skip to content

Commit 0f32298

Browse files
committed
feat(editor): do not exit on Esc
It is not common for TUI text editors to exit when the user presses the Escape key once. Emacs, nano, and Vim don't do it. Muscle memory can lead the user to press Escape and exit accidentally.
1 parent acf77f5 commit 0f32298

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ The editor includes the following key bindings.
461461
#### Session
462462

463463
- **Ctrl+D**: Save and exit
464-
- **Esc**/**Ctrl+C**: Exit without saving
464+
- **Ctrl+C**: Exit without saving
465465

466466
#### Navigation
467467

editor.png

-1.59 KB
Loading

editor/editor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ type editor struct {
2525
type cancelError struct{}
2626

2727
const (
28-
bannerNoSave = "[ Ctrl+V: Paste ] [ Esc: Cancel ]"
29-
bannerSave = "[ Ctrl+D: Save ] [ Ctrl+V: Paste ] [ Esc: Cancel ]"
28+
bannerNoSave = "[ Ctrl+V: Paste ] [ Ctrl+C: Cancel ]"
29+
bannerSave = "[ Ctrl+D: Save ] [ Ctrl+V: Paste ] [ Ctrl+C: Cancel ]"
3030
editorCharLimit = 1 << 16
3131
)
3232

@@ -48,7 +48,7 @@ func (e editor) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
4848
case tea.KeyMsg:
4949
switch msg.Type {
5050

51-
case tea.KeyEsc, tea.KeyCtrlC:
51+
case tea.KeyCtrlC:
5252
e.err = CancelError
5353
return e, tea.Quit
5454

0 commit comments

Comments
 (0)