{"action":"created","issue":{"url":"https://api.github.com/repos/rosshemsley/iOpener/issues/17","labels_url":"https://api.github.com/repos/rosshemsley/iOpener/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/rosshemsley/iOpener/issues/17/comments","events_url":"https://api.github.com/repos/rosshemsley/iOpener/issues/17/events","html_url":"https://github.com/rosshemsley/iOpener/pull/17","id":120000887,"number":17,"title":"Added support for Sublime Text v2.","user":{"login":"mattst","id":835623,"avatar_url":"https://avatars.githubusercontent.com/u/835623?v=3","gravatar_id":"","url":"https://api.github.com/users/mattst","html_url":"https://github.com/mattst","followers_url":"https://api.github.com/users/mattst/followers","following_url":"https://api.github.com/users/mattst/following{/other_user}","gists_url":"https://api.github.com/users/mattst/gists{/gist_id}","starred_url":"https://api.github.com/users/mattst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattst/subscriptions","organizations_url":"https://api.github.com/users/mattst/orgs","repos_url":"https://api.github.com/users/mattst/repos","events_url":"https://api.github.com/users/mattst/events{/privacy}","received_events_url":"https://api.github.com/users/mattst/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-12-02T18:01:04Z","updated_at":"2015-12-08T22:20:01Z","closed_at":"2015-12-05T19:25:26Z","pull_request":{"url":"https://api.github.com/repos/rosshemsley/iOpener/pulls/17","html_url":"https://github.com/rosshemsley/iOpener/pull/17","diff_url":"https://github.com/rosshemsley/iOpener/pull/17.diff","patch_url":"https://github.com/rosshemsley/iOpener/pull/17.patch"},"body":"I've modified `i_opener.py` so that it now works with Sublime Text v2. It has been tested with the latest release versions of both ST2 and ST3 on both Linux (64 bit) and Windows XP (32 bit) and is working well.\r\n\r\nPlease note that I use the ST setting `trim_trailing_white_space_on_save`. When I did a `git diff` with the last commit, dozens of lines were shown as changed when they had not been and I realized they must have had trailing whitespace. Ignore these with the `git diff --ignore-space-at-eol` option (regular diff uses `-Z` to do the same thing). I can't seem to find any way to tell github to ignore trailing whitespace in the diff on the pull request page.\r\n\r\n\r\n### List of changes made in branch `st2_support`:\r\n\r\n\r\n1) Added the `set_sublime_text_version()` function and a ST version check in the `iOpenerCommand` class.\r\n\r\n2) Changed the `get_current_path()` method to use the ST window class method `folders()` instead of `project_data()` to get the project's folders (if any). `folders()` always provides the full path to project folders so the code to build the full path is no longer necessary. It returns an empty list if there is no open project or if an open project has no folders set. `project_data()` is only in the ST3 API, while `folders()` is in both the ST2 and ST3 APIs.\r\n\r\n3) Removed the `os.path import` of `isabs()`; it is no longer needed due to 2).\r\n\r\n4) Changed the `on_query_context()` method in the `iOpenerEventListener` class.\r\n\r\nInstead of directly comparing the view objects, it now compares the view objects' ids. i.e.\r\n\r\n    Was: iOpenerCommand.input_panel.view == view\r\n    Now: iOpenerCommand.input_panel.view.id() == view.id()\r\n\r\nThis was done for compatibility with ST2 because the view object comparison always failed. It took me a while to work out why it was failing but, by inspecting the view class of both APIs, I discovered that the view class in the ST3 API has the *special* methods `__eq__` and `__ne__`, which facilitate object comparison tests using `==` and `!=`, while the view class in the ST2 API does not have them. `view.id()` returns an integer which uniquely identifies the view, using this for the comparison works well with both ST2 and ST3 and is a suitable alternative to directly comparing the objects.\r\n\r\n5) Several changes to the `open_file()` method in the `Path_input` class:\r\n\r\na) Fixed a minor *bug* by moving the call to `add_to_history()` below the check for empty paths, so that empty paths no longer get added to the history. The *bug* can be reproduced by opening an empty path and then scrolling up in the history.\r\n\r\nb) If the user enters the path to a folder, the plugin adds that folder to the project folder list (in a new window by default). Project data can not be set using the ST2 API so this feature is incompatible with ST2. A check has been added to see if ST2 is running before trying to add a project folder, if it is then a status message is displayed saying that opening folders requires ST3 and the method returns.\r\n\r\nc) Fixed a minor *bug* that allows users to create a new buffer with the same full path as an existing folder, they would never be able to save the file. The *bug* can be reproduced by opening a buffer with the same full path as an existing folder but without a trailing slash. It was fixed by changing the `if filename == \"\":` line to `if isdir(path):` which in ST3 *opens the folder* even if the path is missing the trailing slash, while ST2 users get the status message saying that opening folders requires ST3 as described in b).\r\n\r\nFinally: It took great strength to resist changing the name of the `Path_input` class to `iOpenerPathInput` so that the class names all follow the same naming convention; but recognizing that it's a little OCD of me I left if for you to do so if you wish. [Actually I did change it but changed it back again after recognizing that it wasn't my place to do so.]\r\n\r\nI hope this helps. All the best, mattst\r\n"},"comment":{"url":"https://api.github.com/repos/rosshemsley/iOpener/issues/comments/163036241","html_url":"https://github.com/rosshemsley/iOpener/pull/17#issuecomment-163036241","issue_url":"https://api.github.com/repos/rosshemsley/iOpener/issues/17","id":163036241,"user":{"login":"mattst","id":835623,"avatar_url":"https://avatars.githubusercontent.com/u/835623?v=3","gravatar_id":"","url":"https://api.github.com/users/mattst","html_url":"https://github.com/mattst","followers_url":"https://api.github.com/users/mattst/followers","following_url":"https://api.github.com/users/mattst/following{/other_user}","gists_url":"https://api.github.com/users/mattst/gists{/gist_id}","starred_url":"https://api.github.com/users/mattst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattst/subscriptions","organizations_url":"https://api.github.com/users/mattst/orgs","repos_url":"https://api.github.com/users/mattst/repos","events_url":"https://api.github.com/users/mattst/events{/privacy}","received_events_url":"https://api.github.com/users/mattst/received_events","type":"User","site_admin":false},"created_at":"2015-12-08T22:20:00Z","updated_at":"2015-12-08T22:20:00Z","body":"> There's another PR pending that allows you to hide hidden files and other junk in listings if you ever fancy looking.\r\n\r\nI already took a look.\r\n\r\n> If you can find a way to make a failing test for the ST2 fix\r\n\r\nOk, but I've not used circleci before.\r\n\r\nI've just finished the new feature I mentioned. My intention is to make the `USE_PROJECT_DIR` setting redundant, or at least less important. It's a copy of the history cycle feature, it works in the same way but cycles through all available folders; i.e. folder of current file, then all project folders. It only differs in that it's on an infinite loop, last goes to first and visa-versa. Key mapping is `ctrl+up` and `ctrl+down` (for Linux/Win, along the same lines for OSX, I'll look into that tomorrow). Working perfectly in both ST v3 and v2.\r\n\r\nOne other thing:- I think the way the settings are managed should be changed. At the moment a settings file is used:\r\n\r\n    SETTINGS_FILE = 'i_opener.sublime-settings'\r\n\r\nThe only way a setting can be changed is for the user to duplicate the settings file to their user folder and change the setting. I propose ditching that totally and creating settings like this:\r\n\r\n    iopener_use_project_dir\r\n    iopener_open_folders_in_new_window\r\n    iopener_case_sensitive\r\n    iopener_history_entries\r\n\r\nThe user would then change the iOpener settings in their `User/Preferences.sublime-settings` file. The default values for the settings can then be hard coded into `i_opener.py` or in a `settings.py` module if you prefer.\r\n\r\nWith the go ahead I'll do that tomorrow but won't start unless you give the nod.\r\n\r\nBy the way, some of the folder completion is broken. With 2 folders with the same name at the start, e.g. `Temp` and `Templates`, It'll autocomplete to the shortest adding the final slash and never offering the completion choice at all. I was going to take a look but did the folder cycling instead.\r\n\r\nHTH.\r\n"}}