Start stop run timer

This commit is contained in:
2026-02-08 01:58:21 +01:00
parent 58f86e634b
commit e8df455611
3 changed files with 45 additions and 8 deletions
+32
View File
@@ -0,0 +1,32 @@
import * as vscode from "vscode";
export var currentRun: NodeJS.Timeout | null = null;
export async function stopRun() {
if (currentRun) clearTimeout(currentRun);
}
export async function startRun(
statusBarItem: vscode.StatusBarItem,
problemId: string,
) {
const mode = await vscode.window.showQuickPick(["any%", "100%"], {
placeHolder: "Select a mode",
canPickMany: false,
});
let start = Date.now();
currentRun = setInterval(() => {
const elapsed = Date.now() - start;
const minutes = Math.floor(elapsed / 60000);
const seconds = Math.floor((elapsed % 60000) / 1000);
const hundredths = Math.floor((elapsed % 1000) / 10);
statusBarItem.text = `$(clock) ${minutes}:${seconds.toString().padStart(2, "0")}.${hundredths
.toString()
.padStart(2, "0")}`;
}, 50);
}