Skip to content

Commit

Permalink
Improve on-save check status message. (#293)
Browse files Browse the repository at this point in the history
This makes it so the status message at the bottom of the window doesn't
disappear when you switch views.  It also adds some subtle animation.
  • Loading branch information
ehuss authored and jasonwilliams committed Jun 23, 2018
1 parent b67de81 commit 7943659
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions SyntaxCheckPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class RustSyntaxCheckThread(rust_thread.RustThread, rust_proc.ProcListener):
name = 'Syntax Check'
# The Sublime view that triggered the check.
view = None
# The Sublime window that triggered the check.
window = None
# Absolute path to the view that triggered the check.
triggered_file_name = None
# Directory where cargo will be run.
Expand All @@ -54,9 +56,11 @@ class RustSyntaxCheckThread(rust_thread.RustThread, rust_proc.ProcListener):
# The path to the top-level Cargo target filename (like main.rs or
# lib.rs).
current_target_src = None
done = False

def __init__(self, view):
self.view = view
self.window = view.window()
super(RustSyntaxCheckThread, self).__init__(view.window())

def run(self):
Expand All @@ -69,7 +73,7 @@ def run(self):
print('A Cargo.toml manifest is required.')
return

self.view.set_status('rust-check', 'Rust syntax check running...')
self.update_status()
self.this_view_found = False
try:
messages.clear_messages(self.window)
Expand All @@ -79,7 +83,19 @@ def run(self):
return
messages.messages_finished(self.window)
finally:
self.view.erase_status('rust-check')
self.done = True
self.window.status_message('')

def update_status(self, count=0):
if self.done:
return
num = count % 4
if num == 3:
num = 1
num += 1
msg = 'Rust check running' + '.' * num
self.window.status_message(msg)
sublime.set_timeout(lambda: self.update_status(count + 1), 200)

def get_rustc_messages(self):
"""Top-level entry point for generating messages for the given
Expand Down

0 comments on commit 7943659

Please sign in to comment.