-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling multiple Xcode installs #8
Conversation
…nstalls. Active document is detected based on the window title since the previous approach was occasionally grabbing a document in a different window within the same process. Should resolve tonyarnold#6.
… 4, regardless of how many windows, tabs, or assistant editors are in use. The Re-Indent workflow no longer saves the document after processing since the other workflows did not share that behavior.
…sponding characters. Fixed by using herestring input rather than piping the string to uncrustify via echo.
Doing a fresh checkout of your workflows, I can't open them locally. Automator thinks that they are corrupt — can you just check that everything is OK on your end? |
Sorry about that, it should be fixed now. That's what I get for editing outside of Automator. |
Thanks, @idpaterson — I'm going to need to spend some time with your changes, as your revised scripts don't work on my setup. |
…ith detecting the active document. This should allow enough time for the user to release any modifier keys that would affect the keystroke emitted by the script.
Shot in the dark... are you running the service with a keyboard shortcut that uses the Option or Control keys? There is apparently no way to send a keystroke unadulterated by the current keyboard state, so the active document detection portion of my changes was sending the Up Arrow key with either the Shift or Control modifiers if the service keyboard shortcut included those modifiers. In that situation, the Up Arrow does not change the selection in the active document and no active doc is found. Other people experiencing that problem in AppleScript used a 200ms delay to allow time for the keyboard shortcut to be released. |
I am, yes — I'll give your updated code another shot, but this is becoming very fragile. I think I need to look at making this a proper Xcode plugin now there are examples available. |
OK, shoot me a private message: It's not perfect, but I have a proof-of-concept of a native Xcode plugin that does the same thing as this automator workflow. It's already more reliable, and faster. I'm planning on making a commercial product out of it, so I'd like to keep the binary private for now, but I'd love to get your feedback! |
That sounds like a better direction, glad to hear it! |
The path of the frontmost application is now used to distinguish multiple Xcode installs, which should fix #6.
Additionally, I developed a robust technique to find the current active document in Xcode 4 since the approach in the first commit was not working in assistant editors. While this was trivial in Xcode 3, there were no good solutions out there for Xcode 4 that did not break down when pitted against multiple windows, tabs, or assistant editors.
There are a few ways that we can interact with the active document in AppleScript without actually having a reference to it, for example emitting keystrokes or changing the text selection. The approach used in this pull request is to:
text document
instances and record their currentselection
valuetext document
instances and find the one with a differentselection
valuetext document
and operate on itThis approach should work well until Xcode's AppleScript bindings are improved. Since the
menu_click
routine could be subject to system localization issues, I made a small "config" section at the top for convenience.