aboutsummaryrefslogtreecommitdiff
path: root/Scripts
diff options
context:
space:
mode:
authorDavid Czihak <git@dcz.at>2026-05-09 01:56:30 +0200
committerDavid Czihak <git@dcz.at>2026-05-09 01:56:30 +0200
commit64e9c56fc665972fdde5234c4fb2f2a882e237dc (patch)
tree18ec6e7d163b8b9991436995fe7584e910c4aea9 /Scripts
parent4c3e7ea293b2e5a4929781e1b97a2f6affff6576 (diff)
Fix: A few small reliability tweaks
- An error no longer aborts the rest of the cleanup on deactivate. - Project name detection now ignores commented-out `.name` lines in build.zig.zon. - Failed step discovery now leaves a note in the log instead of failing silently. - The clean task now uses the same command builder as everything else.
Diffstat (limited to 'Scripts')
-rw-r--r--Scripts/main.js45
1 files changed, 37 insertions, 8 deletions
diff --git a/Scripts/main.js b/Scripts/main.js
index 24f8cde..60fd4aa 100644
--- a/Scripts/main.js
+++ b/Scripts/main.js
@@ -45,7 +45,11 @@ exports.deactivate = function deactivate() {
commandRegistrations.forEach((disposable) => {
if (disposable && typeof disposable.dispose === "function") {
- disposable.dispose();
+ try {
+ disposable.dispose();
+ } catch (error) {
+ console.error(`[${EXTENSION_ID}] Failed to dispose registration`, error);
+ }
}
});
commandRegistrations = [];
@@ -352,7 +356,10 @@ function parseProjectName(cwd) {
}
if (typeof content !== "string" || content.length === 0) return null;
- const match = content.match(/\.name\s*=\s*(?:"([^"]+)"|\.([A-Za-z_][\w]*))/);
+ const stripped = content.replace(/\/\/[^\n]*/g, "");
+ const match = stripped.match(
+ /\.name\s*=\s*(?:"([^"]+)"|\.([A-Za-z_][\w]*))/,
+ );
if (!match) return null;
return match[1] || match[2] || null;
}
@@ -395,9 +402,12 @@ function activeZigFileDirectory() {
// build.zig / build.zig.zon and a soft 5-minute TTL. `getOrFetch` returns
// cached steps synchronously and kicks off a background refresh when stale,
// nudging Nova to reload tasks once the refresh lands.
+const STEP_DISCOVERY_WARN_THROTTLE_MS = 5 * 60 * 1000;
+
const stepCache = {
entries: new Map(),
pending: new Map(),
+ lastWarnedAt: new Map(),
getOrFetch(cwd) {
if (!cwd) return null;
@@ -448,7 +458,17 @@ const stepCache = {
cwd,
timeoutMs: 60000,
});
- if (result.status !== 0) return null;
+ if (result.status !== 0) {
+ const last = this.lastWarnedAt.get(cwd) || 0;
+ if (Date.now() - last >= STEP_DISCOVERY_WARN_THROTTLE_MS) {
+ this.lastWarnedAt.set(cwd, Date.now());
+ const detail = (result.stderr || "").trim().slice(0, 500);
+ console.warn(
+ `[zig-task] Step discovery failed in ${cwd} (status ${result.status})${detail ? ": " + detail : ""}`,
+ );
+ }
+ return null;
+ }
const steps = result.stdout
.split("\n")
@@ -469,8 +489,10 @@ const stepCache = {
invalidate(cwd) {
if (cwd) {
this.entries.delete(cwd);
+ this.lastWarnedAt.delete(cwd);
} else {
this.entries.clear();
+ this.lastWarnedAt.clear();
}
},
};
@@ -906,7 +928,14 @@ class ZigLanguageServer {
this.stop();
this.disposables.forEach((disposable) => {
if (disposable && typeof disposable.dispose === "function") {
- disposable.dispose();
+ try {
+ disposable.dispose();
+ } catch (error) {
+ console.error(
+ `[${LANGUAGE_CLIENT_ID}] Failed to dispose subscription`,
+ error,
+ );
+ }
}
});
this.disposables = [];
@@ -1226,11 +1255,11 @@ class ZigTaskAssistant {
) {
const zigPath = await resolveZigExecutable();
if (zigPath) {
- const command = `${quoteShellArgument(zigPath)} build uninstall; /bin/rm ${args
- .map(quoteShellArgument)
- .join(" ")}`;
+ // `;` (not `&&`) is intentional: rm should run even if uninstall fails.
+ const uninstall = buildShellCommand(zigPath, ["build", "uninstall"]);
+ const remove = buildShellCommand("/bin/rm", args);
return new TaskProcessAction("/bin/zsh", {
- args: ["-lc", command],
+ args: ["-lc", `${uninstall}; ${remove}`],
cwd,
matchers: [ISSUE_MATCHER],
});