Skip to content

Commit 1c888e7

Browse files
committed
Add disposal check to logging methods in CopilotTokenTracker
1 parent 6c0486c commit 1c888e7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/extension.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ class CopilotTokenTracker implements vscode.Disposable {
726726
for (const r of results) { uniq[path.normalize(r.path)] = r; }
727727
return Object.values(uniq);
728728
}
729+
private _disposed = false;
729730
private updateInterval: NodeJS.Timeout | undefined;
730731
private initialDelayTimeout: NodeJS.Timeout | undefined;
731732
private detailsPanel: vscode.WebviewPanel | undefined;
@@ -1184,16 +1185,19 @@ class CopilotTokenTracker implements vscode.Disposable {
11841185

11851186
// Logging methods
11861187
public log(message: string): void {
1188+
if (this._disposed) { return; }
11871189
const timestamp = new Date().toLocaleTimeString();
11881190
this.outputChannel.appendLine(`[${timestamp}] ${message}`);
11891191
}
11901192

11911193
private warn(message: string): void {
1194+
if (this._disposed) { return; }
11921195
const timestamp = new Date().toLocaleTimeString();
11931196
this.outputChannel.appendLine(`[${timestamp}] WARNING: ${message}`);
11941197
}
11951198

11961199
private error(message: string, error?: any): void {
1200+
if (this._disposed) { return; }
11971201
const timestamp = new Date().toLocaleTimeString();
11981202
this.outputChannel.appendLine(`[${timestamp}] ERROR: ${message}`);
11991203
if (error) {
@@ -11047,6 +11051,7 @@ ${hashtag}`;
1104711051
this.diagnosticsPanel.dispose();
1104811052
}
1104911053
this.statusBarItem.dispose();
11054+
this._disposed = true;
1105011055
this.outputChannel.dispose();
1105111056
}
1105211057
}

0 commit comments

Comments
 (0)