Skip to content

Commit

Permalink
Fix ST3 plugin directory detection
Browse files Browse the repository at this point in the history
  • Loading branch information
kemayo committed Jan 9, 2016
1 parent d076053 commit 9bdc984
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@


# Goal is to get: "Packages/Git", allowing for people who rename things
def find_plugin_directory(f):
dirname = os.path.split(os.path.dirname(f))[-1]
def find_plugin_directory():
if __file__.startswith('./'):
# ST2, we get "./git/__init__.py" which is pretty useless since we want the part above that
# However, os.getcwd() is the plugin directory!
full = os.getcwd()
else:
# In a complete inversion, in ST3 when a plugin is loaded we
# actually can trust __file__. It'll be something like:
# /Users/dlynch/Library/Application Support/Sublime Text 3/Packages/Git/git/__init__.py
full = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
dirname = os.path.split(full)[-1]
return "Packages/" + dirname.replace(".sublime-package", "")
if __file__.startswith('./'):
PLUGIN_DIRECTORY = os.getcwd().replace(os.path.normpath(os.path.join(os.getcwd(), '..', '..')) + os.path.sep, '').replace(os.path.sep, '/')
else:
# In a complete inversion from ST2, in ST3 when a plugin is loaded we
# actually can trust __file__.
PLUGIN_DIRECTORY = find_plugin_directory(os.path.normpath(os.path.join(os.path.dirname(__file__), '..')))
PLUGIN_DIRECTORY = find_plugin_directory()


def main_thread(callback, *args, **kwargs):
Expand Down

0 comments on commit 9bdc984

Please sign in to comment.