@@ -174,7 +174,7 @@ - (id)initWithVimController:(MMVimController *)controller
174174
175175 [win setDelegate: self ];
176176 [win setInitialFirstResponder: [vimView textView ]];
177-
177+
178178 if ([win styleMask ] & NSWindowStyleMaskTexturedBackground ) {
179179 // On Leopard, we want to have a textured window to have nice
180180 // looking tabs. But the textured window look implies rounded
@@ -381,6 +381,7 @@ - (void)selectTabWithIndex:(int)idx
381381}
382382
383383- (void )setTextDimensionsWithRows : (int )rows columns : (int )cols isLive : (BOOL )live
384+ keepGUISize : (BOOL )keepGUISize
384385 keepOnScreen : (BOOL )onScreen
385386{
386387 ASLogDebug (@" setTextDimensionsWithRows:%d columns:%d isLive:%d "
@@ -399,7 +400,7 @@ - (void)setTextDimensionsWithRows:(int)rows columns:(int)cols isLive:(BOOL)live
399400
400401 [vimView setDesiredRows: rows columns: cols];
401402
402- if (setupDone && !live) {
403+ if (setupDone && !live && !keepGUISize ) {
403404 shouldResizeVimView = YES ;
404405 keepOnScreen = onScreen;
405406 }
@@ -428,6 +429,15 @@ - (void)setTextDimensionsWithRows:(int)rows columns:(int)cols isLive:(BOOL)live
428429 }
429430}
430431
432+ - (void )resizeView
433+ {
434+ if (setupDone)
435+ {
436+ shouldResizeVimView = YES ;
437+ shouldKeepGUISize = YES ;
438+ }
439+ }
440+
431441- (void )zoomWithRows : (int )rows columns : (int )cols state : (int )state
432442{
433443 [self setTextDimensionsWithRows: rows
@@ -503,19 +513,13 @@ - (void)createScrollbarWithIdentifier:(int32_t)ident type:(int)type
503513- (BOOL )destroyScrollbarWithIdentifier : (int32_t )ident
504514{
505515 BOOL scrollbarHidden = [vimView destroyScrollbarWithIdentifier: ident];
506- shouldResizeVimView = shouldResizeVimView || scrollbarHidden;
507- shouldMaximizeWindow = shouldMaximizeWindow || scrollbarHidden;
508-
509516 return scrollbarHidden;
510517}
511518
512519- (BOOL )showScrollbarWithIdentifier : (int32_t )ident state : (BOOL )visible
513520{
514521 BOOL scrollbarToggled = [vimView showScrollbarWithIdentifier: ident
515522 state: visible];
516- shouldResizeVimView = shouldResizeVimView || scrollbarToggled;
517- shouldMaximizeWindow = shouldMaximizeWindow || scrollbarToggled;
518-
519523 return scrollbarToggled;
520524}
521525
@@ -600,7 +604,18 @@ - (void)processInputQueueDidFinish
600604 fullScreenWindow ? [fullScreenWindow frame ].size :
601605 fullScreenEnabled ? desiredWindowSize :
602606 [self constrainContentSizeToScreenSize: [vimView desiredSize ]]];
603- [vimView setFrameSize: contentSize];
607+
608+ // Setting 'guioptions+=k' will make shouldKeepGUISize true, which
609+ // means avoid resizing the window. Instead, resize the view instead
610+ // to keep the GUI window's size consistent.
611+ bool avoidWindowResize = shouldKeepGUISize && !fullScreenEnabled;
612+
613+ if (!avoidWindowResize) {
614+ [vimView setFrameSize: contentSize];
615+ }
616+ else {
617+ [vimView setFrameSizeKeepGUISize: originalSize];
618+ }
604619
605620 if (fullScreenWindow) {
606621 // NOTE! Don't mark the full-screen content view as needing an
@@ -613,12 +628,15 @@ - (void)processInputQueueDidFinish
613628 [fullScreenWindow centerView ];
614629 }
615630 } else {
616- [self resizeWindowToFitContentSize: contentSize
617- keepOnScreen: keepOnScreen];
631+ if (!avoidWindowResize) {
632+ [self resizeWindowToFitContentSize: contentSize
633+ keepOnScreen: keepOnScreen];
634+ }
618635 }
619636 }
620637
621638 keepOnScreen = NO ;
639+ shouldKeepGUISize = NO ;
622640 }
623641}
624642
@@ -657,15 +675,13 @@ - (void)adjustLinespace:(int)linespace
657675{
658676 if (vimView && [vimView textView ]) {
659677 [[vimView textView ] setLinespace: (float )linespace];
660- shouldMaximizeWindow = shouldResizeVimView = YES ;
661678 }
662679}
663680
664681- (void )adjustColumnspace : (int )columnspace
665682{
666683 if (vimView && [vimView textView ]) {
667684 [[vimView textView ] setColumnspace: (float )columnspace];
668- shouldMaximizeWindow = shouldResizeVimView = YES ;
669685 }
670686}
671687
@@ -1177,7 +1193,7 @@ - (void)window:(NSWindow *)window
11771193 [[window animator ] setAlphaValue: 0 ];
11781194 } completionHandler: ^{
11791195 [self maximizeWindow: fullScreenOptions];
1180-
1196+
11811197 // Fade in
11821198 [NSAnimationContext runAnimationGroup: ^(NSAnimationContext *context) {
11831199 [context setDuration: 0.5 *duration];
@@ -1196,7 +1212,7 @@ - (void)windowWillEnterFullScreen:(NSNotification *)notification
11961212
11971213 // The separator should never be visible in fullscreen or split-screen.
11981214 [decoratedWindow hideTablineSeparator: YES ];
1199-
1215+
12001216 // ASSUMPTION: fullScreenEnabled always reflects the state of Vim's 'fu'.
12011217 if (!fullScreenEnabled) {
12021218 ASLogDebug (@" Full-screen out of sync, tell Vim to set 'fu'" );
@@ -1298,7 +1314,7 @@ - (void)windowDidExitFullScreen:(NSNotification *)notification
12981314 // full-screen by moving the window out from Split View.
12991315 [vimController sendMessage: BackingPropertiesChangedMsgID data: nil ];
13001316 }
1301-
1317+
13021318 [self updateTablineSeparator ];
13031319}
13041320
@@ -1519,7 +1535,6 @@ - (void)hideTablineSeparator:(BOOL)hide
15191535 // The tabline separator was toggled so the content view must change
15201536 // size.
15211537 [self updateResizeConstraints ];
1522- shouldResizeVimView = YES ;
15231538 }
15241539}
15251540
0 commit comments