Skip to content

Fix editor scroll jump during typing at end of long documents#343

Merged
schuyler merged 1 commit into
mainfrom
claude/create-issue-282-feedback-UMxbI
Apr 3, 2026
Merged

Fix editor scroll jump during typing at end of long documents#343
schuyler merged 1 commit into
mainfrom
claude/create-issue-282-feedback-UMxbI

Conversation

@schuyler

@schuyler schuyler commented Mar 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Guard previewBoundsDidChange: with _inEditing to break the feedback loop where DOM replacement's window.scrollTo() triggers reverse scroll sync back into the editor, causing the scroll jump reported in Editor still jumps while typing at end of long document #342
  • Guard the MathJax DOMReplacementDone completion callback's syncScrollers call with the same _inEditing check, preventing the same cascade via the async MathJax path
  • Fix secondary inconsistency where syncScrollersReverse was called outside the !_inLiveScroll guard with stale header data

Both fixes follow the established _inEditing pattern from the #282 fix in editorBoundsDidChange:.

Related to #342

Test plan

  • CI passes on all 4 macOS runners (macos-14, macos-15, macos-15-intel, macos-26)
  • New test: testPreviewBoundsDidChangeSkipsSyncWhenInEditing — verifies reverse sync is suppressed during editing
  • New test: testPreviewBoundsDidChangeSyncsWhenNotInEditing — verifies no over-suppression of legitimate preview scrolling
  • New test: testPreviewBoundsDidChangeRespectsGuardFlag — verifies early-return path
  • Manual: Open a long document, type at the end, confirm no scroll jumping
  • Manual: Scroll the preview pane manually, confirm editor follows (reverse sync still works)
  • Manual: Enable MathJax, type math at the end of a long document, confirm no jumping

Guard previewBoundsDidChange: with _inEditing to break the feedback
loop where DOM replacement's window.scrollTo() triggers reverse scroll
sync back into the editor. Also guard the MathJax completion callback's
syncScrollers call for the same reason. Both fixes mirror the existing
_inEditing pattern from the #282 fix in editorBoundsDidChange:.

Additionally fixes a secondary inconsistency where syncScrollersReverse
was called outside the !_inLiveScroll guard with stale header data.

Related to #342

https://claude.ai/code/session_01GFGosaQntktYnAJgv7fCpw
@github-actions

github-actions Bot commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Report

Current Coverage: 57.22%

Coverage Details (Summary)
Name                                                                                                                                   Coverage            
-------------------------------------------------------------------------------------------------------------------------------------- ------------------- 
MASPreferences.bundle                                                                                                                  0.00% (0/0)         
MacDown 3000.app                                                                                                                       59.89% (8218/13722) 
    /Users/runner/work/macdown3000/macdown3000/Dependency/peg-markdown-highlight/HGMarkdownHighlighter.m                               85.51% (478/559)    
        styleparsing_error_callback                                                                                                    90.00% (9/10)       
        -[HGMarkdownHighlighter init]                                                                                                  92.86% (13/14)      
        -[HGMarkdownHighlighter initWithTextView:]                                                                                     83.33% (5/6)        
        -[HGMarkdownHighlighter initWithTextView:waitInterval:]                                                                        83.33% (5/6)        
        -[HGMarkdownHighlighter initWithTextView:waitInterval:styles:]                                                                 83.33% (5/6)        
        -[HGMarkdownHighlighter parseText:]                                                                                            100.00% (9/9)       
        -[HGMarkdownHighlighter convertOffsets:text:]                                                                                  26.19% (11/42)      
        -[HGMarkdownHighlighter requestParsing]                                                                                        100.00% (15/15)     
        __39-[HGMarkdownHighlighter requestParsing]_block_invoke                                                                       100.00% (12/12)     
        __39-[HGMarkdownHighlighter requestParsing]_block_invoke.55                                                                    100.00% (3/3)       
        __39-[HGMarkdownHighlighter requestParsing]_block_invoke.67                                                                    100.00% (4/4)       
        -[HGMarkdownHighlighter getClearFontTraitMask:]                                                                                88.89% (16/18)      
        -[HGMarkdownHighlighter clearHighlightingForRange:]                                                                            100.00% (31/31)     
        __51-[HGMarkdownHighlighter clearHighlightingForRange:]_block_invoke                                                           100.00% (8/8)       
        -[HGMarkdownHighlighter readClearTextStylesFromTextView]                                                                       100.00% (17/17)     
        -[HGMarkdownHighlighter applyHighlighting:withRange:]                                                                          80.00% (60/75)      
        __53-[HGMarkdownHighlighter applyHighlighting:withRange:]_block_invoke                                                         92.31% (12/13)      
        -[HGMarkdownHighlighter applyVisibleRangeHighlighting]                                                                         100.00% (16/16)     
        -[HGMarkdownHighlighter clearHighlighting]                                                                                     100.00% (3/3)       
        -[HGMarkdownHighlighter cacheElementList:]                                                                                     100.00% (6/6)       
        -[HGMarkdownHighlighter clearElementsCache]                                                                                    100.00% (2/2)       
        -[HGMarkdownHighlighter textViewTextDidChange:]                                                                                0.00% (0/11)        
        __47-[HGMarkdownHighlighter textViewTextDidChange:]_block_invoke                                                               0.00% (0/3)         
        -[HGMarkdownHighlighter textViewDidScroll:]                                                                                    100.00% (11/11)     
        __43-[HGMarkdownHighlighter textViewDidScroll:]_block_invoke                                                                   100.00% (6/6)       
        __43-[HGMarkdownHighlighter textViewDidScroll:]_block_invoke_2                                                                 100.00% (3/3)       
        -[HGMarkdownHighlighter getDefaultStyles]                                                                                      100.00% (27/27)     
        -[HGMarkdownHighlighter applyStyleDependenciesToTargetTextView]                                                                92.86% (13/14)      
        -[HGMarkdownHighlighter setStyles:]                                                                                            100.00% (8/8)       
        -[HGMarkdownHighlighter getDefaultSelectedTextAttributes]                                                                      100.00% (7/7)       
        -[HGMarkdownHighlighter handleStyleParsingError:]                                                                              100.00% (12/12)     
        -[HGMarkdownHighlighter applyStylesFromStylesheet:withErrorHandler:]                                                           86.05% (74/86)      
        -[HGMarkdownHighlighter setTargetTextView:]                                                                                    100.00% (7/7)       
        -[HGMarkdownHighlighter parseAndHighlightNow]                                                                                  100.00% (3/3)       
        -[HGMarkdownHighlighter highlightNow]                                                                                          100.00% (3/3)       
        -[HGMarkdownHighlighter activate]                                                                                              100.00% (24/24)     
        -[HGMarkdownHighlighter deactivate]                                                                                            100.00% (18/18)     
    /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)         

... (2859 more lines truncated)

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

@schuyler schuyler merged commit 000e4e4 into main Apr 3, 2026
9 checks passed
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