Skip to content

Address issue #23: Hiding both editor and preview panes bug#207

Merged
schuyler merged 1 commit intomainfrom
issue-23-hide-panes-bug
Dec 7, 2025
Merged

Address issue #23: Hiding both editor and preview panes bug#207
schuyler merged 1 commit intomainfrom
issue-23-hide-panes-bug

Conversation

@schuyler
Copy link
Copy Markdown
Owner

@schuyler schuyler commented Dec 7, 2025

Summary

  • Prevent hiding both editor and preview panes simultaneously
  • Menu items are now disabled when hiding would leave no visible panes
  • Toggle actions are no-ops when hiding would leave no visible panes
  • Added comprehensive unit tests for pane toggle behavior

Related Issue

Closes #23

Changes

MPDocument.m

  • Modified validateUserInterfaceItem: to return NO (disable menu item) when hiding a pane would leave no visible panes
  • Added guard in toggleSplitterCollapsingEditorPane: to early-return when hiding would leave no visible panes

MPPaneToggleTests.m (new file)

  • IBAction safety tests
  • Menu validation tests
  • Constraint enforcement tests
  • Restore operations tests

Manual Testing Plan

  1. Menu validation: With only one pane visible, verify the "Hide" menu item for that pane is grayed out
  2. Keyboard shortcuts: Verify shortcuts do nothing when hiding would leave no visible panes
  3. Restore operations: Verify restoring hidden panes always works
  4. Rapid toggles: Verify no crashes during rapid toggle sequences

Add validation to ensure at least one pane remains visible at all times:

1. Modified validateUserInterfaceItem: to return NO (disable menu item)
   when hiding the last visible pane
2. Added guard in toggleSplitterCollapsingEditorPane: to early-return
   when hiding would leave no visible panes

This prevents the bug where hiding both panes leaves the user unable to
restore normal split view without menu intervention.

Added comprehensive tests in MPPaneToggleTests.m covering:
- Menu validation for both hide and restore operations
- Toggle action no-op behavior when hiding last pane
- Edge cases and headless CI compatibility

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

github-actions bot commented Dec 7, 2025

Code Coverage Report

Current Coverage: 38.07%

Coverage Details (Summary)
Name                                                                                                                                   Coverage            
-------------------------------------------------------------------------------------------------------------------------------------- ------------------- 
MASPreferences.bundle                                                                                                                  0.00% (0/0)         
MacDown 3000.app                                                                                                                       44.89% (5572/12412) 
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Document/MPDocument.m                                                      43.77% (660/1508)   
        MPEditorPreferenceKeyWithValueKey                                                                                              85.71% (6/7)        
        MPEditorKeysToObserve                                                                                                          100.00% (14/14)     
        __MPEditorKeysToObserve_block_invoke                                                                                           100.00% (9/9)       
        MPEditorPreferencesToObserve                                                                                                   100.00% (13/13)     
        __MPEditorPreferencesToObserve_block_invoke                                                                                    100.00% (8/8)       
        MPRectStringForAutosaveName                                                                                                    100.00% (6/6)       
        MPGetWebViewBackgroundColor                                                                                                    0.00% (0/9)         
        -[NSURL(Convert) absoluteBaseURLString]                                                                                        0.00% (0/6)         
        -[WebView(Shortcut) enclosingScrollView]                                                                                       100.00% (3/3)       
        -[MPPreferences(Hoedown) extensionFlags]                                                                                       71.43% (20/28)      
        -[MPPreferences(Hoedown) rendererFlags]                                                                                        66.67% (8/12)       
        MPGetPreviewLoadingCompletionHandler                                                                                           100.00% (25/25)     
        __MPGetPreviewLoadingCompletionHandler_block_invoke                                                                            0.00% (0/22)        
        -[MPDocument preferences]                                                                                                      100.00% (3/3)       
        -[MPDocument markdown]                                                                                                         100.00% (3/3)       
        -[MPDocument setMarkdown:]                                                                                                     100.00% (3/3)       
        -[MPDocument html]                                                                                                             0.00% (0/3)         
        -[MPDocument toolbarVisible]                                                                                                   0.00% (0/3)         
        -[MPDocument previewVisible]                                                                                                   100.00% (3/3)       
        -[MPDocument editorVisible]                                                                                                    100.00% (3/3)       
        -[MPDocument needsHtml]                                                                                                        0.00% (0/5)         
        -[MPDocument setTotalWords:]                                                                                                   0.00% (0/7)         
        -[MPDocument setTotalCharacters:]                                                                                              0.00% (0/7)         
        -[MPDocument setTotalCharactersNoSpaces:]                                                                                      0.00% (0/8)         
        -[MPDocument setAutosaveName:]                                                                                                 100.00% (4/4)       
        -[MPDocument init]                                                                                                             88.89% (8/9)        
        -[MPDocument windowNibName]                                                                                                    100.00% (3/3)       
        -[MPDocument windowControllerDidLoadNib:]                                                                                      100.00% (85/85)     
        __41-[MPDocument windowControllerDidLoadNib:]_block_invoke                                                                     100.00% (4/4)       
        -[MPDocument reloadFromLoadedString]                                                                                           100.00% (8/8)       
        -[MPDocument close]                                                                                                            0.00% (0/20)        
        +[MPDocument autosavesInPlace]                                                                                                 100.00% (2/2)       
        +[MPDocument writableTypes]                                                                                                    100.00% (3/3)       
        -[MPDocument isDocumentEdited]                                                                                                 100.00% (5/5)       
        -[MPDocument writeToURL:ofType:error:]                                                                                         0.00% (0/15)        
        -[MPDocument dataOfType:error:]                                                                                                0.00% (0/3)         
        -[MPDocument readFromData:ofType:error:]                                                                                       100.00% (8/8)       
        -[MPDocument prepareSavePanel:]                                                                                                76.92% (30/39)      
        __31-[MPDocument prepareSavePanel:]_block_invoke                                                                               100.00% (12/12)     
        -[MPDocument printInfo]                                                                                                        0.00% (0/12)        
        -[MPDocument printOperationWithSettings:error:]                                                                                0.00% (0/7)         
        -[MPDocument printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo:]                                  0.00% (0/17)        
        -[MPDocument validateUserInterfaceItem:]                                                                                       0.00% (0/41)        
        -[MPDocument splitViewDidResizeSubviews:]                                                                                      100.00% (4/4)       
        -[MPDocument textView:doCommandBySelector:]                                                                                    0.00% (0/13)        

... (2111 more lines truncated)

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

@schuyler schuyler merged commit 0a0ec71 into main Dec 7, 2025
4 checks passed
@schuyler schuyler deleted the issue-23-hide-panes-bug branch December 7, 2025 01:43
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.

Hiding both editor and preview panes bug

1 participant