Skip to content

Address issue #214: Fix copy-paste regression in editor#220

Merged
schuyler merged 1 commit intomainfrom
claude/resolve-issue-214-X4mbS
Dec 21, 2025
Merged

Address issue #214: Fix copy-paste regression in editor#220
schuyler merged 1 commit intomainfrom
claude/resolve-issue-214-X4mbS

Conversation

@schuyler
Copy link
Copy Markdown
Owner

Summary

  • Fixed a regression in MPEditorView.m where the writeSelectionToPasteboard:types: method completely replaced NSTextView's implementation instead of extending it
  • The bug was introduced in commit bd2e293 (issue Use net.daringfireball.markdown UTType when copying to pasteboard #196: Add markdown UTType support)
  • Copy-paste broke because the override only handled NSPasteboardTypeString and kMPMarkdownPasteboardType, ignoring other types NSTextView normally handles (RTF, attributed strings, etc.)

The fix: Call super first to let NSTextView handle standard pasteboard operations, then add the markdown type on top using addTypes:owner: which preserves existing pasteboard data.

Related Issue

Related to #214

Manual Testing Plan

Smoke Test (minimum)

  1. Basic copy-paste - Copy text, paste within same document → works
  2. Cut operation - Cut text, paste elsewhere → text removed and pasted
  3. Cross-app paste - Copy from MacDown, paste to TextEdit → works
  4. Markdown syntax - Copy **bold** *italic*, paste → syntax preserved

Regression Comparison

  • Build broken version (bd2e293): Copy-paste fails
  • Build fixed version: Copy-paste works

Markdown UTType Verification (issue #196)

  • Copy from MacDown to a Markdown-aware app (Bear, Ulysses)
  • Should recognize content as Markdown

Review Notes

  • Code Review: Approved - fix follows standard Cocoa pattern of calling super first then extending behavior
  • Documentation: No updates needed
  • Architecture: The fix properly delegates to NSTextView for standard types while preserving markdown interoperability

The writeSelectionToPasteboard:types: override introduced in commit bd2e293
completely replaced NSTextView's implementation instead of extending it.
This broke standard copy-paste because it only handled NSPasteboardTypeString
and the markdown type, ignoring other types NSTextView normally handles.

The fix calls super first to let NSTextView handle standard pasteboard
operations (plain text, RTF, attributed strings, etc.), then adds our
markdown type on top using addTypes:owner: which preserves existing data.

Related to #214
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 20, 2025

Code Coverage Report

Current Coverage: 42.58%

Coverage Details (Summary)
Name                                                                                                                                   Coverage            
-------------------------------------------------------------------------------------------------------------------------------------- ------------------- 
MASPreferences.bundle                                                                                                                  0.00% (0/0)         
MacDown 3000.app                                                                                                                       54.72% (6801/12429) 
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Extension/DOMNode+Text.m                                                   0.00% (0/94)        
        -[NSString(WordCount) numberOfWords]                                                                                           0.00% (0/11)        
        __36-[NSString(WordCount) numberOfWords]_block_invoke                                                                          0.00% (0/3)         
        -[NSString(WordCount) lengthWithoutNewlines]                                                                                   0.00% (0/11)        
        __44-[NSString(WordCount) lengthWithoutNewlines]_block_invoke                                                                  0.00% (0/3)         
        -[NSString(WordCount) lengthWithoutWhitespacesAndNewlines]                                                                     0.00% (0/11)        
        __58-[NSString(WordCount) lengthWithoutWhitespacesAndNewlines]_block_invoke                                                    0.00% (0/3)         
        MPGetChildrenNodetextCount                                                                                                     0.00% (0/6)         
        MPGetNodeTextCount                                                                                                             0.00% (0/38)        
        -[DOMNode(Text) textCount]                                                                                                     0.00% (0/8)         
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Utility/MPMathJaxListener.m                                                0.00% (0/26)        
        -[MPMathJaxListener callbacks]                                                                                                 0.00% (0/5)         
        -[MPMathJaxListener addCallback:forKey:]                                                                                       0.00% (0/3)         
        -[MPMathJaxListener invokeCallbackForKey:]                                                                                     0.00% (0/8)         
        +[MPMathJaxListener isSelectorExcludedFromWebScript:]                                                                          0.00% (0/5)         
        +[MPMathJaxListener isKeyExcludedFromWebScript:]                                                                               0.00% (0/5)         
    /Users/runner/work/macdown3000/macdown3000/Dependency/peg-markdown-highlight/HGMarkdownHighlightingStyle.m                         87.69% (57/65)      
        +[HGMarkdownHighlightingStyle colorFromARGBColor:]                                                                             100.00% (6/6)       
        -[HGMarkdownHighlightingStyle initWithType:attributesToAdd:toRemove:fontTraitsToAdd:]                                          88.89% (8/9)        
        -[HGMarkdownHighlightingStyle initWithStyleAttributes:baseFont:]                                                               86.00% (43/50)      
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Extension/hoedown_html_patch.c                                             73.64% (95/129)     
        hoedown_patch_render_blockcode                                                                                                 89.09% (49/55)      
        hoedown_patch_render_listitem                                                                                                  100.00% (46/46)     
        hoedown_patch_render_toc_header                                                                                                0.00% (0/28)        
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Application/MPMainController.m                                             40.76% (97/238)     
        MPOpenBundledFile                                                                                                              95.24% (20/21)      
        __MPOpenBundledFile_block_invoke                                                                                               85.71% (6/7)        
        treat                                                                                                                          20.00% (6/30)       
        __treat_block_invoke                                                                                                           0.00% (0/3)         
        -[MPMainController applicationDidFinishLaunching:]                                                                             100.00% (6/6)       
        -[MPMainController openUrlSchemeAppleEvent:withReplyEvent:]                                                                    0.00% (0/45)        
        __59-[MPMainController openUrlSchemeAppleEvent:withReplyEvent:]_block_invoke                                                   0.00% (0/7)         
        -[MPMainController valueForKey:fromQueryItems:]                                                                                0.00% (0/5)         
        -[MPMainController preferences]                                                                                                100.00% (3/3)       
        -[MPMainController preferencesWindowController]                                                                                0.00% (0/18)        
        -[MPMainController showPreferencesWindow:]                                                                                     0.00% (0/2)         
        -[MPMainController showHelp:]                                                                                                  100.00% (3/3)       
        -[MPMainController showContributing:]                                                                                          100.00% (3/3)       
        -[MPMainController init]                                                                                                       90.91% (10/11)      
        -[MPMainController applicationShouldOpenUntitledFile:]                                                                         80.00% (4/5)        
        -[MPMainController applicationDidBecomeActive:]                                                                                100.00% (5/5)       
        -[MPMainController copyFiles]                                                                                                  63.33% (19/30)      
        -[MPMainController openPendingFiles]                                                                                           29.41% (5/17)       
        -[MPMainController openPendingPipedContent]                                                                                    28.57% (4/14)       
        -[MPMainController showFirstLaunchTips]                                                                                        100.00% (3/3)       
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Utility/MPUtilities.m                                                      63.12% (101/160)    

... (2113 more lines truncated)

📊 **Full coverage report available in workflow artifacts**

@schuyler
Copy link
Copy Markdown
Owner Author

Closes #214

@schuyler schuyler merged commit d67c9b4 into main Dec 21, 2025
5 checks passed
@schuyler schuyler mentioned this pull request Dec 21, 2025
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