Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions server/src/RescriptEditorSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
};
}
Expand All @@ -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];
Expand All @@ -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;
Expand Down