@@ -2,7 +2,7 @@ import { fileURLToPath } from "url";
22import { RequestMessage } from "vscode-languageserver" ;
33import * as utils from "./utils" ;
44import * as path from "path" ;
5- import { execSync } from "child_process" ;
5+ import { execFileSync } from "child_process" ;
66import fs from "fs" ;
77
88let binaryPath = path . join (
@@ -20,8 +20,8 @@ let findExecutable = (uri: string) => {
2020 return null ;
2121 } else {
2222 return {
23- binaryPathQuoted : '"' + binaryPath + '"' , // path could have white space
24- filePathQuoted : '"' + filePath + '"' ,
23+ binaryPath : binaryPath ,
24+ filePath : filePath ,
2525 cwd : projectRootPath ,
2626 } ;
2727 }
@@ -38,16 +38,16 @@ export function runDumpCommand(msg: RequestMessage): dumpCommandResult | null {
3838 }
3939
4040 let command =
41- executable . binaryPathQuoted +
42- " dump " +
43- executable . filePathQuoted +
41+ executable . filePath +
4442 ":" +
4543 msg . params . position . line +
4644 ":" +
4745 msg . params . position . character ;
4846
4947 try {
50- let stdout = execSync ( command , { cwd : executable . cwd } ) ;
48+ let stdout = execFileSync ( executable . binaryPath , [ "dump" , command ] , {
49+ cwd : executable . cwd ,
50+ } ) ;
5151 let parsed = JSON . parse ( stdout . toString ( ) ) ;
5252 if ( parsed && parsed [ 0 ] ) {
5353 return parsed [ 0 ] ;
@@ -73,18 +73,18 @@ export function runCompletionCommand(
7373 fs . writeFileSync ( tmpname , code , { encoding : "utf-8" } ) ;
7474
7575 let command =
76- executable . binaryPathQuoted +
77- " complete " +
78- executable . filePathQuoted +
76+ executable . filePath +
7977 ":" +
8078 msg . params . position . line +
8179 ":" +
82- msg . params . position . character +
83- " " +
84- tmpname ;
80+ msg . params . position . character ;
8581
8682 try {
87- let stdout = execSync ( command , { cwd : executable . cwd } ) ;
83+ let stdout = execFileSync (
84+ executable . binaryPath ,
85+ [ "complete" , command , tmpname ] ,
86+ { cwd : executable . cwd }
87+ ) ;
8888 let parsed = JSON . parse ( stdout . toString ( ) ) ;
8989 if ( parsed && parsed [ 0 ] ) {
9090 return parsed ;
0 commit comments