Skip to content

Fix new document windows opening at bottom-left#286

Merged
schuyler merged 1 commit intoschuyler:mainfrom
mbinkhorst:claude/fix-new-document-window-position-1769076277
Jan 22, 2026
Merged

Fix new document windows opening at bottom-left#286
schuyler merged 1 commit intoschuyler:mainfrom
mbinkhorst:claude/fix-new-document-window-position-1769076277

Conversation

@mbinkhorst
Copy link
Copy Markdown
Contributor

@mbinkhorst mbinkhorst commented Jan 22, 2026

Summary

  • Fix new document windows opening at bottom-left screen position when no saved window position exists
  • Center the window as a fallback only when frame restoration fails, preserving saved positions for all other cases

Solution

Added a fallback in windowControllerDidLoadNib: to center the window when no saved frame position is found. This preserves the existing behavior for:

  • Saved documents (restore position from file URL autosave)
  • New documents with a saved default (restore from "Untitled" autosave)

Only windows with no saved position at all get centered.

Test plan

  • Open an existing document → restores to last saved position
  • Create new document, move window, close, create another → restores default position
  • Clear saved default with defaults delete app.macdown.macdown3000 "NSWindow Frame Untitled", create new document → centers on screen
  • Test on multiple monitors

Copy link
Copy Markdown
Owner

@schuyler schuyler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this issue!

I noticed a potential problem with the execution order. When [super makeWindowControllers] runs, it loads the nib and triggers windowControllerDidLoadNib:, which restores the saved window frame. The center call then runs after that, which means it will override the restored position for all documents, not just new ones.

A couple of options to fix this:

  1. Only call center when self.fileURL is nil (i.e., for new unsaved documents)
  2. Move the centering logic into windowControllerDidLoadNib: before the autosave restoration, so saved positions take precedence

Either approach should preserve the restored positions for previously saved documents while still fixing the (0,0) issue for new ones.

@mbinkhorst mbinkhorst force-pushed the claude/fix-new-document-window-position-1769076277 branch from a8060ea to 4d9fc8a Compare January 22, 2026 19:40
@mbinkhorst
Copy link
Copy Markdown
Contributor Author

Totally forgot about that order. I will try to fix this.

Center the window as a fallback in windowControllerDidLoadNib: only when
no saved frame position exists. This preserves saved positions for
existing documents and the default position for new documents.
@mbinkhorst mbinkhorst force-pushed the claude/fix-new-document-window-position-1769076277 branch from 4d9fc8a to 8de31a3 Compare January 22, 2026 20:05
@mbinkhorst mbinkhorst changed the title Fix new document windows opening at (0,0) Fix new document windows opening at bottom-left Jan 22, 2026
@schuyler schuyler merged commit 83fa76b into schuyler:main Jan 22, 2026
5 checks passed
@schuyler
Copy link
Copy Markdown
Owner

schuyler commented Jan 22, 2026

@mbinkhorst Thanks for the patch!

@mbinkhorst
Copy link
Copy Markdown
Contributor Author

Thank you!

schuyler pushed a commit that referenced this pull request Jan 24, 2026
Comprehensive testing plan covering all changes since v3000.0.3:
- Smart quote substitution fix (#289)
- Editor jumping when typing at end of long documents (#288)
- New document window positioning (#286)
- Graphviz/Mermaid button positioning in Compilation Settings (#280)
- Adjacent shortcut-style links rendering (#275)

Includes regression testing checklist for core functionality.
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