Skip to content

Commit

Permalink
Improvement: refresh status bar and related fix (#659)
Browse files Browse the repository at this point in the history
* Improvement: refresh status bar less often

* Fix: 1 second equals 1000 ms
  • Loading branch information
randy3k committed May 29, 2017
1 parent 2b10772 commit d9abb60
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion common/global_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class GsInterfaceFocusEventListener(EventListener):
"""

def on_activated(self, view):
util.view.refresh_gitsavvy(view)
# status bar is handled by GsStatusBarEventListener
util.view.refresh_gitsavvy(view, refresh_status_bar=False)

def on_close(self, view):
util.view.handle_closed_view(view)
Expand Down
6 changes: 4 additions & 2 deletions common/util/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_is_view_of_type(view, typ):
# GLOBAL #
##########

def refresh_gitsavvy(view, refresh_sidebar=False):
def refresh_gitsavvy(view, refresh_sidebar=False, refresh_status_bar=True):
"""
Called after GitSavvy action was taken that may have effected the
state of the Git repo.
Expand All @@ -68,7 +68,9 @@ def refresh_gitsavvy(view, refresh_sidebar=False):
if view.settings().get("git_savvy.branch_commit_history_view") is not None:
view.run_command("gs_branches_diff_commit_history_refresh")

view.run_command("gs_update_status_bar")
if refresh_status_bar:
view.run_command("gs_update_status_bar")

if view.window() and refresh_sidebar:
view.window().run_command("refresh_folder_list")

Expand Down
4 changes: 2 additions & 2 deletions core/commands/status_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def run(self, edit):
global last_execution, update_status_bar_soon
if sublime.load_settings("GitSavvy.sublime-settings").get("git_status_in_status_bar"):

millisec = int(round(time.time() * 100))
millisec = int(round(time.time() * 1000))
# If we updated to less then 100 ms we don't need to update now but
# should update in 100 ms in case of current file change.
#
Expand All @@ -50,7 +50,7 @@ def run(self, edit):
update_status_bar_soon = True
sublime.set_timeout_async(self.run_async, 100)

last_execution = int(round(time.time() * 100))
last_execution = int(round(time.time() * 1000))

def run_async(self):
# Short-circuit update attempts for files not part of Git repo.
Expand Down

0 comments on commit d9abb60

Please sign in to comment.