Question

I often have Safari open while working on a project in Xcode, looking up stuff on Stack Overflow and the like. A few times, I've searched something in to the web address/search engine field of Safari, and a word or two from what I typed in and it will be entered into the Search Navigator in Xcode, even though I didn't type it in there. It doesn't do it every time.

EDIT: Text entered in through the Search Navigator can pop up in Safari too.

This doesn't cause any problems, but the words it picks don't seem to have any relevance, and I'm curious as to why this oddity is happening.

I'm running Xcode 4.6.3, Safari 6.0.3, and Mac OS X 10.8.4

Is this a glitch? A half-baked feature?

Was it helpful?

Solution

What you are seeing is the OS X Global Find Pasteboard in action. Anywhere the private class NSFindPanel is invoked (typically in conjunction with a text field) this global pasteboard will get invoked and provides a single, central location for 'find' metadata which includes the most recent query:

In addition to communicating search strings via the find pasteboard, the standard Find panel for NSTextView also communicates search option metadata, including case sensitivity and substring matching options. This metadata is stored in a property list as the NSFindPanelSearchOptionsPboardType value on the global find pasteboard. As such, third party applications may store additional keys in this property list to communicate additional metadata as desired to support the various search options common to many third-party applications' Find panels.

from Section "Find Panel Search Metadata" in the NSTextField documentation on developer.apple.com

I believe the design intent to be, if you've performed a search in one app, there is a reasonably high probability that you'll be doing the same search in another app, so the global find pasteboard acts as a syncing mechanism between Find fields on disparate apps. For those coming from other operating systems, this would appear to be very odd behavior where the find capabilities of an app are very much sandboxed to their own process -- the most recent search term is an app-specific search term, not this global shared space.

As far as replication is concerned, you can always trigger the reported behavior by coping text to the clipboard, then pasting it into a Find field. When you switch from application to application the global find pasteboard will update the find NSFindPanel. This is why you see it going both ways between Xcode and Safari -- as both use NSFindPanel, both reference the global find pasteboard and sync up when the next time they get focus.

Unfortunately, this is not a user-configurable kind of setting; all NSFindPanels have this behavior and there is not a System Preferences or defaults preference you can set to change the behavior. Consider filing an issue with Apple at bugreport.apple.com

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top