Repository navigation
mac editor: Tab accepts the fix at the caret (#277) - #445
Merged
Merged
Conversation
A quick fix was something you went and found in the Problems panel and
clicked. This offers it where the author is typing and accepts it with Tab.
The affordance is drawn before it can be accepted: when the caret is on a
diagnostic that carries a mechanical edit, the fix appears after that line as
`⇥ \alpha`, in the accent colour, next to the error-lens message when one is
showing. It is drawn whatever the error-lens preference says, because Tab acts
on it — a hint the author has switched off, silently arming a key, is the bug
this feature could most easily have been. `ShellModel.caretFix` is the single
value that both draws the hint and arms the key, so the two cannot disagree.
Tab's precedence, in order:
1. an input-method composition — untouched, Tab never reaches this code;
2. a snippet placeholder (`CompletingTextView.keyDown`) — modal, mid-edit;
3. the completion list (`CompletingTextView.keyDown`, and `handleTab`'s own
`isCompletionActive` guard) — modal, the author is looking at it;
4. **the fix at the caret** — new;
5. indent a multi-line selection;
6. insert an indent unit at the caret.
Step 4 only takes the key on three conditions, so Tab never does something
invisible: a fix is actually offered (and Esc has not taken it down), the
selection is empty, and it is Tab rather than ⇧Tab. A multi-line selection is
unambiguously "indent this block" and keeps the key; ⇧Tab always outdents.
With nothing offered this falls straight through and Tab indents exactly as
before. Esc takes the hint down — ahead of Esc's other meaning, opening the
completion list — and Tab indents again until the caret moves onto another fix.
Accepting routes through `previewQuickFix` + `applyQuickFix`, the panel's own
path, rather than a second application path, so the edit ledger, the revision
counter and undo behave identically: one undo step.
The gate is also why this had nothing to accept before. `canApplyHelpReplacement`
required `help.replacement`, but the app attaches `flashtex-render` by default
(`ShellModel.locateDefaultProducer` prefers it over the compiler), and
`display::Diagnostic` has no `help` field — the render pipeline builds against
the pinned `vendor/compiler`, which has no `DiagnosticHelp` type at all. The
wire carries only the flat `suggestion`. Measured on that wire, a `\alpah` typo
arrives as `suggestion: "\alpha"` over `source` bytes 44..50 — exactly the
command token — and `has_help=false`. `mechanicalEdit` already understood that
form; only the gate did not, so the affordance was unreachable in the shipping
configuration. It now asks `mechanicalEdit`, which accepts both forms. The
compiler sets `suggestion` at exactly one site (`Diagnostic::command_error`),
where the span is the command token, so this is the same edit
`help.replacement` would have carried.
`caretFix` bails out before `caretByte` — a conversion linear in the document —
unless some diagnostic actually carries an edit, because it is read on every
keystroke.
Verified on mac-m1max-a: swift build clean; swift test --skip
NearbyInterfaceTests --skip NearbyLANInterfaceTests.
Implementation-Agent: Claude Opus 5 (lane quick-fix-tab, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
Contributor
|
daniel-parent: an overlap note, nothing blocking. This PR and my #423 (code folding) both edit |
d-q222
added a commit
that referenced
this pull request
Sep 14, 2026
Merged origin/main (includes #413 Re-indent, #419 duplicate line, #442 Vim status line, #445 caret fix). Conflict in apps/mac/README.md: kept both the ⌘L Go to Line row (ours) and the ⌃I / Re-indent Document rows (theirs). AccessibilityCommands.swift and CommandPalette.swift auto-merged with both enum cases, entries, and palette actions. Ran: cd apps/mac && swift test --filter 'GoToLineTests|CommandTableTests' Executed 17 tests, with 0 failures (0 unexpected) in 0.125 (0.126) seconds. grep -rn '<<<<<<<\|>>>>>>>' apps/mac: empty. README shortcuts unique. Next: merge origin/main into editor-folding (#423). Implementation-Agent: cursor-agent cursor-grok-4.6 Commit-Executor: cursor-agent Lane-Owner: daniel-parent (mac-m5pro-dq222) Co-authored-by: Cursor <[email protected]>
d-q222
added a commit
that referenced
this pull request
Sep 14, 2026
…stics beside links Merged origin/main (7f67984) into agent/daniel-parent/mac-v2-diagnostics. Conflicts: EditorDiagnostics.swift — kept main's CaretFix/fixOffered (#445) and mechanicalEdit from both forms (help.replacement else suggestion). PreviewV2View.swift — request display-list-v2 + images + links + diagnostics. RenderingV2.swift — both diagnosticsCapability and linksCapability (Mac/iOS share the file via hardlink). EditorDiagnosticsQuickFixTests.swift — kept #363 suggestion/help-wins mapping test (not a second Tab-accept path). V2ImageTests.swift — suffix(4) includes links and diagnostics. display.rs — kept producer comment (suggestion serialised only when Wire.diagnostics is set); #358 merge is next and will take that file. Ran: git merge origin/main (conflicted, then resolved as above). Tests not run on this checkpoint. Next: git merge origin/agent/daniel-parent/v2-structured-diagnostics (ef130a7); take #358's display.rs on any conflict. Open questions: whether document-runtime should also allowlist display-list-v2-links (main requests it; this crate still does not). Out of #363 scope unless the producer merge requires it. Implementation-Agent: cursor-agent cursor-grok-4.6 Commit-Executor: cursor-agent Lane-Owner: daniel-parent (mac-m5pro-dq222) Co-authored-by: Cursor <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A quick fix was something you went and found in the Problems panel and clicked.
This offers it where the author is typing, and accepts it with Tab.
Tab's precedence
Tab is heavily overloaded, so the order is explicit:
CompletingTextView.keyDown) — modal, mid-edit;CompletingTextView.keyDown, andhandleTab's ownisCompletionActiveguard) — modal, the author is looking at it;Completion and snippets keep the key because they are modal and the author is
mid-interaction. Step 4 takes it from indentation only on three conditions, so
Tab never does something invisible:
block", never "fix a word in it";
With nothing offered,
handleTabfalls straight through and Tab indents exactlyas before. Esc takes the hint down — ahead of Esc's other meaning, opening
the completion list — and Tab indents again until the caret moves onto another
fix.
Seeing it before accepting it
With the caret on (or directly either side of) a diagnostic that carries a
mechanical edit, the fix is drawn after that line as
⇥ \alphain the accentcolour, beside the error-lens message when one is showing.
It is drawn whatever the error-lens preference says, because Tab acts on it.
A hint the author has switched off, silently arming a key, is the bug this
feature could most easily have been — so it does not ride on an optional
affordance.
ShellModel.caretFixis the single value that both draws the hintand arms the key, so the two cannot disagree.
The hint extends the existing
ErrorLensPainterrather than adding a secondpainter:
foregroundDecoratoris a single slot, and a new painter would havesilently displaced the error lens.
One undo step
Accepting routes through
previewQuickFix+applyQuickFix— the panel's ownpath — rather than a second application path, so the edit ledger, the revision
counter and undo behave identically.
Why this had nothing to accept before
canApplyHelpReplacementrequiredhelp.replacement. But the app attachesflashtex-renderby default (ShellModel.locateDefaultProducerprefers it overthe compiler), and
display::Diagnostichas nohelpfield — the renderpipeline builds against the pinned
vendor/compiler, which has noDiagnosticHelptype at all. Measured on that wire, a\alpahtypo arrives as:{"code":"unknown_command","message":"\\alpah is not supported...", "source":{"start_byte":44,"end_byte":50,"path":"main.tex"},"suggestion":"\\alpha"} has_suggestion=true has_help=falseBytes 44..50 are exactly the command token.
mechanicalEditalready understoodthat flat form; only the gate did not, so the affordance — and the panel's
"Fix…" button with it — was unreachable in the shipping configuration. The gate
now asks
mechanicalEdit, which accepts both forms. The compiler setssuggestionat exactly one site (Diagnostic::command_error), where the spanis the command token, so this is the same edit
help.replacementwould carry.caretFixbails out beforecaretByte— a conversion linear in the document —unless some diagnostic actually carries an edit, because it is read on every
keystroke.
Verified
swift buildclean.swift test --skip NearbyInterfaceTests --skip NearbyLANInterfaceTestson mac-m1max-a:faa7d484): 1136 tests, 2 failuresThe 2 failures are identical on both and pre-existing —
CommandTableTestsasserting that
⌥⇧↓/⌥⇧↑(#419) are documented in the README. Nothing to dowith this change.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu