mirror of
https://github.com/MacDownApp/macdown.git
synced 2026-05-17 12:40:37 +00:00
Merge pull request #1086 from CDOApps/link-to-md-file
Check for .md file existence on link click.
This commit is contained in:
@@ -1927,7 +1927,22 @@ current file somewhere to enable this feature.", \
|
||||
- (void)openOrCreateFileForUrl:(NSURL *)url
|
||||
{
|
||||
// Simply open the file if it is not local, or exists already.
|
||||
if (!url.isFileURL || [url checkResourceIsReachableAndReturnError:NULL])
|
||||
BOOL file = url.isFileURL;
|
||||
BOOL reachable = !file || [url checkResourceIsReachableAndReturnError:NULL];
|
||||
|
||||
// If the file is local but doesn't exist, check if a file with
|
||||
// the .md extension exists.
|
||||
if (file && !reachable && [url.pathExtension isEqualToString:@""])
|
||||
{
|
||||
NSURL *markdownURL = [url URLByAppendingPathExtension:@"md"];
|
||||
if ([markdownURL checkResourceIsReachableAndReturnError:NULL])
|
||||
{
|
||||
reachable = YES;
|
||||
url = markdownURL;
|
||||
}
|
||||
}
|
||||
|
||||
if (reachable)
|
||||
{
|
||||
[[NSWorkspace sharedWorkspace] openURL:url];
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user