Skip to content

Report better version in About MacVim, and store last used version #1357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/MacVim/MMAppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ + (void)initialize
[NSNumber numberWithBool:NO], MMRendererClipToRowKey,
[NSNumber numberWithBool:YES], MMAllowForceClickLookUpKey,
[NSNumber numberWithBool:NO], MMUpdaterPrereleaseChannelKey,
@"", MMLastUsedBundleVersionKey,
nil];

[[NSUserDefaults standardUserDefaults] registerDefaults:dict];
Expand Down Expand Up @@ -459,6 +460,51 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification

[self addInputSourceChangedObserver];

NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];

NSString *lastUsedVersion = [ud stringForKey:MMLastUsedBundleVersionKey];
NSString *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:
@"CFBundleVersion"];
// This will be used for showing a "What's New" dialog box in the future. For
// now, just update the stored version for future use so later versions will
// be able to tell whether to show this dialog box or not.
if (currentVersion && currentVersion.length != 0) {
if (!lastUsedVersion || [lastUsedVersion length] == 0) {
[ud setValue:currentVersion forKey:MMLastUsedBundleVersionKey];
} else {
// If the current version is larger, set that to be stored. Don't
// want to do it otherwise to prevent testing older versions flipping
// the stored version back to an old one.
NSArray<NSString*> *lastUsedVersionItems = [lastUsedVersion componentsSeparatedByString:@"."];
NSArray<NSString*> *currentVersionItems = [currentVersion componentsSeparatedByString:@"."];
// Compare two arrays lexographically. We just assume that version
// numbers are also X.Y.Z… with no "beta" etc texts.
bool currentVersionLarger = NO;
for (int i = 0; i < currentVersionItems.count && i < lastUsedVersionItems.count; i++) {
if (i >= currentVersionItems.count) {
currentVersionLarger = NO;
break;
}
if (i >= lastUsedVersionItems.count) {
currentVersionLarger = YES;
break;
}
if (currentVersionItems[i].integerValue > lastUsedVersionItems[i].integerValue) {
currentVersionLarger = YES;
break;
}
else if (currentVersionItems[i].integerValue < lastUsedVersionItems[i].integerValue) {
currentVersionLarger = NO;
break;
}
}

if (currentVersionLarger) {
[ud setValue:currentVersion forKey:MMLastUsedBundleVersionKey];
}
}
}

ASLogInfo(@"MacVim finished launching");
}

Expand Down
2 changes: 1 addition & 1 deletion src/MacVim/MMApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ - (void)orderFrontStandardAboutPanel:(id)sender
NSString *marketingVersion = [[NSBundle mainBundle]
objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
NSString *title = [NSString stringWithFormat:
@"Custom Version %@ (%@)", marketingVersion, version];
@"Vim %@ (MacVim r%@)", marketingVersion, version];

[self orderFrontStandardAboutPanelWithOptions:
[NSDictionary dictionaryWithObjectsAndKeys:
Expand Down
1 change: 1 addition & 0 deletions src/MacVim/Miscellaneous.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ extern NSString *MMCmdLineAlignBottomKey;
extern NSString *MMRendererClipToRowKey;
extern NSString *MMAllowForceClickLookUpKey;
extern NSString *MMUpdaterPrereleaseChannelKey;
extern NSString *MMLastUsedBundleVersionKey; // The last used version of MacVim before this launch


// Enum for MMUntitledWindowKey
Expand Down
1 change: 1 addition & 0 deletions src/MacVim/Miscellaneous.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
NSString *MMRendererClipToRowKey = @"MMRendererClipToRow";
NSString *MMAllowForceClickLookUpKey = @"MMAllowForceClickLookUp";
NSString *MMUpdaterPrereleaseChannelKey = @"MMUpdaterPrereleaseChannel";
NSString *MMLastUsedBundleVersionKey = @"MMLastUsedBundleVersion";


@implementation NSIndexSet (MMExtras)
Expand Down