Cmd-E search string from other apps not respected


#1

On the Mac, there is a pretty common system-wide convention that Cmd-E enters the current selection as the seach string, and then Cmd-G allows you to immediately search for instances of that string. Atom sort of follows this convention (although it opens the Find dialog instead of just keeping focus on the editor.)

However, Atom does not respect search strings entered from other apps. That is, you can select a CSS selector in Chrome inspector, press Cmd-E, and then switch to your CSS file and press Cmd-G to find occurrences of that selector. This works in most editors I’ve tried, but not Atom.

Has anyone else found this annoying? Is there a solution, or should I open an issue?


#2

I must admit I didn’t even know about that feature (not really a longtime mac user).
I don’t see how it works, and if chrome is able to handle that I’m not sure there’s a JS API to use in Atom to fix it. So yes, you should definitely open an issue.


#3

If you don’t use it or know about it, it’s nothing. If you use it daily and have been for 10 years, it is extremely annoying. TextEdit and Sublime handle this as expected. Hell, all mac apps I can think of handle this. Atom not handling it feels so wrong.

There are a couple of tickets open about this problem. atom/atom issue #4650 gives the details about how Mac OS does it. Maybe we can fix it with a package in the beginning, if there’s not enough up-front interest. Not sure it’s possible though, I haven’t written one yet, but this is itching a lot and I’m more tempted every day. As soon as I find the time.

In the mean time, maybe someone can help me and say if these operations are possible with the Atom plugin system. Seems like the idea would be to watch the “active state” of the app, if inactive->active, change the current find pattern to Mac OS’ global find pasteboard (we can shell out for this, not a biggy). If active=>inactive copy the other way around. Fairly straight forward if we have easy read/write access to the current find pattern and an event on the change of the state of the app, not sure we have those.

Also, while we’re at it, if we could make an alternative behavior for cmd+e in the app, where it does not focus the search box, that would be amazing! Looking at atom/find-and-replace it looks like it wouldn’t be too hard, everything is there, it would be a few lines of code to add the behavior that could then be activated through custom key-bindings, no need to impose this on everyone (though, it is the standard behavior for Sublime/TextEdit). Not sure if it’s possible from a package or if we need to patch atom/find-and-replace.

Anyone already working on the issue(s)?
Does someone know if the operations needed are (cleanly) supported by the Atom plugin system?

Thank you so much!

P.S. Can’t post with links to the open issues in this message, I get this error: “Sorry, new users can only put 2 links in a post.” I do have only 2 links in this post…!?


#4

Alright, I can’t post any link… The issues are on github.com then:

Cheers!


#5

Excellent. Subscribed to both of those issues.