Skip to content

MacVim fails to initialize properly if the last saved window position is outside of current screen #66

Closed
@yacoob

Description

@yacoob

I've had Macvim failed to create its first window a couple of times with:

2015-08-21 12:16:53.910 MacVim[23324:151631] Error (1000) creating CGSWindow on line 281
2015-08-21 12:16:53.912 MacVim[23324:151631] (
        0   CoreFoundation                      0x00007fff937d103c __exceptionPreprocess + 172
        1   libobjc.A.dylib                     0x00007fff90cbc76e objc_exception_throw + 43
        2   CoreFoundation                      0x00007fff937d0eed +[NSException raise:format:] + 205
        3   AppKit                              0x00007fff98e86cc2 _NSCreateWindowWithOpaqueShape2 + 1417
        4   AppKit                              0x00007fff98e84f48 -[NSWindow _commonAwake] + 1877
        5   AppKit                              0x00007fff98f0fa19 -[NSWindow _makeKeyRegardlessOfVisibility] + 85
        6   AppKit                              0x00007fff98f0f98e -[NSWindow makeKeyAndOrderFront:] + 27
        7   MacVim                              0x000000010823481d -[MMWindowController presentWindow:] + 147
        8   Foundation                          0x00007fff9673b4eb __NSFireDelayedPerform + 364
        9   CoreFoundation                      0x00007fff937242e4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
        10  CoreFoundation                      0x00007fff93723f73 __CFRunLoopDoTimer + 1059
        11  CoreFoundation                      0x00007fff9379753d __CFRunLoopDoTimers + 301
        12  CoreFoundation                      0x00007fff936df608 __CFRunLoopRun + 2024
        13  CoreFoundation                      0x00007fff936debd8 CFRunLoopRunSpecific + 296
        14  HIToolbox                           0x00007fff8fbc656f RunCurrentEventLoopInMode + 235
        15  HIToolbox                           0x00007fff8fbc62ea ReceiveNextEventCommon + 431
        16  HIToolbox                           0x00007fff8fbc612b _BlockUntilNextEventMatchingListInModeWithFilter + 71
        17  AppKit                              0x00007fff98e738ab _DPSNextEvent + 978
        18  AppKit                              0x00007fff98e72e58 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346
        19  AppKit                              0x00007fff98e68af3 -[NSApplication run] + 594
        20  AppKit                              0x00007fff98de5244 NSApplicationMain + 1832
        21  libdyld.dylib                       0x00007fff8cbbd5c9 start + 1

As a result the process keeps running, but there's no UI to interact with.

I've traced it down to MacVim trying to restore its window in a place that is outside of current screen. This happens when I work on a macbook with a large external display connected, quit MacVim, disconnect the display, then try to launch MacVim again.

$ defaults read org.vim.MacVim MMTopLeftPoint
{4, 1577}
$ osascript -e 'tell application "Finder" to get bounds of window of desktop'
0, 0, 1680, 1050

Removing the setting makes MacVim happy again and allows it to initialize properly:

$ defaults delete org.vim.MacVim MMTopLeftPoint

It'd be nice if MacVim would realise this on its own and didn't fail during window creation. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions