You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This adds a General preference to always start documents in preview-only mode and applies it during document startup after the split view restores its autosaved layout.
Why
MacDown already lets users hide the editor pane for a preview-only view, but that state does not survive app restarts. The root cause is that startup restores the split view's autosaved geometry and never reapplies a durable user preference for preview-only startup.
User impact
Users who prefer MacDown as a Markdown viewer can enable Start in preview mode in General settings and consistently reopen documents with the editor pane hidden.
Implementation notes
added a persisted editorStartInPreviewMode preference using the existing editor* naming convention
exposed the setting in the General preferences pane
applied the preference after initial split-view autosave restoration and window layout so it reliably overrides stale editor-visible startup geometry
preserved a sane restore ratio when startup begins from an editor-only autosaved layout
added preference and pane-toggle tests for the new behavior
xcodebuild is currently blocked in this checkout because Pods/Target Support Files/...xcconfig files are missing and local Bundler/CocoaPods are not usable
Thank you so much for this PR! Here is some targeted feedback from Claude Code. I'd be delighted to merge if we can address these points.
Targeted feedback:
applyEditorStartInPreviewModePreference — unreachable-looking branch. Because of the !self.editorVisible early return, dividerLocation will only land on exactly 0.0/1.0 in the editor-only autosave case, so the else if (self.previousSplitRatio < 0.0) branch reads as defensive-but-unreachable. Please either add a one-line comment explaining that this fallback is specifically for the editor-only autosaved layout, or restructure so the intent is explicit.
Test fragility in testStartInPreviewModeRestoresPreviewFromEditorOnlyLayout. The assertion previousSplitRatio == 0.5 relies on MPDocumentSplitView.dividerLocation returning exactly 1.0 for a 399/0 split in a 400-px view. That's an implementation detail of how ratio is computed relative to divider thickness; a small tweak to the split view could flip this test to the "save current ratio" branch silently (setting previousSplitRatio ≈ 0.9975) and still pass nothing. Prefer asserting observable outcomes — editorVisible == NO, previewVisible == YES, and the resulting splitView.dividerLocation — rather than pinning the 0.5 fallback constant.
XIB default state. The new checkbox has state="on" in MPGeneralPreferencesViewController.xib (aYQ-0c-EOQ). The preference should be opt-in per the PR description, and for a first-run user (no default written yet) this risks a brief visual mismatch before bindings resolve. Please set state="off" in the xib.
Trailing newline at EOF of MPDocument.m was removed. Probably unintentional — please restore it.
Optional: drop the forced layoutSubtreeIfNeeded. If MPDocumentSplitView.dividerLocation already derives from subview frames that AppKit has set by the time windowControllerDidLoadNib: runs, the forced layout pass is unnecessary startup work. If it's required for correctness, a comment saying why would help.
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
rc-pendingIncluded in a release candidate awaiting validation
2 participants
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.
Summary
This adds a General preference to always start documents in preview-only mode and applies it during document startup after the split view restores its autosaved layout.
Why
MacDown already lets users hide the editor pane for a preview-only view, but that state does not survive app restarts. The root cause is that startup restores the split view's autosaved geometry and never reapplies a durable user preference for preview-only startup.
User impact
Users who prefer MacDown as a Markdown viewer can enable
Start in preview modein General settings and consistently reopen documents with the editor pane hidden.Implementation notes
editorStartInPreviewModepreference using the existingeditor*naming conventionValidation
ibtool --errors --warnings --notices --compile /tmp/MPGeneralPreferencesViewController.nib MacDown/Localization/Base.lproj/MPGeneralPreferencesViewController.xibxcodebuild test -workspace 'MacDown 3000.xcworkspace' -scheme 'MacDown' -configuration Debug -destination 'platform=macOS' -only-testing:MacDownTests/MPPreferencesTests/testStartInPreviewModeToggle -only-testing:MacDownTests/MPPaneToggleTests/testStartInPreviewModeRestoresPreviewFromEditorOnlyLayoutxcodebuildis currently blocked in this checkout becausePods/Target Support Files/...xcconfigfiles are missing and local Bundler/CocoaPods are not usable