diff --git a/server/src/RescriptEditorSupport.ts b/server/src/RescriptEditorSupport.ts index cdc559e8f..bf5d2d654 100644 --- a/server/src/RescriptEditorSupport.ts +++ b/server/src/RescriptEditorSupport.ts @@ -2,7 +2,7 @@ import { fileURLToPath } from "url"; import { RequestMessage } from "vscode-languageserver"; import * as utils from "./utils"; import * as path from "path"; -import { execSync } from "child_process"; +import { execFileSync } from "child_process"; import fs from "fs"; let binaryPath = path.join( @@ -20,8 +20,8 @@ let findExecutable = (uri: string) => { return null; } else { return { - binaryPathQuoted: '"' + binaryPath + '"', // path could have white space - filePathQuoted: '"' + filePath + '"', + binaryPath: binaryPath, + filePath: filePath, cwd: projectRootPath, }; } @@ -38,16 +38,16 @@ export function runDumpCommand(msg: RequestMessage): dumpCommandResult | null { } let command = - executable.binaryPathQuoted + - " dump " + - executable.filePathQuoted + + executable.filePath + ":" + msg.params.position.line + ":" + msg.params.position.character; try { - let stdout = execSync(command, { cwd: executable.cwd }); + let stdout = execFileSync(executable.binaryPath, ["dump", command], { + cwd: executable.cwd, + }); let parsed = JSON.parse(stdout.toString()); if (parsed && parsed[0]) { return parsed[0]; @@ -73,18 +73,18 @@ export function runCompletionCommand( fs.writeFileSync(tmpname, code, { encoding: "utf-8" }); let command = - executable.binaryPathQuoted + - " complete " + - executable.filePathQuoted + + executable.filePath + ":" + msg.params.position.line + ":" + - msg.params.position.character + - " " + - tmpname; + msg.params.position.character; try { - let stdout = execSync(command, { cwd: executable.cwd }); + let stdout = execFileSync( + executable.binaryPath, + ["complete", command, tmpname], + { cwd: executable.cwd } + ); let parsed = JSON.parse(stdout.toString()); if (parsed && parsed[0]) { return parsed;