Skip to content

Commit

Permalink
wrap paths containing terminal unsafe characters in quotes
Browse files Browse the repository at this point in the history
Closes #258
  • Loading branch information
Vexu committed Dec 14, 2024
1 parent 5363c27 commit b17d9c9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/zigMainCodeLens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,17 @@ function zigRun() {
terminal.show();
const wsFolder = getWorkspaceFolder(filePath);
if (wsFolder && isWorkspaceFile(filePath) && hasBuildFile(wsFolder.uri.fsPath)) {
terminal.sendText(`${zigPath} build run`);
terminal.sendText(`${escapePath(zigPath)} build run`);
return;
}
terminal.sendText(`${zigPath} run "${filePath}"`);
terminal.sendText(`${escapePath(zigPath)} run ${escapePath(filePath)}`);
}

function escapePath(rawPath: string): string {
if (/[ !"#$&'()*,;:<>?\[\\\]^`{|}]/.test(rawPath)) {
return `"${rawPath.replaceAll("\"", "\"\\\"\"")}"`;
}
return rawPath;
}

function hasBuildFile(workspaceFspath: string): boolean {
Expand Down

0 comments on commit b17d9c9

Please sign in to comment.