mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Remove existance check before removing user style
This commit is contained in:
parent
2af95be7a9
commit
cd714d5908
@ -20,6 +20,7 @@ develop
|
||||
- Fix an issue where hanging indent was applied when document style is changed even it is turned off.
|
||||
- Fix an issue where the current line highlight didn't update under the specific condition.
|
||||
- Fix an issue where editor area was not focused when document opens.
|
||||
- Fix an issue where custom syntax style/theme couldn't be removed from the style list if the definition file is already deleted.
|
||||
- Fix an issue where URL links were removed when editor is split.
|
||||
|
||||
|
||||
|
@ -577,8 +577,6 @@ NSString *_Nonnull const IsUTF8WithBOM = @"UTF-8 with BOM";
|
||||
- (void)deleteSyntaxStyleWithName:(nonnull NSString *)styleName
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
if (![[CESyntaxManager sharedManager] URLForUserStyle:styleName]) { return; }
|
||||
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
[alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"Are you sure you want to delete “%@” syntax style?", nil), styleName]];
|
||||
[alert setInformativeText:NSLocalizedString(@"This action cannot be undone.", nil)];
|
||||
|
@ -328,25 +328,28 @@ NSString *_Nonnull const CESyntaxValidationMessageKey = @"MessageKey";
|
||||
|
||||
if ([URL checkResourceIsReachableAndReturnError:nil]) {
|
||||
success = [[NSFileManager defaultManager] trashItemAtURL:URL resultingItemURL:nil error:nil];
|
||||
|
||||
if (success) {
|
||||
// 内部で持っているキャッシュ用データを更新
|
||||
[[self styleCaches] removeObjectForKey:styleName];
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[self updateCacheWithCompletionHandler:^{
|
||||
typeof(self) self = weakSelf; // strong self
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:CESyntaxDidUpdateNotification
|
||||
object:self
|
||||
userInfo:@{CEOldNameKey: styleName,
|
||||
CENewNameKey: NSLocalizedString(@"None", nil)}];
|
||||
}];
|
||||
} else {
|
||||
NSLog(@"Error. Could not remove \"%@\".", URL);
|
||||
}
|
||||
} else {
|
||||
NSLog(@"Error. Could not be found \"%@\" for remove.", URL);
|
||||
// already removed.
|
||||
success = YES;
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
NSLog(@"Error. Could not remove \"%@\".", URL);
|
||||
return NO;
|
||||
}
|
||||
|
||||
// 内部で持っているキャッシュ用データを更新
|
||||
[[self styleCaches] removeObjectForKey:styleName];
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[self updateCacheWithCompletionHandler:^{
|
||||
typeof(self) self = weakSelf; // strong self
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:CESyntaxDidUpdateNotification
|
||||
object:self
|
||||
userInfo:@{CEOldNameKey: styleName,
|
||||
CENewNameKey: NSLocalizedString(@"None", nil)}];
|
||||
}];
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@ -361,25 +364,28 @@ NSString *_Nonnull const CESyntaxValidationMessageKey = @"MessageKey";
|
||||
|
||||
if ([URL checkResourceIsReachableAndReturnError:nil]) {
|
||||
success = [[NSFileManager defaultManager] trashItemAtURL:URL resultingItemURL:nil error:nil];
|
||||
|
||||
if (success) {
|
||||
// 内部で持っているキャッシュ用データを更新
|
||||
[self styleCaches][styleName] = [[self bundledStyleDictionaryWithStyleName:styleName] mutableCopy];
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[self updateCacheWithCompletionHandler:^{
|
||||
typeof(self) self = weakSelf; // strong self
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:CESyntaxDidUpdateNotification
|
||||
object:self
|
||||
userInfo:@{CEOldNameKey: styleName,
|
||||
CENewNameKey: styleName}];
|
||||
}];
|
||||
} else {
|
||||
NSLog(@"Error. Could not restore \"%@\".", URL);
|
||||
}
|
||||
} else {
|
||||
NSLog(@"Error. Could not be restore \"%@\" for restore.", URL);
|
||||
// already removed.
|
||||
success = YES;
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
NSLog(@"Error. Could not restore \"%@\".", URL);
|
||||
return NO;
|
||||
}
|
||||
|
||||
// 内部で持っているキャッシュ用データを更新
|
||||
[self styleCaches][styleName] = [[self bundledStyleDictionaryWithStyleName:styleName] mutableCopy];
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[self updateCacheWithCompletionHandler:^{
|
||||
typeof(self) self = weakSelf; // strong self
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:CESyntaxDidUpdateNotification
|
||||
object:self
|
||||
userInfo:@{CEOldNameKey: styleName,
|
||||
CENewNameKey: styleName}];
|
||||
}];
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ NSString *_Nonnull const CEThemeDidUpdateNotification = @"CEThemeDidUpdateNotifi
|
||||
{
|
||||
NSURL *URL = [self URLForUserTheme:themeName available:YES];
|
||||
|
||||
if (!URL) { return NO; }
|
||||
if (!URL) { return YES; } // already removed
|
||||
|
||||
BOOL success = [[NSFileManager defaultManager] trashItemAtURL:URL resultingItemURL:nil error:nil];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user