-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'show build results only on a failed build' feature #8
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import sublime | ||
import sublime_plugin | ||
import re | ||
|
||
import functools | ||
|
||
class SublimeOnSaveBuild(sublime_plugin.EventListener): | ||
def on_post_save(self, view): | ||
|
@@ -15,10 +15,34 @@ def on_post_save(self, view): | |
# Load filename filter. Again, a project level setting takes precedence. | ||
filename_filter = view.settings().get('filename_filter', global_settings.get('filename_filter', '*')) | ||
|
||
# Check if we should automatically hide the build window | ||
auto_hide_build_window = view.settings().get('auto_hide_build_window', global_settings.get('auto_hide_build_window', True)) | ||
|
||
if not should_build: | ||
return | ||
|
||
if not re.search(filename_filter, view.file_name()): | ||
return | ||
|
||
# show the 'exec' view before building, so we can read from it afterwards | ||
self.output_view = view.window().get_output_panel("exec") | ||
|
||
view.window().run_command('build') | ||
|
||
if auto_hide_build_window: | ||
self.num_polls = 0 | ||
# start polling for results every 100s | ||
self.poll_for_results(view) | ||
|
||
def poll_for_results(self, view): | ||
build_finished = self.output_view.find('Finished', 0) != None | ||
|
||
if build_finished: | ||
errors = self.output_view.find('Error', 0) | ||
if errors == None: | ||
view.window().run_command("hide_panel", {"panel": "output.exec"}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I believe the |
||
else: | ||
if self.num_polls < 300: | ||
sublime.set_timeout(functools.partial(self.poll_for_results, view), 200) | ||
|
||
self.num_polls += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at Packages/Default/exec.py, a more robust way to do the error check would be: