Add folder workspaces: hideable sidebar + native tabs + macdown . - #493
Add folder workspaces: hideable sidebar + native tabs + macdown .#493fluxa wants to merge 1 commit into
Conversation
|
@fluxa pretty exciting, thank you for submitting. this is a feature that several folks have asked for. I'll have a review done and send notes back. we can try to target the 3000.0.8 release for this feature. |
|
Thanks, sounds great, ready for your notes whenever. |
Browse a folder of Markdown files in a hideable sidebar and open them as native macOS window tabs (one NSDocument per file). Reachable via a new File > Open Folder... command and a 'macdown .' CLI directory argument. - MPFileNode: filesystem-tree model (folders + Markdown files, sorted; dotfiles excluded). - MPFolderWatcher: recursive FSEvents watcher for live refresh (respects the remote-volume guard). - MPFolderSidebarViewController: NSOutlineView source list; double-click / Enter opens a file as a tab (reusing an already-open tab); Reveal in Finder / Copy Path context menu. - MPSidebarSyncCoordinator: keeps sidebar width / visibility / folder expansion in sync across a workspace's tabs so switching tabs is seamless. - MPDocument gains workspaceRootURL + sidebar install/toggle (Cmd-\) + open-as-tab; MPMainController gains Open Folder... and programmatic menu items located by selector (locale-proof); macdown-cmd routes directory arguments through shared defaults. No new dependencies. The editor/preview pipeline and existing single-file behaviour are unchanged. Covered by XCTest.
|
Heads up: I've rebased this onto the latest main (013fd16), so the earlier merge conflicts are resolved and the branch is conflict-free again. The only overlap was in project.pbxproj alongside the MPPDFAnchorInjector additions, resolved by keeping both. Full test suite passes locally (the only failures are the pre-existing HGMarkdownHighlighterTests theme checks, present on unmodified main). Happy to address review notes whenever you get a chance, in case this can still make the 3000.0.8 window. |
Summary
Adds folder workspaces to MacDown 3000: browse a folder of Markdown files in a hideable sidebar and open them as native macOS window tabs, instead of only opening individual files. Reachable from a new File → Open Folder… command and from the command line with
macdown ..This is an additive feature — the editor/preview pipeline and existing single-file behaviour are untouched, and there are no new dependencies.
What you get
NSOutlineViewsource list) showing subfolders and Markdown files (.md/.markdown), dotfiles excluded.macdown .— the CLI learns to accept a directory and opens it as a workspace (files still open as before;macdown file.mdis unchanged).How it works
MacDown is a standard
NSDocumentapp (one document per window). Rather than refactor that, this leans into native window tabbing (addTabbedWindow:): each file stays its ownMPDocument, and the OS merges their windows into one tabbed window. The sidebar is added per-window by nesting the existing editor/preview split inside an outerNSSplitView.New components (all under
MacDown/Code/Sidebar/):MPFileNode— filesystem-tree model (filtering + folders-first sort).MPFolderWatcher— recursive FSEvents watcher (respects the existing remote-volume guard).MPFolderSidebarViewController— the source list + open/activation + context menu.MPSidebarSyncCoordinator— shares sidebar state across tabs.Wiring:
MPDocumentgainsworkspaceRootURL, sidebar install/toggle, and the open-as-tab flow.MPMainControllergainsOpen Folder…and inserts its menu items by member selector (so they install in non-English locales too).macdown-cmdroutes directory arguments to a new shared-defaults key.Testing
XCTestcoverage for the model, watcher, sync coordinator, directory routing, menu installation, tab-reuse lookup, and workspace-root propagation. The full suite passes (the pre-existingHGMarkdownHighlighterTeststheme failures are unrelated to this change).macdown ., double-click-to-tab + tab reuse, ⌘\ toggle, live refresh, Reveal/Copy Path, and cross-tab sync.Notes / design decisions
Closes/relates to: (feel free to link a folder-browsing feature request if one exists)