fix(editor): surface failed save-and-exit error; characterize completion accept after left-move #26

Merged
fiatcode merged 2 commits from fix/editor-review-bugs into main 2026-06-18 16:30:37 +07:00
Owner

Implements Section 1 (Bugs) of the 2026-06-18 weft code-review follow-up. Executed via subagent-driven-development (TDD, per-task spec+quality review, final whole-branch review — all clean).

Task 1 — surface failed save-and-exit error (fix)

In EditorView.Update, the confirmingExit case "s" returned the save+exit result without resetting e.mode to editing. On a write failure the App keeps the editor open and calls SetError, but statusLine() only renders errMsg in editing mode — in confirmingExit it kept showing the "Save changes?" prompt, so the save error was invisible and s silently retried the failing write. Fix: reset to editing before returning. On the success path the App tears the editor down, so the reset is harmless. Verified against the App save/error path (app.go): on failure it SetErrors and returns before the Exit teardown.

Task 2 — characterize completion accept after cursor left-move (test only)

Accepting a completion after moving the cursor left within the typed partial relocates the trailing runes after the closed link ([[Alph, Left×2, accept Alpha[[Alpha]]ph). This is structurally identical to the intentionally-supported mid-line accept (a[[Alpha]]b), and acceptCompletion cannot distinguish the two at accept time. A characterization test pins the current behavior so any future change is a conscious decision.

Decision: kept current behavior (no change to acceptCompletion). The alternative "consume the contiguous token" rule would delete pre-existing user text in the mid-line case (a[[Alpha]]ba[[Alpha]]) — data loss in a common path to fix a non-destructive surprise in a rare one. If ever worth fixing, the right approach is an anchor (track where [[ opened), not token-consume — a separate, larger change.

Verification

  • go vet ./... clean; go test ./... all packages pass.
  • Additive only: editor.go +6, editor_view_test.go +45.

Commits:

  • fix(editor): surface failed save-and-exit error instead of confirm prompt
  • test(editor): characterize completion accept after cursor left-move
Implements Section 1 (Bugs) of the 2026-06-18 weft code-review follow-up. Executed via subagent-driven-development (TDD, per-task spec+quality review, final whole-branch review — all clean). ## Task 1 — surface failed save-and-exit error (fix) In `EditorView.Update`, the `confirmingExit` `case "s"` returned the save+exit result without resetting `e.mode` to `editing`. On a write failure the App keeps the editor open and calls `SetError`, but `statusLine()` only renders `errMsg` in `editing` mode — in `confirmingExit` it kept showing the "Save changes?" prompt, so the save error was invisible and `s` silently retried the failing write. Fix: reset to `editing` before returning. On the success path the App tears the editor down, so the reset is harmless. Verified against the App save/error path (`app.go`): on failure it `SetError`s and returns before the `Exit` teardown. ## Task 2 — characterize completion accept after cursor left-move (test only) Accepting a completion after moving the cursor left within the typed partial relocates the trailing runes after the closed link (`[[Alph`, Left×2, accept `Alpha` → `[[Alpha]]ph`). This is structurally identical to the intentionally-supported mid-line accept (`a[[Alpha]]b`), and `acceptCompletion` cannot distinguish the two at accept time. A characterization test pins the current behavior so any future change is a conscious decision. **Decision: kept current behavior (no change to `acceptCompletion`).** The alternative "consume the contiguous token" rule would delete pre-existing user text in the mid-line case (`a[[Alpha]]b` → `a[[Alpha]]`) — data loss in a common path to fix a non-destructive surprise in a rare one. If ever worth fixing, the right approach is an anchor (track where `[[` opened), not token-consume — a separate, larger change. ## Verification - `go vet ./...` clean; `go test ./...` all packages pass. - Additive only: `editor.go` +6, `editor_view_test.go` +45. Commits: - fix(editor): surface failed save-and-exit error instead of confirm prompt - test(editor): characterize completion accept after cursor left-move
test(editor): characterize completion accept after cursor left-move
All checks were successful
CI / vet-and-test (pull_request) Successful in 28s
da4b9e5bc6
Pins the current behavior of acceptCompletion when the cursor is moved
left inside the typed partial before accepting: the tail runes ("ph")
are placed after the closed link, yielding "[[Alpha]]ph". This is
structurally identical to the deliberate mid-line-accept behavior and
is documented here so any future change is a conscious decision.

Expected string "[[Alpha]]ph" matched reality as-written — no
adjustment was needed.
fiatcode deleted branch fix/editor-review-bugs 2026-06-18 16:30:37 +07:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
fiatcode/weft!26
No description provided.