Skip to content

Fix/markdown code fence crash#88

Merged
RobertoMachorro merged 3 commits into
masterfrom
fix/markdown-code-fence-crash
Jul 12, 2026
Merged

Fix/markdown code fence crash#88
RobertoMachorro merged 3 commits into
masterfrom
fix/markdown-code-fence-crash

Conversation

@RobertoMachorro

Copy link
Copy Markdown
Owner

No description provided.

RobertoMachorro and others added 2 commits July 11, 2026 20:29
Applying `.foregroundColor` via NSTextLayoutManager.addRenderingAttribute in
STTextView-Plugin-Neon crashes on macOS 26 (NSInvalidArgumentException,
"attempt to insert nil object") for Markdown fenced-code-block tokens. The
crashing line lives in the remote plugin package, already pinned to its newest
revision, so repoint the dependency to a patched fork that applies foreground
as a regular text attribute (like other attributes) instead of a rendering
attribute, and keeps clearStyle consistent.

Fork: RobertoMachorro/STTextView-Plugin-Neon @ fix/markdown-code-fence-crash

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`updateNSView` sets `textView.text` from the model, which fires
`textViewDidChangeText` synchronously and wrote the identical value back to
`model.content`. Re-publishing an unchanged value mutated the model inside a
view update ("Publishing changes from within view updates is not allowed").
Skip the write-back when the content is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@RobertoMachorro RobertoMachorro self-assigned this Jul 12, 2026
Copilot AI review requested due to automatic review settings July 12, 2026 00:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a crash/regression related to Markdown editing and SwiftUI update cycles by preventing redundant model write-backs from the editor delegate, and by updating the STTextView Neon plugin dependency to a different upstream/revision.

Changes:

  • Avoid re-publishing model.content when STTextView change notifications are triggered by programmatic replaceContent during updateNSView.
  • Update the STTextView-Plugin-Neon SwiftPM package source URL and pinned revision.
  • Refresh SwiftPM resolution metadata (Package.resolved origin hash / pin state).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Moped/TextEditorRepresentable.swift Skips writing back identical content to avoid SwiftUI “publishing changes from within view updates” crashes.
Moped.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved Updates the resolved pin to a new STTextView-Plugin-Neon repository URL and revision.
Moped.xcodeproj/project.pbxproj Updates the Xcode Swift package reference to the new STTextView-Plugin-Neon repository URL and pinned revision.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Moped/TextEditorRepresentable.swift Outdated
Address Copilot review feedback on #88: comparing the whole buffer
(`model.content != newText`) on every keystroke is O(n) and contradicts the
`programmaticChangeID` fast-path in `updateNSView`. Instead set an
`isApplyingProgrammaticText` flag around the programmatic `textView.text`
assignments (initial build and `replaceContent`); the text-change delegate
checks the flag to skip echoing the model's own content back during a view update.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@RobertoMachorro RobertoMachorro merged commit 46782b0 into master Jul 12, 2026
1 check passed
@RobertoMachorro RobertoMachorro deleted the fix/markdown-code-fence-crash branch July 12, 2026 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants