hangxingliu / vscode-coding-tracker

:clock10: A coding activities tracker(time, file, type)
GNU General Public License v3.0
172 stars 34 forks source link

Exception print in console #18

Closed hangxingliu closed 6 years ago

hangxingliu commented 6 years ago
TypeError: Cannot set property 'lineCount' of null
    at Object.onFileCoding (/path/to/vscode-coding-tracker/extension.js:168:34)
    at subscriptions.push.vscode.workspace.onDidChangeTextDocument.e (/path/to/vscode-coding-tracker/extension.js:229:83)
    at e.fire (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:87:218)
    at e.$acceptDirtyStateChanged (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:432:782)
    at t.e.invoke (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:516:87)
    at e._invokeHandler (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:357:580)
    at e._receiveOneMessage (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:357:270)
    at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:356:206
    at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:358:204
    at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:85:988
    at e.fire (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:87:218)
    at Socket.<anonymous> (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:135:717)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)
hangxingliu commented 6 years ago

This is a bug from vscode:

  1. Event onDidChangeActiveTextEditor be emitted with empty document when you open Settings editor.
  2. Then Event onDidChangeTextDocument be emitted even if you has not edited anything in setting document.
  3. So in this situation, onFileCoding function be invoked with global variable activeDocument is null. So get this exception: TypeError: Cannot set property 'lineCount' of null.