mirror of
https://github.com/wakatime/sublime-wakatime.git
synced 2023-08-10 21:13:02 +03:00
fix lineno, cursorpos, and lines-in-file arguments
This commit is contained in:
parent
7d2bd0b7c5
commit
4d6533b2ee
19
WakaTime.py
19
WakaTime.py
@ -417,10 +417,16 @@ def append_heartbeat(entity, timestamp, is_write, view, project, folders):
|
|||||||
'entity': entity,
|
'entity': entity,
|
||||||
'timestamp': timestamp,
|
'timestamp': timestamp,
|
||||||
'is_write': is_write,
|
'is_write': is_write,
|
||||||
'cursorpos': view.sel()[0].begin() if view.sel() else None,
|
|
||||||
'project': project,
|
'project': project,
|
||||||
'folders': folders,
|
'folders': folders,
|
||||||
|
'lines_in_file': view.rowcol(view.size())[0] + 1,
|
||||||
}
|
}
|
||||||
|
selections = view.sel()
|
||||||
|
if selections:
|
||||||
|
rowcol = view.rowcol(selections[0].begin())
|
||||||
|
row, col = rowcol[0] + 1, rowcol[1] + 1
|
||||||
|
heartbeat['lineno'] = row
|
||||||
|
heartbeat['cursorpos'] = col
|
||||||
HEARTBEATS.put_nowait(heartbeat)
|
HEARTBEATS.put_nowait(heartbeat)
|
||||||
|
|
||||||
# make this heartbeat the LAST_HEARTBEAT
|
# make this heartbeat the LAST_HEARTBEAT
|
||||||
@ -493,7 +499,8 @@ class SendHeartbeatsThread(threading.Thread):
|
|||||||
self.send_heartbeats()
|
self.send_heartbeats()
|
||||||
|
|
||||||
def build_heartbeat(self, entity=None, timestamp=None, is_write=None,
|
def build_heartbeat(self, entity=None, timestamp=None, is_write=None,
|
||||||
cursorpos=None, project=None, folders=None):
|
lineno=None, cursorpos=None, lines_in_file=None,
|
||||||
|
project=None, folders=None):
|
||||||
"""Returns a dict for passing to wakatime-cli as arguments."""
|
"""Returns a dict for passing to wakatime-cli as arguments."""
|
||||||
|
|
||||||
heartbeat = {
|
heartbeat = {
|
||||||
@ -509,8 +516,12 @@ class SendHeartbeatsThread(threading.Thread):
|
|||||||
if project_name:
|
if project_name:
|
||||||
heartbeat['alternate_project'] = project_name
|
heartbeat['alternate_project'] = project_name
|
||||||
|
|
||||||
|
if lineno is not None:
|
||||||
|
heartbeat['lineno'] = lineno
|
||||||
if cursorpos is not None:
|
if cursorpos is not None:
|
||||||
heartbeat['cursorpos'] = cursorpos
|
heartbeat['cursorpos'] = cursorpos
|
||||||
|
if lines_in_file is not None:
|
||||||
|
heartbeat['lines-in-file'] = lines_in_file
|
||||||
|
|
||||||
return heartbeat
|
return heartbeat
|
||||||
|
|
||||||
@ -529,8 +540,12 @@ class SendHeartbeatsThread(threading.Thread):
|
|||||||
cmd.append('--write')
|
cmd.append('--write')
|
||||||
if heartbeat.get('alternate_project'):
|
if heartbeat.get('alternate_project'):
|
||||||
cmd.extend(['--alternate-project', heartbeat['alternate_project']])
|
cmd.extend(['--alternate-project', heartbeat['alternate_project']])
|
||||||
|
if heartbeat.get('lineno') is not None:
|
||||||
|
cmd.extend(['--lineno', '{0}'.format(heartbeat['lineno'])])
|
||||||
if heartbeat.get('cursorpos') is not None:
|
if heartbeat.get('cursorpos') is not None:
|
||||||
cmd.extend(['--cursorpos', '{0}'.format(heartbeat['cursorpos'])])
|
cmd.extend(['--cursorpos', '{0}'.format(heartbeat['cursorpos'])])
|
||||||
|
if heartbeat.get('lines_in_file') is not None:
|
||||||
|
cmd.extend(['--lines-in-file', '{0}'.format(heartbeat['lines_in_file'])])
|
||||||
for pattern in self.ignore:
|
for pattern in self.ignore:
|
||||||
cmd.extend(['--exclude', pattern])
|
cmd.extend(['--exclude', pattern])
|
||||||
for pattern in self.include:
|
for pattern in self.include:
|
||||||
|
Loading…
Reference in New Issue
Block a user