fix(editor): surface failed save-and-exit error; characterize completion accept after left-move #26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/editor-review-bugs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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, theconfirmingExitcase "s"returned the save+exit result without resettinge.modetoediting. On a write failure the App keeps the editor open and callsSetError, butstatusLine()only renderserrMsgineditingmode — inconfirmingExitit kept showing the "Save changes?" prompt, so the save error was invisible andssilently retried the failing write. Fix: reset toeditingbefore 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 itSetErrors and returns before theExitteardown.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, acceptAlpha→[[Alpha]]ph). This is structurally identical to the intentionally-supported mid-line accept (a[[Alpha]]b), andacceptCompletioncannot 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.editor.go+6,editor_view_test.go+45.Commits:
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.