Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Constrain window before autosaving dimensions

This fixes a bug where the view would not be maximized vertically when
entering full screen on startup.  (Debugging assist by David Whetstone.)
  • Loading branch information...
commit 8b4669ff38db551849224db1f9c77cdd014d504e 1 parent 4ea64bd
Björn Winckler authored February 22, 2011

Showing 1 changed file with 14 additions and 13 deletions. Show diff stats Hide diff stats

  1. 27  src/MacVim/MMWindowController.m
27  src/MacVim/MMWindowController.m
@@ -326,18 +326,6 @@ - (void)setTextDimensionsWithRows:(int)rows columns:(int)cols isLive:(BOOL)live
326 326
         shouldResizeVimView = YES;
327 327
         keepOnScreen = onScreen;
328 328
     }
329  
-
330  
-    if (windowAutosaveKey) {
331  
-        // Autosave rows and columns (only done for window which also autosaves
332  
-        // window position).
333  
-        id tv = [vimView textView];
334  
-        int rows = [tv maxRows];
335  
-        int cols = [tv maxColumns];
336  
-        NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
337  
-        [ud setInteger:rows forKey:MMAutosaveRowsKey];
338  
-        [ud setInteger:cols forKey:MMAutosaveColumnsKey];
339  
-        [ud synchronize];
340  
-    }
341 329
 }
342 330
 
343 331
 - (void)zoomWithRows:(int)rows columns:(int)cols state:(int)state
@@ -484,7 +472,8 @@ - (void)processInputQueueDidFinish
484 472
         NSSize originalSize = [vimView frame].size;
485 473
         NSSize contentSize = [vimView desiredSize];
486 474
         contentSize = [self constrainContentSizeToScreenSize:contentSize];
487  
-        contentSize = [vimView constrainRows:NULL columns:NULL
  475
+        int rows = 0, cols = 0;
  476
+        contentSize = [vimView constrainRows:&rows columns:&cols
488 477
                                       toSize:contentSize];
489 478
         [vimView setFrameSize:contentSize];
490 479
 
@@ -501,6 +490,18 @@ - (void)processInputQueueDidFinish
501 490
         } else {
502 491
             [self resizeWindowToFitContentSize:contentSize
503 492
                                   keepOnScreen:keepOnScreen];
  493
+
  494
+            if (windowAutosaveKey && rows > 0 && cols > 0) {
  495
+                // Autosave rows and columns now that they should have been
  496
+                // constrained to fit on screen.  We only do this for the
  497
+                // window which also autosaves window position and we avoid
  498
+                // autosaving when in fullscreen since the rows usually won't
  499
+                // fit when in windowed mode.
  500
+                NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
  501
+                [ud setInteger:rows forKey:MMAutosaveRowsKey];
  502
+                [ud setInteger:cols forKey:MMAutosaveColumnsKey];
  503
+                [ud synchronize];
  504
+            }
504 505
         }
505 506
 
506 507
         keepOnScreen = NO;

0 notes on commit 8b4669f

Please sign in to comment.
Something went wrong with that request. Please try again.