nathanhosselton / NJHMultiTheme

An Xcode plugin (defunct) for contextual themes
MIT License
11 stars 0 forks source link

File detection is broken in Xcode 7 #3

Closed nathanhosselton closed 9 years ago

nathanhosselton commented 9 years ago

Switching file types does not consistently change the theme in Xcode 7. Oddly, new files appear to be detected upon creation. Also, detection via window switching still works (this makes sense as it is a different detection method from file switching - new file creation is probably caught with this method as well).

Investigation required.

nathanhosselton commented 9 years ago

The issue actually lies at line 64 of https://github.com/nathanhosselton/NJHMultiTheme/commit/75d59770191d460a6cf8b70f9694851edc916c75 as the number of toolbar items has now increased to 7. This check was originally put in place to resolve #2 but was intended to be temporary as the return is incorrect behavior for when the number of toolbar items does not correspond the number expected in a Xcode project window and is thus the root of this issue.

For posterity: the purpose for even grabbing the specific toolbar item from the main window is to ensure that the assistant editor is not active, which would cause MultiTheme to crash Xcode due to a timeout (iirc), an issue for which I was unable to find a more direct solution. Thus, the correct behavior for failing to grab the toolbar item (due to it not being present because the current window is not a project window) is to simply skip the proceeding check on the status of the toolbar item and continue execution as normal.

I've considered alternative solutions to the check on the count of toolbar items (which is subject to change with IDE revisions), but outside of a try/catch all would similarly be strongly coupled to specific values that would be subject to change, and would additionally require loops. So I'll stick with the count check for now and deal with breakage as it may happen.

I should be able to fix this tonight.