adamwathan / sublime-phpunit

Run individual unit test files directly from Sublime
281 stars 43 forks source link

Re-focus Sublime after running tests #22

Open jimrubenstein opened 7 years ago

jimrubenstein commented 7 years ago

As I mentioned in #21, I often forget to restore focus to Sublime after running my tests.

This enhancement adds 2 new options (and supporting readme material) for automatically restoring focus to Sublime after tests are run.

By default, autofocus is off. I expect it's fine for most people. But when I have my terminal on one screen and Sublime in the other, it's super handy to have focus automatically be restored. I rarely ever need to type more terminal commands after my test suite starts.

eby commented 7 years ago

I did similar to this but instead of tabbing over I used the following:

tell application "System Events" to tell process "Sublime Text"
        set frontmost to true
end tell

Seems to work but not sure if it is the best method either.

jimrubenstein commented 7 years ago

I was messing with this method, or one like it, as well, but instead of coming into focus, sublime would just hang...so I tried the tab method.

Might've had something to do with the process I was running the command in, not sure.

I wish I could make this more intelligent though, to say, detect when sublime is overlapping the terminal and not re-focus then? Idk just a random thought I had when I was running some tests one day..haha

On Aug 1, 2017 1:18 PM, "Ryan Eby" notifications@github.com wrote:

I did similar to this but instead of tabbing over I used the following:

tell application "System Events" to tell process "Sublime Text" set frontmost to trueend tell

Seems to work but not sure if it is the best method either.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/adamwathan/sublime-phpunit/pull/22#issuecomment-319437113, or mute the thread https://github.com/notifications/unsubscribe-auth/AALajxcuTO0rja3_1P-nkOuBmES1G-HNks5sT13rgaJpZM4NDm-_ .

eby commented 7 years ago

I had the hang issue if I followed any of the suggestions of activate or window index but the frontmost seems to work without a hang, at least on my setup.