▍ humdrum codex / glint v1.0.2
license AGPL-3.0

feat: Esc clears the active selection (TASK-028)

f744adce9f2fd7696619f682cd63442577cec2a6
Kevin Kortum <kevinkortum@me.com> · 2026-06-29 16:22

parent 0938ecf7

feat: Esc clears the active selection (TASK-028)

In editor mode Esc now clears a Shift-arrow selection (find still closes first
when in find mode). Documented in README.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KjNrdAWUdkaxFyGdrPHaBj

4 files changed

README.md +1 −1
@@ -66,7 +66,7 @@ | `Ctrl+N` | new note in the current directory (a typed picker query becomes its name) |
 | `Ctrl+B` | new note in the inbox |
 | `Ctrl+T` | cycle theme (flexoki-light → flexoki-dark → charm) |
 | `Ctrl+Q` | quit (press twice if there are unsaved changes) |
-| `Esc` | back to the editor |
+| `Esc` | clear the selection, or close find / back to the editor |
 
 ## Configuration
 
- → Esc-clears-the-active-selection.md +25 −0
@@ -0,0 +1,25 @@
+---
+id: TASK-028
+title: Esc clears the active selection
+status: "\U0001F3C1 Done"
+assignee: []
+created_date: '2026-06-29 23:22'
+updated_date: '2026-06-29 23:22'
+labels:
+  - feature
+dependencies: []
+priority: low
+ordinal: 28000
+---
+
+## Description
+
+<!-- SECTION:DESCRIPTION:BEGIN -->
+In the editor, Esc now clears an active (Shift-arrow) selection instead of doing nothing. Priority: close find first if in find mode, else clear selection.
+<!-- SECTION:DESCRIPTION:END -->
+
+## Acceptance Criteria
+<!-- AC:BEGIN -->
+- [x] #1 Esc clears an active selection in editor mode
+- [x] #2 Esc still closes find when in find mode
+<!-- AC:END -->
internal/app/app.go +2 −0
@@ -262,6 +262,8 @@ 		return a.openFind()
 	case tea.KeyEsc:
 		if a.mode == ModeFind {
 			a.editor.ClearFind()
+		} else if a.editor.HasSelection() {
+			a.editor.ClearSelection()
 		}
 		a.mode = ModeEditor
 		return a, nil
internal/app/status_test.go +18 −0
@@ -100,3 +100,21 @@ 			t.Fatalf("status line width %d > 20: %q", w, line)
 		}
 	}
 }
+
+func TestEscClearsSelection(t *testing.T) {
+	a := statusApp()
+	a.editor.SetContent([]byte("hello world"))
+	for i := 0; i < 5; i++ { // select "hello" with Shift+Right
+		a.editor.HandleKey(tea.KeyMsg{Type: tea.KeyShiftRight})
+	}
+	if !a.editor.HasSelection() {
+		t.Fatal("setup: expected a selection")
+	}
+	a.handleKey(tea.KeyMsg{Type: tea.KeyEsc})
+	if a.editor.HasSelection() {
+		t.Fatal("Esc should clear the selection")
+	}
+	if a.mode != ModeEditor {
+		t.Fatalf("mode = %v, want ModeEditor", a.mode)
+	}
+}