Do not accept dropped text of type public.plain-text

The stringForType: method seems unable to handle this type, as a textClipping file dragged to TextMate (on 10.11) will result in a string with null bytes, presumably because the data was UTF-16 but interpreted as ASCII / MacRoman.

This change mirrors what we did for services in commit 062a939189
This commit is contained in:
Allan Odgaard
2016-08-18 21:54:16 +02:00
parent dbdfa3c6af
commit 196db13f1d

View File

@@ -3400,7 +3400,7 @@ static char const* kOakMenuItemTitle = "OakMenuItemTitle";
{
return @[ NSColorPboardType, NSFilenamesPboardType,
@"WebURLsWithTitlesPboardType", (NSString*)kUTTypeURL, @"public.url-name", NSURLPboardType,
@"public.plain-text" ];
NSStringPboardType ];
}
- (void)setDropMarkAtPoint:(NSPoint)aPoint
@@ -3591,7 +3591,7 @@ static char const* kOakMenuItemTitle = "OakMenuItemTitle";
documentView->set_ranges(ng::range_t(pos));
documentView->insert(text::join(paths, "\n"));
}
else if(NSString* text = [pboard stringForType:[pboard availableTypeFromArray:@[ @"public.plain-text" ]]] ?: [pboard stringForType:NSStringPboardType])
else if(NSString* text = [pboard stringForType:[pboard availableTypeFromArray:@[ NSStringPboardType ]]])
{
D(DBF_OakTextView_DragNDrop, bug("plain text: %s\n", [text UTF8String]););
if(shouldMove)