-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsmart_new_window.py
More file actions
30 lines (20 loc) · 951 Bytes
/
smart_new_window.py
File metadata and controls
30 lines (20 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import sublime
import sublime_plugin
class SmartNewWindowCommand(sublime_plugin.ApplicationCommand):
def run(self):
current_window = sublime.active_window()
if current_window.project_file_name():
# A project file is already open. Sublime Text covers this case with a
# command.
current_window.run_command("new_window_for_project")
elif current_window.folders():
# No project is open. There are just open folders added to the window.
# We will replicate the in-memory project manually.
current_window.run_command("new_window")
new_window = sublime.active_window()
new_window.set_project_data(current_window.project_data())
else:
# No project or open folders. We will just create a plain new window.
current_window.run_command("new_window")
def is_enabled(self):
return True