Fix/markdown code fence crash#88
Merged
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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.contentwhenSTTextViewchange notifications are triggered by programmaticreplaceContentduringupdateNSView. - Update the STTextView-Plugin-Neon SwiftPM package source URL and pinned revision.
- Refresh SwiftPM resolution metadata (
Package.resolvedorigin 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.
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>
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.
No description provided.