Skip to content

Commit 2e0e7c1

Browse files
committed
Updating plugin to show the window until the build succeeds or fails, then hide it only on success
1 parent be3d6c5 commit 2e0e7c1

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

SublimeOnSaveBuild.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def on_post_save(self, view):
1616
filename_filter = view.settings().get('filename_filter', global_settings.get('filename_filter', '*'))
1717

1818
# Check if we should automatically hide the build window
19-
show_build_window_on_failure_only = view.settings().get('show_build_window_on_failure_only', global_settings.get('auto_hide_build_window', True))
19+
auto_hide_build_window = view.settings().get('auto_hide_build_window', global_settings.get('auto_hide_build_window', True))
2020

2121
if not should_build:
2222
return
@@ -29,10 +29,8 @@ def on_post_save(self, view):
2929

3030
view.window().run_command('build')
3131

32-
if show_build_window_on_failure_only:
32+
if auto_hide_build_window:
3333
self.num_polls = 0
34-
# immediately hide the 'exec' panel. Will show it again later if there were errors
35-
view.window().run_command("hide_panel", {"panel": "output.exec"})
3634
# start polling for results every 100s
3735
self.poll_for_results(view)
3836

@@ -41,13 +39,10 @@ def poll_for_results(self, view):
4139

4240
if build_finished:
4341
errors = self.output_view.find('Error', 0)
44-
if errors != None:
45-
view.window().run_command("show_panel", {"panel": "output.exec"})
42+
if errors == None:
43+
view.window().run_command("hide_panel", {"panel": "output.exec"})
4644
else:
47-
if self.num_polls < 50:
48-
sublime.set_timeout(functools.partial(self.poll_for_results, view), 100)
49-
else:
50-
# show the window if the build took longer than the specified amount
51-
view.window().run_command("show_panel", {"panel": "output.exec"})
45+
if self.num_polls < 300:
46+
sublime.set_timeout(functools.partial(self.poll_for_results, view), 200)
5247

5348
self.num_polls += 1

0 commit comments

Comments
 (0)