[quote=“tito”]I was able to create a solution for project related things with SideBarEnhancements
for example
from sidebar.SideBarProject import SideBarProject
SideBarProject().getPreference('folders')
That will return “folders” value of the project file.
it would be nice if you can use that api if available and fit your needs. I’ll appreciate contributions to that file.
You may can include a copy of that file in your package and load it only if SideBarProject is not already defined.[/quote]
Pretty cool. Are you searching the session as well or are you doing it differently? I did throw together a simple solution. It isn’t a lot of code, I just didn’t want to have to parse the session.
def get_project(win_id):
project = None
try:
with open(join(sublime.packages_path(), "..", "Settings", "Session.sublime_session")) as f:
j = json.load(f)
for w in j'windows']:
if w'window_id'] == win_id:
if "workspace_name" in w:
project = w"workspace_name"]
break
except:
pass
return project
Now with this I track the windows IDs that have been toggled to use per project favorites and I pair them in a dictionary with their project file path. Then you can also prune the them when the windows get closed (assuming my logic isn’t off).
def prune_projects(projects):
dead = set(projects.keys()) - set([x.id() for x in sublime.windows()])
for key in dead:
del projects[key]
I am considering just using the settings section in the project to store per project favorites. That way I don’t have to guess what folder to put them in. And that is what the settings section in the project file is for…per project settings. Still playing around though.