Skip to content

Commit

Permalink
Refactor MacVim tests and add startup delayed full screen tests
Browse files Browse the repository at this point in the history
Add test suite utility functions to set/restore defaults, adding/tearing
down a new Vim window, making temp files, wait for full screen
transition. This helps simplify per-test code and prevent mistakes.

Add new tests for delayed full screen on startup. This happens when a
vimrc/gvimrc sets 'fullscreen' on startup and MacVim has to delay
entering full screen until the window has been presented. This
incidentally regression tests a bug (fixed in macvim-dev#1521) where simply having
'set fuopt= fullscreen' in a gvimrc would cause MacVim to crash on
startup due to bad interaction with window resize messages.
  • Loading branch information
ychin committed Jan 8, 2025
1 parent c93f9c0 commit 791b291
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 150 deletions.
1 change: 1 addition & 0 deletions src/MacVim/MMAppController.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
- (void)refreshAllResizeConstraints;
- (void)refreshAllTextViews;

- (void)openNewWindow:(enum NewWindowMode)mode activate:(BOOL)activate extraArgs:(NSArray *)args;
- (void)openNewWindow:(enum NewWindowMode)mode activate:(BOOL)activate;

//
Expand Down
24 changes: 16 additions & 8 deletions src/MacVim/MMAppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1298,31 +1298,39 @@ - (BOOL)validateMenuItem:(NSMenuItem *)item
return YES;
}

/// Open a new Vim window, potentially taking from cached (if preload is used).
///
/// @param mode Determine whether to use clean mode or not. Preload will only
/// be used if using normal mode.
///
/// @param activate Activate the window after it's opened.
- (void)openNewWindow:(enum NewWindowMode)mode activate:(BOOL)activate
- (void)openNewWindow:(enum NewWindowMode)mode activate:(BOOL)activate extraArgs:(NSArray *)extraArgs
{
if (activate)
[self activateWhenNextWindowOpens];

// A cached controller requires no loading times and results in the new
// window popping up instantaneously. If the cache is empty it may take
// 1-2 seconds to start a new Vim process.
MMVimController *vc = (mode == NewWindowNormal) ? [self takeVimControllerFromCache] : nil;
MMVimController *vc = (mode == NewWindowNormal && extraArgs == nil) ? [self takeVimControllerFromCache] : nil;
if (vc) {
[[vc backendProxy] acknowledgeConnection];
} else {
NSArray *args = (mode == NewWindowNormal) ? nil
: (mode == NewWindowClean ? @[@"--clean"]
: @[@"--clean", @"-u", @"NONE"]);
if (extraArgs != nil) {
args = [args arrayByAddingObjectsFromArray:extraArgs];
}
[self launchVimProcessWithArguments:args workingDirectory:nil];
}
}

/// Open a new Vim window, potentially taking from cached (if preload is used).
///
/// @param mode Determine whether to use clean mode or not. Preload will only
/// be used if using normal mode.
///
/// @param activate Activate the window after it's opened.
- (void)openNewWindow:(enum NewWindowMode)mode activate:(BOOL)activate
{
return [self openNewWindow:mode activate:activate extraArgs:nil];
}

- (IBAction)newWindow:(id)sender
{
ASLogDebug(@"Open new window");
Expand Down
Loading

0 comments on commit 791b291

Please sign in to comment.