Skip to content

Fix preview scroll jump when MathJax is enabled (#325)#330

Merged
schuyler merged 3 commits into
mainfrom
claude/issue-325-ZxTvL
Feb 26, 2026
Merged

Fix preview scroll jump when MathJax is enabled (#325)#330
schuyler merged 3 commits into
mainfrom
claude/issue-325-ZxTvL

Conversation

@schuyler

Copy link
Copy Markdown
Owner

Summary

  • Remove the MathJax bypass from the DOM replacement condition so MathJax-enabled documents use fast DOM replacement instead of a full WebView reload on every keystroke
  • Add a post-typesetting callback via MPMathJaxListener to update header locations after MathJax rendering changes document height, keeping scroll sync accurate
  • Save lastPreviewScrollTop during DOM replacement for scroll position preservation

Test plan

  • 11 new tests in MPMathJaxScrollTests.m covering DOM replacement condition logic, listener callbacks, state management, and scroll preservation
  • Verify CI passes on all macOS runners (macos-15, macos-15-intel, macos-26 already green; macos-14 pending runner)
  • Manual test: Open a document with MathJax equations, scroll to middle, type — preview should stay in place instead of jumping to top

Related to #325

https://claude.ai/code/session_01D99FSveFtEM8szRX6f74iN

Remove the MathJax exclusion from the DOM replacement condition so that
MathJax-enabled documents use the fast DOM replacement path instead of a
full WebView reload on every keystroke. The existing MathJax.Hub.Queue
mechanism correctly serializes async typesetting and scroll restoration.

Add a post-typesetting callback via MPMathJaxListener to update header
locations after MathJax rendering changes document height, ensuring
scroll sync remains accurate.

Related to #325

https://claude.ai/code/session_01D99FSveFtEM8szRX6f74iN
Add #import "MPRenderer.h" to resolve unknown type errors in tests.
Add clarifying comment about MathJaxListener overwriting safety.
Fix copyright year to 2026.

Related to #325

https://claude.ai/code/session_01D99FSveFtEM8szRX6f74iN
@schuyler schuyler force-pushed the claude/issue-325-ZxTvL branch from 07b6e3d to d1107ff Compare February 26, 2026 20:08
@github-actions

github-actions Bot commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Report

Current Coverage: 56.80%

Coverage Details (Summary)
Name                                                                                                                                   Coverage            
-------------------------------------------------------------------------------------------------------------------------------------- ------------------- 
MASPreferences.bundle                                                                                                                  0.00% (0/0)         
MacDown 3000.app                                                                                                                       59.64% (8185/13724) 
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Preferences/MPHtmlPreferencesViewController.m                              0.00% (0/112)       
        MPPrismDefaultThemeName                                                                                                        0.00% (0/2)         
        -[MPHtmlPreferencesViewController viewIdentifier]                                                                              0.00% (0/3)         
        -[MPHtmlPreferencesViewController toolbarItemImage]                                                                            0.00% (0/3)         
        -[MPHtmlPreferencesViewController toolbarItemLabel]                                                                            0.00% (0/2)         
        -[MPHtmlPreferencesViewController viewWillAppear]                                                                              0.00% (0/4)         
        -[MPHtmlPreferencesViewController changeStylesheet:]                                                                           0.00% (0/7)         
        -[MPHtmlPreferencesViewController changeHighlightingTheme:]                                                                    0.00% (0/7)         
        -[MPHtmlPreferencesViewController invokeStylesheetFunction:]                                                                   0.00% (0/23)        
        -[MPHtmlPreferencesViewController invokeHighlightingThemeFunction:]                                                            0.00% (0/33)        
        -[MPHtmlPreferencesViewController loadStylesheets]                                                                             0.00% (0/13)        
        -[MPHtmlPreferencesViewController loadHighlightingThemes]                                                                      0.00% (0/15)        
    /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/FileURLInlining.m                                                  26.60% (25/94)      
        +[FileURLInlining inlineFromIterable:]                                                                                         0.00% (0/11)        
        -[FileURLInlining initWithURL:]                                                                                                0.00% (0/6)         
        -[FileURLInlining init]                                                                                                        100.00% (3/3)       
        -[FileURLInlining inlineContent]                                                                                               0.00% (0/9)         
        -[FileURLInlining imageContent]                                                                                                0.00% (0/12)        
        +[FileURLInlining mimeTypeForFilePath:]                                                                                        100.00% (22/22)     
        -[FileURLInlining clippingContent]                                                                                             0.00% (0/4)         
        +[FileURLInlining isTextClippingAtPath:]                                                                                       0.00% (0/12)        
        +[FileURLInlining textContentFromClipping:]                                                                                    0.00% (0/15)        
    /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/Utility/MPResourceWatcherSet.m                                             87.10% (54/62)      
        -[MPResourceWatcherSet init]                                                                                                   100.00% (6/6)       
        -[MPResourceWatcherSet dealloc]                                                                                                0.00% (0/3)         
        -[MPResourceWatcherSet watchedPaths]                                                                                           100.00% (3/3)       
        -[MPResourceWatcherSet updateWatchedPaths:]                                                                                    100.00% (16/16)     
        -[MPResourceWatcherSet addWatcherForPath:]                                                                                     100.00% (18/18)     
        __42-[MPResourceWatcherSet addWatcherForPath:]_block_invoke                                                                    100.00% (6/6)       
        __42-[MPResourceWatcherSet addWatcherForPath:]_block_invoke.5                                                                  0.00% (0/5)         
        -[MPResourceWatcherSet stopAll]                                                                                                100.00% (5/5)       
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Extension/hoedown_html_patch.c                                             86.47% (115/133)    

... (2836 more lines truncated)

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

@schuyler schuyler merged commit be69552 into main Feb 26, 2026
9 of 10 checks passed
@schuyler schuyler deleted the claude/issue-325-ZxTvL branch February 26, 2026 22:34
@schuyler schuyler mentioned this pull request Feb 28, 2026
4 tasks
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