From b5b76ffb1f9d0601af3182c1cb656d34ce81a567 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Sun, 7 Jul 2013 19:43:26 -0700 Subject: [PATCH] sending actions when switching between files --- sublime-wakatime.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sublime-wakatime.py b/sublime-wakatime.py index f3fed8d..3ae2898 100644 --- a/sublime-wakatime.py +++ b/sublime-wakatime.py @@ -76,17 +76,19 @@ class WakatimeListener(sublime_plugin.EventListener): def on_activated(self, view): now = time.time() - if enough_time_passed(now): + targetFile = view.file_name() + if enough_time_passed(now) or targetFile != LAST_FILE: if away(now): - api(view.file_name(), LAST_ACTION, endtime=now) + api(targetFile, LAST_ACTION, endtime=now) else: - api(view.file_name(), now) + api(targetFile, now) def on_selection_modified(self, view): now = time.time() - if enough_time_passed(now): + targetFile = view.file_name() + if enough_time_passed(now) or targetFile != LAST_FILE: if away(now): - api(view.file_name(), LAST_ACTION, endtime=now) + api(targetFile, LAST_ACTION, endtime=now) else: - api(view.file_name(), now) + api(targetFile, now)