Skip to content

Commit ed1d98d

Browse files
TechatrixVexu
authored andcommitted
add a workaround for ziglang/zig#21905
1 parent c814837 commit ed1d98d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/zigSetup.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import vscode from "vscode";
22

3+
import fs from "fs/promises";
34
import path from "path";
45

56
import semver from "semver";
@@ -596,6 +597,33 @@ export async function setupZig(context: vscode.ExtensionContext) {
596597
await context.workspaceState.update("zig-version", undefined);
597598
}
598599

600+
/// Workaround https://github.com/ziglang/zig/issues/21905
601+
switch (process.platform) {
602+
case "darwin":
603+
case "freebsd":
604+
case "openbsd":
605+
case "netbsd":
606+
case "haiku":
607+
vscode.workspace.onDidSaveTextDocument(async (document) => {
608+
if (document.languageId !== "zig") return;
609+
if (document.uri.scheme !== "file") return;
610+
611+
const fsPath = document.uri.fsPath;
612+
try {
613+
await fs.copyFile(fsPath, fsPath + ".tmp", fs.constants.COPYFILE_EXCL);
614+
await fs.rename(fsPath + ".tmp", fsPath);
615+
} catch {}
616+
}, context.subscriptions);
617+
break;
618+
case "aix":
619+
case "android":
620+
case "linux":
621+
case "sunos":
622+
case "win32":
623+
case "cygwin":
624+
break;
625+
}
626+
599627
versionManagerConfig = {
600628
context: context,
601629
title: "Zig",

0 commit comments

Comments
 (0)