Only accept service requests when we actually have a selection

This commit is contained in:
Kovid Goyal 2023-02-01 12:17:59 +05:30
parent c201bac900
commit 1c6bae636b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1581,10 +1581,14 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) {
// Support services receiving "public.utf8-plain-text" and "NSStringPboardType" // Support services receiving "public.utf8-plain-text" and "NSStringPboardType"
- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
{ {
if ([sendType isEqual:NSPasteboardTypeString] || [sendType isEqual:@"NSStringPboardType"]) { if (
return self; (!sendType || [sendType isEqual:NSPasteboardTypeString] || [sendType isEqual:@"NSStringPboardType"]) &&
(!returnType || [returnType isEqual:NSPasteboardTypeString] || [returnType isEqual:@"NSStringPboardType"])
) {
NSString *text = [self accessibilitySelectedText];
if (text && text.length > 0) return self;
} }
return nil; return [super validRequestorForSendType:sendType returnType:returnType];
} }
// Selected text as input to be sent to Services // Selected text as input to be sent to Services