@@ -263,6 +263,7 @@ + (void)initialize
263263 [NSNumber numberWithBool: NO ], MMRendererClipToRowKey,
264264 [NSNumber numberWithBool: YES ], MMAllowForceClickLookUpKey,
265265 [NSNumber numberWithBool: NO ], MMUpdaterPrereleaseChannelKey,
266+ @" " , MMLastUsedBundleVersionKey,
266267 nil ];
267268
268269 [[NSUserDefaults standardUserDefaults ] registerDefaults: dict];
@@ -459,6 +460,51 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification
459460
460461 [self addInputSourceChangedObserver ];
461462
463+ NSUserDefaults *ud = [NSUserDefaults standardUserDefaults ];
464+
465+ NSString *lastUsedVersion = [ud stringForKey: MMLastUsedBundleVersionKey];
466+ NSString *currentVersion = [[NSBundle mainBundle ] objectForInfoDictionaryKey:
467+ @" CFBundleVersion" ];
468+ // This will be used for showing a "What's New" dialog box in the future. For
469+ // now, just update the stored version for future use so later versions will
470+ // be able to tell whether to show this dialog box or not.
471+ if (currentVersion && currentVersion.length != 0 ) {
472+ if (!lastUsedVersion || [lastUsedVersion length ] == 0 ) {
473+ [ud setValue: currentVersion forKey: MMLastUsedBundleVersionKey];
474+ } else {
475+ // If the current version is larger, set that to be stored. Don't
476+ // want to do it otherwise to prevent testing older versions flipping
477+ // the stored version back to an old one.
478+ NSArray <NSString *> *lastUsedVersionItems = [lastUsedVersion componentsSeparatedByString: @" ." ];
479+ NSArray <NSString *> *currentVersionItems = [currentVersion componentsSeparatedByString: @" ." ];
480+ // Compare two arrays lexographically. We just assume that version
481+ // numbers are also X.Y.Z… with no "beta" etc texts.
482+ bool currentVersionLarger = NO ;
483+ for (int i = 0 ; i < currentVersionItems.count && i < lastUsedVersionItems.count ; i++) {
484+ if (i >= currentVersionItems.count ) {
485+ currentVersionLarger = NO ;
486+ break ;
487+ }
488+ if (i >= lastUsedVersionItems.count ) {
489+ currentVersionLarger = YES ;
490+ break ;
491+ }
492+ if (currentVersionItems[i].integerValue > lastUsedVersionItems[i].integerValue ) {
493+ currentVersionLarger = YES ;
494+ break ;
495+ }
496+ else if (currentVersionItems[i].integerValue < lastUsedVersionItems[i].integerValue ) {
497+ currentVersionLarger = NO ;
498+ break ;
499+ }
500+ }
501+
502+ if (currentVersionLarger) {
503+ [ud setValue: currentVersion forKey: MMLastUsedBundleVersionKey];
504+ }
505+ }
506+ }
507+
462508 ASLogInfo (@" MacVim finished launching" );
463509}
464510
0 commit comments