decreased number of events handled using global lock variable and skipping events without a file associated to the view
This commit is contained in:
parent
9d21626459
commit
d3d4a65538
1 changed files with 25 additions and 20 deletions
|
@ -108,8 +108,11 @@ def should_prompt_user(now):
|
|||
|
||||
|
||||
def handle_write_action(view):
|
||||
now = time.time()
|
||||
global BUSY
|
||||
BUSY = True
|
||||
targetFile = view.file_name()
|
||||
if targetFile:
|
||||
now = time.time()
|
||||
if enough_time_passed(now) or targetFile != LAST_FILE:
|
||||
if should_prompt_user(now):
|
||||
if away(now):
|
||||
|
@ -120,14 +123,16 @@ def handle_write_action(view):
|
|||
api(targetFile, now, endtime=LAST_ACTION, isWrite=True)
|
||||
else:
|
||||
api(targetFile, now, isWrite=True)
|
||||
BUSY = False
|
||||
|
||||
|
||||
def handle_normal_action(view):
|
||||
global LAST_USAGE, BUSY
|
||||
now = time.time()
|
||||
targetFile = view.file_name()
|
||||
if enough_time_passed(now) or targetFile != LAST_FILE:
|
||||
BUSY = True
|
||||
targetFile = view.file_name()
|
||||
if targetFile:
|
||||
now = time.time()
|
||||
if enough_time_passed(now) or targetFile != LAST_FILE:
|
||||
if should_prompt_user(now):
|
||||
if away(now):
|
||||
api(targetFile, now, endtime=LAST_ACTION)
|
||||
|
@ -135,9 +140,9 @@ def handle_normal_action(view):
|
|||
api(targetFile, now)
|
||||
else:
|
||||
api(targetFile, now, endtime=LAST_ACTION)
|
||||
BUSY = False
|
||||
else:
|
||||
LAST_USAGE = now
|
||||
BUSY = False
|
||||
|
||||
|
||||
class WakatimeListener(sublime_plugin.EventListener):
|
||||
|
|
Loading…
Reference in a new issue