Skip to content

Commit 7943659

Browse files
ehussjasonwilliams
authored andcommitted
Improve on-save check status message. (#293)
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.
1 parent b67de81 commit 7943659

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

SyntaxCheckPlugin.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class RustSyntaxCheckThread(rust_thread.RustThread, rust_proc.ProcListener):
4040
name = 'Syntax Check'
4141
# The Sublime view that triggered the check.
4242
view = None
43+
# The Sublime window that triggered the check.
44+
window = None
4345
# Absolute path to the view that triggered the check.
4446
triggered_file_name = None
4547
# Directory where cargo will be run.
@@ -54,9 +56,11 @@ class RustSyntaxCheckThread(rust_thread.RustThread, rust_proc.ProcListener):
5456
# The path to the top-level Cargo target filename (like main.rs or
5557
# lib.rs).
5658
current_target_src = None
59+
done = False
5760

5861
def __init__(self, view):
5962
self.view = view
63+
self.window = view.window()
6064
super(RustSyntaxCheckThread, self).__init__(view.window())
6165

6266
def run(self):
@@ -69,7 +73,7 @@ def run(self):
6973
print('A Cargo.toml manifest is required.')
7074
return
7175

72-
self.view.set_status('rust-check', 'Rust syntax check running...')
76+
self.update_status()
7377
self.this_view_found = False
7478
try:
7579
messages.clear_messages(self.window)
@@ -79,7 +83,19 @@ def run(self):
7983
return
8084
messages.messages_finished(self.window)
8185
finally:
82-
self.view.erase_status('rust-check')
86+
self.done = True
87+
self.window.status_message('')
88+
89+
def update_status(self, count=0):
90+
if self.done:
91+
return
92+
num = count % 4
93+
if num == 3:
94+
num = 1
95+
num += 1
96+
msg = 'Rust check running' + '.' * num
97+
self.window.status_message(msg)
98+
sublime.set_timeout(lambda: self.update_status(count + 1), 200)
8399

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

0 commit comments

Comments
 (0)