def get_project_path(window: sublime.Window) -> 'Optional[str]':
"""
Returns the common root of all open folders in the window
"""
if len(window.folders()):
folder_paths = window.folders()
return folder_paths[0]
else:
view = window.active_view()
if view:
filename = view.file_name()
if filename:
project_path = os.path.dirname(filename)
debug("Couldn't determine project directory since no folders are open!",
"Using", project_path, "as a fallback.")
return project_path
else:
debug("Couldn't determine project directory since no folders are open",
"and the current file isn't saved on the disk.")
return None
else:
debug("No view is active in current window")
return None # https://github.com/tomv564/LSP/issues/219
评论列表
文章目录