diff --git a/src/MacVim/MMSparkle2Delegate.h b/src/MacVim/MMSparkle2Delegate.h index bf3640903c..127d835c4d 100644 --- a/src/MacVim/MMSparkle2Delegate.h +++ b/src/MacVim/MMSparkle2Delegate.h @@ -8,14 +8,23 @@ #import "Sparkle.framework/Headers/Sparkle.h" -@interface MMSparkle2Delegate : NSObject ; +NS_ASSUME_NONNULL_BEGIN + +@interface MMSparkle2Delegate : NSObject ; // SPUUpdaterDelegate -- (nonnull NSSet *)allowedChannelsForUpdater:(nonnull SPUUpdater *)updater; +- (NSSet *)allowedChannelsForUpdater:(SPUUpdater *)updater; // SPUStandardUserDriverDelegate -// No need to implement anything for now. Default behaviors work fine. +- (_Nullable id )standardUserDriverRequestsVersionDisplayer; + +// SUVersionDisplay +- (NSString *)formatUpdateDisplayVersionFromUpdate:(SUAppcastItem *)update andBundleDisplayVersion:(NSString * _Nonnull __autoreleasing * _Nonnull)inOutBundleDisplayVersion withBundleVersion:(NSString *)bundleVersion; + +- (NSString *)formatBundleDisplayVersion:(NSString *)bundleDisplayVersion withBundleVersion:(NSString *)bundleVersion matchingUpdate:(SUAppcastItem * _Nullable)matchingUpdate; @end +NS_ASSUME_NONNULL_END + #endif diff --git a/src/MacVim/MMSparkle2Delegate.m b/src/MacVim/MMSparkle2Delegate.m index 57644ac6fa..82b149da8b 100644 --- a/src/MacVim/MMSparkle2Delegate.m +++ b/src/MacVim/MMSparkle2Delegate.m @@ -24,6 +24,35 @@ @implementation MMSparkle2Delegate; return [NSSet set]; } +- (_Nullable id )standardUserDriverRequestsVersionDisplayer +{ + return self; +} + +/// MacVim has a non-standard way of using "bundle version" and "display version", +/// where the display version is the upstream Vim version, and the bundle version +/// is the release number of MacVim itself. The release number is more useful to +/// know when updating MacVim, but both should be displayed. Format them nicely so +/// it's clear to the user which is which. By default Sparkle would only show display +/// version which is problematic as that wouldn't show the release number which we +/// care about. +NSString* formatVersionString(NSString* bundleVersion, NSString* displayVersion) +{ + return [NSString stringWithFormat:@"r%@ (Vim %@)", bundleVersion, displayVersion]; +} + +- (NSString *)formatUpdateDisplayVersionFromUpdate:(SUAppcastItem *)update andBundleDisplayVersion:(NSString * _Nonnull __autoreleasing * _Nonnull)inOutBundleDisplayVersion withBundleVersion:(NSString *)bundleVersion +{ + *inOutBundleDisplayVersion = formatVersionString(bundleVersion, *inOutBundleDisplayVersion); + return formatVersionString(update.versionString, update.displayVersionString); +} + +- (NSString *)formatBundleDisplayVersion:(NSString *)bundleDisplayVersion withBundleVersion:(NSString *)bundleVersion matchingUpdate:(SUAppcastItem * _Nullable)matchingUpdate +{ + return formatVersionString(bundleVersion, bundleDisplayVersion); +} + + @end; #endif