lilyball Posted May 30, 2017 Posted May 30, 2017 If I search for a place in Maps and hit ⌘C, it copies both an image of the map, as well as plain text that contains a URL like https://maps.apple.com/?address=826 Folsom St, San Francisco, CA 94107, United States&auid=7989913039222126743&ll=37.781586,-122.402010&lsp=9902&q=Zero Zero&t=m. I have Alfred configured to save plain text, so I would expect Alfred's Clipboard History to retain the URL there, but it doesn't. Alfred doesn't keep any history of URLs copied from Maps.app. I've tested this with "Keep Images" enabled and with it disabled, and in neither case does Alfred save the history. And I don't have Maps configured in the Ignore Apps section.
lilyball Posted May 30, 2017 Author Posted May 30, 2017 If I press ⌘⌥C in Maps, which is just Copy Link, then Alfred clipboard history works correctly. But this produces the same pasteboard as regular Copy, just without the image. The presence of a large image shouldn't cause Alfred to skip saving the plain text.
Andrew Posted May 30, 2017 Posted May 30, 2017 @kballard I've just looked into this and there is definitely something odd going on with Maps.app which initially appears to be a bug. When copying something from Maps.app, there are no types reported in the clipboard. For example, if I copy a URL from Safari (or any other Mac app), I see this: TYPES: ( "dyn.ah62d4rv4gu8zs3pcnzme2641rf4guzdmsv0gn64uqm10c6xenv61a3k", WebURLsWithTitlesPboardType, "dyn.ah62d4rv4gu8yc6durvwwaznwmuuha2pxsvw0e55bsmwca7d3sbwu", "Apple URL pasteboard type", "public.url", "CorePasteboardFlavorType 0x75726C20", "public.url-name", "CorePasteboardFlavorType 0x75726C6E", "public.utf8-plain-text", NSStringPboardType ) And this is what I see when copying from Maps.app using cmd+c: TYPES: ( ) ... But doing a subsequent paste of this copy to e.g. TextEdit, it pastes a stack of stuff. I haven't finished looking at this, but it looks like Maps.app is doing something fudgy and non-standard to get the data / URL into the clipboard. This would explain why there is different behaviour in Maps.app vs other apps. Andrew
lilyball Posted May 30, 2017 Author Posted May 30, 2017 I just tested copying from Maps and then printing out NSPasteboard.general().types and I get the expected types. So maybe it's just something weird like there being a very short delay in between you getting notified of a change (how do you get notified anyway?) and Maps actually declaring the types properly?
Andrew Posted May 30, 2017 Posted May 30, 2017 Alfred watches the pasteboard change count. It looks like the change count is increased, but nothing is in the clipboard (yet), then a short period later, the data is defined in the clipboard. There is no way to achieve this using the standard pasteboard API, which is why you don't see this behaviour with other apps, so I suspect they may be doing something sketchy behind the scenes. I'm not sure I want to add a fudge into Alfred to cater for this one specific case, but I will raise a bug against Maps.app. Cheers, Andrew
lilyball Posted May 30, 2017 Author Posted May 30, 2017 What if you call `clearContents()`, then add an artificial delay, then `writeObjects()`? As long as ownership didn't change in the meantime, could this cause Alfred to see the change count increase with nothing on the pasteboard, and then have the pasteboard populate shortly afterwards?
Andrew Posted May 30, 2017 Posted May 30, 2017 @kballard hmm, I had (wrongly?) assumed that this would have either been wrapped in a single pasteboard "transaction", or clearContents would have adjusted the clipboard change count (i.e. clipboard changed to empty), then writeObjects would have adjusted it too (i.e. changed to contents). I've had a bit of a play with this and I can comfortably ignore clip counter changes until there are types available. Thanks for highlighting this - I'll have this fixed in the next 3.4 pre-release Cheers, Andrew lilyball 1
Andrew Posted June 2, 2017 Posted June 2, 2017 @kballard this is now sorted if you update to the b837 pre-release. I'm still tempted in raising a ticket with Apple though, as it doesn't feel right that the clip counter can happen before the clip changes are seen as complete. Cheers, Andrew
lilyball Posted June 2, 2017 Author Posted June 2, 2017 (edited) @Andrew Excellent. I'll check that out now. Incidentally, the first line of the change log for the pre-release has a typo ("exapnsion"). As for reporting it, you could do that, but I'm honestly not sure how they're supposed to know that clipboard changes are complete. I can erase the clipboard now, then write one piece of data to it, then a bit later on add more data to the clipboard, and there's no way for me to say that I'm "done" mucking with it. Edited June 2, 2017 by kballard
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now