Adjust timing detecting URL link

This commit is contained in:
1024jp 2016-02-18 19:02:52 +09:00
parent 3a2d83640a
commit 3387de8965
2 changed files with 14 additions and 0 deletions

View File

@ -11,12 +11,14 @@ develop
- Add `--wait` (`-w`) option to wait until a newly opened window closes.
- Optimize command performance.
- Fix an issue where command cannot open file whose path includes non-ascii character.
- Now, the change of “link URL” option is applied to opened documents immediately.
### Fix
- Fix an issue where documents were marked as “Edited” just after opening file if “link URL” option is enabled.
- Fix an issue where URL link was not applied to pasted text.

View File

@ -858,6 +858,12 @@ static NSCharacterSet *kMatchingClosingBracketsSet;
- (BOOL)readSelectionFromPasteboard:(nonnull NSPasteboard *)pboard type:(nonnull NSString *)type
// ------------------------------------------------------
{
// apply link to pasted string
__unsafe_unretained typeof(self) weakSelf = self; // NSTextView cannot be weak
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf detectLinkIfNeeded];
});
// on file drop
if ([type isEqualToString:NSFilenamesPboardType]) {
NSArray<NSDictionary<NSString *, NSString *> *> *fileDropDefs = [[NSUserDefaults standardUserDefaults] arrayForKey:CEDefaultFileDropArrayKey];
@ -1028,6 +1034,12 @@ static NSCharacterSet *kMatchingClosingBracketsSet;
} else if ([keyPath isEqualToString:CEDefaultAutoLinkDetectionKey]) {
[self setAutomaticLinkDetectionEnabled:[newValue boolValue]];
if ([self isAutomaticLinkDetectionEnabled]) {
[self detectLinkIfNeeded];
} else {
// remove current links
[[self textStorage] removeAttribute:NSLinkAttributeName range:NSMakeRange(0, [[self string] length])];
}
}
}