feat(editor): spellcheck posture toggle (#77)
CI / ci (push) Canceled after 0s

Neo triage input: continuous spell checking off by default, on when
asked — markdown on disk already carries the spelling; squiggles are
a presentation choice, per-launch with no persistence.

Edit ▸ Check Spelling While Typing binds AppGateState.spellChecking
and applies it to the live NSTextView in makeNSView/updateNSView.
Commands views take gate as a plain property — @Environment lookups
trap at launch there (crash-verified).

Verified in-app: toggle -> live view flag true -> squiggles render.
(The initial "does nothing" report was a machine-level kill switch:
NSAllowContinuousSpellChecking=0 in the global defaults domain, since
deleted; no app code change was needed for that part.)

Closes #77 follow-up.
This commit is contained in:
AlexKucera committed 2026-10-08 17:36:57 +02:00
1 parent 49fab56452
commit c1f5d707f8
4 files changed
+46 -4

No files matched your search

+18 -3
View File
@@ -35,6 +35,9 @@ struct PostEditorView: View {
@State private var closeObserver: AnyCancellable?
@State private var toggleObserver: AnyCancellable?
/// #77: spellcheck posture (app-scoped, Edit menu) — applied to the live
/// text view on every representable update.
@Environment(AppGateState.self) private var gate
/// #68: reading is a transient act of inspection — no persistence; a
/// fresh open always lands in editing.
@State private var reading = false
@@ -107,9 +110,9 @@ struct PostEditorView: View {
@ViewBuilder
private var editingSurface: some View {
if let session {
ProseTextView(session: session, caretHint: flipBackCaret)
ProseTextView(session: session, spellChecking: gate.spellChecking, caretHint: flipBackCaret)
} else {
ProseTextView(draft: draftMirror, onEdit: { newText in
ProseTextView(draft: draftMirror, spellChecking: gate.spellChecking, onEdit: { newText in
draftMirror = newText
draftEdited?(newText)
}, caretHint: flipBackCaret)
@@ -238,19 +241,27 @@ struct ProseTextView: NSViewRepresentable {
var session: EditorSession?
var draft: String?
var onEdit: ((String) -> Void)?
var spellChecking = false
var caretHint: (location: Int, token: Int)?
init(session: EditorSession, caretHint: (location: Int, token: Int)? = nil) {
init(
session: EditorSession,
spellChecking: Bool = false,
caretHint: (location: Int, token: Int)? = nil,
) {
self.session = session
self.spellChecking = spellChecking
self.caretHint = caretHint
}
init(
draft: String,
spellChecking: Bool = false,
onEdit: @escaping (String) -> Void,
caretHint: (location: Int, token: Int)? = nil,
) {
self.draft = draft
self.spellChecking = spellChecking
self.onEdit = onEdit
self.caretHint = caretHint
}
@@ -273,6 +284,8 @@ struct ProseTextView: NSViewRepresentable {
tv.isAutomaticDashSubstitutionEnabled = false
tv.isAutomaticTextReplacementEnabled = false
tv.isAutomaticSpellingCorrectionEnabled = false
// #77: squiggles follow the posture toggle (default off).
tv.isContinuousSpellCheckingEnabled = spellChecking
tv.usesFindBar = true
tv.backgroundColor = NSColor.white
tv.typingAttributes = ProseTypography.bodyAttributes
@@ -305,6 +318,8 @@ struct ProseTextView: NSViewRepresentable {
func updateNSView(_ scroll: NSScrollView, context: Context) {
guard let tv = scroll.documentView as? NSTextView else { return }
// #77: posture toggle while editing — cheap idempotent set.
tv.isContinuousSpellCheckingEnabled = spellChecking
if let session {
context.coordinator.sessionRef = session
// Load only when the generation moved (open, Yes-reload) — never