From 6af17523def124d78b919e0765d3ecd6b752220a Mon Sep 17 00:00:00 2001 From: Igor Schlumberger Date: Wed, 11 Feb 2026 20:22:34 +0100 Subject: [PATCH] Restore OpenRecent Made with Codex 5.3. It work on my Mac silicon. --- MacDown.xcodeproj/project.pbxproj | 39 ++++++++++++++----- .../xcshareddata/xcschemes/MacDown.xcscheme | 24 +++++------- .../xcshareddata/WorkspaceSettings.xcsettings | 2 +- MacDown/Code/Document/MPDocument.m | 14 ++++++- .../Extension/NSDocumentController+Document.h | 5 +++ .../Extension/NSDocumentController+Document.m | 31 +++++++++++++++ MacDown/Resources/Styles/GitHub-2020.css | 0 Podfile.lock | 2 +- 8 files changed, 90 insertions(+), 27 deletions(-) create mode 100644 MacDown/Resources/Styles/GitHub-2020.css diff --git a/MacDown.xcodeproj/project.pbxproj b/MacDown.xcodeproj/project.pbxproj index 81f315a6..38dae016 100644 --- a/MacDown.xcodeproj/project.pbxproj +++ b/MacDown.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -971,8 +971,9 @@ 1FA6DE191941CC9E000409FB /* Project object */ = { isa = PBXProject; attributes = { + BuildIndependentTargetsInParallel = YES; CLASSPREFIX = MP; - LastUpgradeCheck = 0920; + LastUpgradeCheck = 2600; ORGANIZATIONNAME = "Tzu-ping Chung "; TargetAttributes = { 1FA6DE441941CC9E000409FB = { @@ -1191,12 +1192,10 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-MacDown/Pods-MacDown-frameworks.sh", "${PODS_ROOT}/Sparkle/Sparkle.framework", - "${PODS_ROOT}/Sparkle/Sparkle.framework.dSYM", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Sparkle.framework", - "${DWARF_DSYM_FOLDER_PATH}/Sparkle.framework.dSYM", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -1667,22 +1666,27 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; @@ -1702,6 +1706,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.8; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; + STRING_CATALOG_GENERATE_SYMBOLS = YES; }; name = Debug; }; @@ -1718,23 +1723,28 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_NO_COMMON_BLOCKS = YES; @@ -1746,6 +1756,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; SDKROOT = macosx; + STRING_CATALOG_GENERATE_SYMBOLS = YES; }; name = Release; }; @@ -1754,12 +1765,13 @@ baseConfigurationReference = 1A198D1BA59D710201DD3BC8 /* Pods-MacDown.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_IDENTITY = ""; + CODE_SIGN_IDENTITY = "-"; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "MacDown/Code/MacDown-Prefix.pch"; INFOPLIST_FILE = "MacDown/MacDown-Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.8; + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "com.uranusjr.${PRODUCT_NAME:rfc1034identifier:lower}-debug"; PRODUCT_NAME = MacDown; SDKROOT = macosx; @@ -1772,12 +1784,13 @@ baseConfigurationReference = 39EFCAE04F60154F0C8C5469 /* Pods-MacDown.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_IDENTITY = ""; + CODE_SIGN_IDENTITY = "-"; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "MacDown/Code/MacDown-Prefix.pch"; INFOPLIST_FILE = "MacDown/MacDown-Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.8; + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "com.uranusjr.${PRODUCT_NAME:rfc1034identifier:lower}"; PRODUCT_NAME = MacDown; SDKROOT = macosx; @@ -1792,6 +1805,7 @@ BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/MacDown.app/Contents/MacOS/MacDown"; CLANG_ENABLE_MODULES = NO; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = ( "$(DEVELOPER_FRAMEWORKS_DIR)", "$(inherited)", @@ -1807,7 +1821,7 @@ "$(inherited)", "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/MacDown-ggdtxvuybojeqbhjydkhilziizrv/Build/Products/Debug", ); - MACOSX_DEPLOYMENT_TARGET = 10.8; + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "com.uranusjr.${PRODUCT_NAME:rfc1034identifier:lower}"; PRODUCT_NAME = MacDownTests; TEST_HOST = "$(BUNDLE_LOADER)"; @@ -1822,6 +1836,7 @@ BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/MacDown.app/Contents/MacOS/MacDown"; CLANG_ENABLE_MODULES = NO; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = ( "$(DEVELOPER_FRAMEWORKS_DIR)", "$(inherited)", @@ -1833,7 +1848,7 @@ "$(inherited)", "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/MacDown-ggdtxvuybojeqbhjydkhilziizrv/Build/Products/Debug", ); - MACOSX_DEPLOYMENT_TARGET = 10.8; + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "com.uranusjr.${PRODUCT_NAME:rfc1034identifier:lower}"; PRODUCT_NAME = MacDownTests; TEST_HOST = "$(BUNDLE_LOADER)"; @@ -1845,12 +1860,14 @@ isa = XCBuildConfiguration; baseConfigurationReference = 4DBAA63927A60EB2150642B3 /* Pods-macdown-cmd.debug.xcconfig */; buildSettings = { + DEAD_CODE_STRIPPING = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_NAME = macdown; SKIP_INSTALL = YES; }; @@ -1860,8 +1877,10 @@ isa = XCBuildConfiguration; baseConfigurationReference = 7A8EA75FA95818275755F0B6 /* Pods-macdown-cmd.release.xcconfig */; buildSettings = { + DEAD_CODE_STRIPPING = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ""; + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_NAME = macdown; SKIP_INSTALL = YES; }; diff --git a/MacDown.xcodeproj/xcshareddata/xcschemes/MacDown.xcscheme b/MacDown.xcodeproj/xcshareddata/xcschemes/MacDown.xcscheme index e5486feb..02b075a8 100644 --- a/MacDown.xcodeproj/xcshareddata/xcschemes/MacDown.xcscheme +++ b/MacDown.xcodeproj/xcshareddata/xcschemes/MacDown.xcscheme @@ -1,6 +1,6 @@ + + + + @@ -39,17 +48,6 @@ - - - - - - - - BuildSystemType - Original + Latest diff --git a/MacDown/Code/Document/MPDocument.m b/MacDown/Code/Document/MPDocument.m index acbc77ff..a01acf8f 100644 --- a/MacDown/Code/Document/MPDocument.m +++ b/MacDown/Code/Document/MPDocument.m @@ -534,7 +534,14 @@ - (BOOL)writeToURL:(NSURL *)url ofType:(NSString *)typeName self.editor.selectedRange = selection; } } - return [super writeToURL:url ofType:typeName error:outError]; + BOOL ok = [super writeToURL:url ofType:typeName error:outError]; + if (ok) + { + NSDocumentController *controller = + [NSDocumentController sharedDocumentController]; + [controller mp_noteNewRecentDocumentURL:url]; + } + return ok; } - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError @@ -552,6 +559,11 @@ - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName self.loadedString = content; [self reloadFromLoadedString]; + + // Ensure the file is registered for the system "Open Recent" menu. + NSDocumentController *controller = + [NSDocumentController sharedDocumentController]; + [controller mp_noteNewRecentDocumentURL:self.fileURL]; return YES; } diff --git a/MacDown/Code/Extension/NSDocumentController+Document.h b/MacDown/Code/Extension/NSDocumentController+Document.h index 00a8f5d4..b8741d23 100644 --- a/MacDown/Code/Extension/NSDocumentController+Document.h +++ b/MacDown/Code/Extension/NSDocumentController+Document.h @@ -13,4 +13,9 @@ - (__kindof NSDocument *)createNewEmptyDocumentForURL:(NSURL *)url display:(BOOL)display error:(NSError * __autoreleasing *)error; +// Explicitly note a recently used document URL for the system "Open Recent" +// menu. We filter out temporary files to avoid polluting the list with app +// internals (help/treat files, etc.). +- (void)mp_noteNewRecentDocumentURL:(NSURL *)url; + @end diff --git a/MacDown/Code/Extension/NSDocumentController+Document.m b/MacDown/Code/Extension/NSDocumentController+Document.m index f9b5f8a2..031e7b61 100644 --- a/MacDown/Code/Extension/NSDocumentController+Document.m +++ b/MacDown/Code/Extension/NSDocumentController+Document.m @@ -10,6 +10,36 @@ @implementation NSDocumentController (Document) +- (void)mp_noteNewRecentDocumentURL:(NSURL *)url +{ + if (!url || !url.isFileURL) + return; + + NSString *path = url.path; + if (!path.length) + return; + + // Skip temp files (help, treats, other internal/generated docs). + NSString *tmp = NSTemporaryDirectory(); + if (tmp.length) + { + NSString *tmpResolved = + [[tmp stringByStandardizingPath] stringByResolvingSymlinksInPath]; + if (tmpResolved.length && ![tmpResolved hasSuffix:@"/"]) + tmpResolved = [tmpResolved stringByAppendingString:@"/"]; + + NSString *pathResolved = + [[path stringByStandardizingPath] stringByResolvingSymlinksInPath]; + if (tmpResolved.length && [pathResolved hasPrefix:tmpResolved]) + return; + } + + // Recent-documents updates are UI-adjacent; keep it on the main queue. + dispatch_async(dispatch_get_main_queue(), ^{ + [self noteNewRecentDocumentURL:url]; + }); +} + - (__kindof NSDocument *)createNewEmptyDocumentForURL:(NSURL *)url display:(BOOL)display error:(NSError * __autoreleasing *)error { @@ -24,6 +54,7 @@ - (__kindof NSDocument *)createNewEmptyDocumentForURL:(NSURL *)url doc.draft = YES; doc.fileURL = url; + [self mp_noteNewRecentDocumentURL:url]; return doc; } diff --git a/MacDown/Resources/Styles/GitHub-2020.css b/MacDown/Resources/Styles/GitHub-2020.css new file mode 100644 index 00000000..e69de29b diff --git a/Podfile.lock b/Podfile.lock index b90fe24a..d56b30ed 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -48,4 +48,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: e9356b9a2ceafda7889ba385de6e9f2d8b06cba0 -COCOAPODS: 1.8.4 +COCOAPODS: 1.16.2