Skip to content

Commit 0156169

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 0f8b50a commit 0156169

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,12 @@ cap_mkdb /etc/login.conf
458458
![Screenshot of the editor in a terminal showing a TOML entry.
459459
The TOML entry has a password "hunter2" and a test TOTP URL.](editor.png)
460460

461-
The editor includes the following key bindings.
461+
The editor has the following key bindings:
462462

463463
#### Session
464464

465+
- **Ctrl+C**: Exit without saving
465466
- **Ctrl+D**: Save and exit
466-
- **Esc**/**Ctrl+C**: Exit without saving
467467

468468
#### Navigation
469469

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)