From a8ea32a804aae9079726aed291358b0f083d1b80 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sat, 6 Feb 2021 09:44:54 +0100 Subject: [PATCH] Fix request failed when there's a white space in the project path. Fixes https://github.com/rescript-lang/rescript-vscode/issues/78 --- CHANGELOG.md | 4 ++++ server/src/RescriptEditorSupport.ts | 14 +++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e72bd02fd..19c1318d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## master + +- Fix request failed when there's a white space in the project path. + ## 1.0.5 Features: diff --git a/server/src/RescriptEditorSupport.ts b/server/src/RescriptEditorSupport.ts index 1c3b80e25..d4d36f58a 100644 --- a/server/src/RescriptEditorSupport.ts +++ b/server/src/RescriptEditorSupport.ts @@ -19,7 +19,11 @@ let findExecutable = (uri: string) => { if (projectRootPath == null || !binaryExists) { return null; } else { - return { binaryPath, filePath, cwd: projectRootPath }; + return { + binaryPathQuoted: '"' + binaryPath + '"', // path could have white space + filePathQuoted: '"' + filePath + '"', + cwd: projectRootPath, + }; } }; @@ -34,9 +38,9 @@ export function runDumpCommand( onResult(null); } else { let command = - executable.binaryPath + + executable.binaryPathQuoted + " dump " + - executable.filePath + + executable.filePathQuoted + ":" + msg.params.position.line + ":" + @@ -65,9 +69,9 @@ export function runCompletionCommand( fs.writeFileSync(tmpname, code, { encoding: "utf-8" }); let command = - executable.binaryPath + + executable.binaryPathQuoted + " complete " + - executable.filePath + + executable.filePathQuoted + ":" + msg.params.position.line + ":" +