@@ -2,7 +2,7 @@ import { fileURLToPath } from "url";
2
2
import { RequestMessage } from "vscode-languageserver" ;
3
3
import * as utils from "./utils" ;
4
4
import * as path from "path" ;
5
- import { execSync } from "child_process" ;
5
+ import { execFileSync } from "child_process" ;
6
6
import fs from "fs" ;
7
7
8
8
let binaryPath = path . join (
@@ -20,8 +20,8 @@ let findExecutable = (uri: string) => {
20
20
return null ;
21
21
} else {
22
22
return {
23
- binaryPathQuoted : '"' + binaryPath + '"' , // path could have white space
24
- filePathQuoted : '"' + filePath + '"' ,
23
+ binaryPath : binaryPath ,
24
+ filePath : filePath ,
25
25
cwd : projectRootPath ,
26
26
} ;
27
27
}
@@ -38,16 +38,16 @@ export function runDumpCommand(msg: RequestMessage): dumpCommandResult | null {
38
38
}
39
39
40
40
let command =
41
- executable . binaryPathQuoted +
42
- " dump " +
43
- executable . filePathQuoted +
41
+ executable . filePath +
44
42
":" +
45
43
msg . params . position . line +
46
44
":" +
47
45
msg . params . position . character ;
48
46
49
47
try {
50
- let stdout = execSync ( command , { cwd : executable . cwd } ) ;
48
+ let stdout = execFileSync ( executable . binaryPath , [ "dump" , command ] , {
49
+ cwd : executable . cwd ,
50
+ } ) ;
51
51
let parsed = JSON . parse ( stdout . toString ( ) ) ;
52
52
if ( parsed && parsed [ 0 ] ) {
53
53
return parsed [ 0 ] ;
@@ -73,18 +73,18 @@ export function runCompletionCommand(
73
73
fs . writeFileSync ( tmpname , code , { encoding : "utf-8" } ) ;
74
74
75
75
let command =
76
- executable . binaryPathQuoted +
77
- " complete " +
78
- executable . filePathQuoted +
76
+ executable . filePath +
79
77
":" +
80
78
msg . params . position . line +
81
79
":" +
82
- msg . params . position . character +
83
- " " +
84
- tmpname ;
80
+ msg . params . position . character ;
85
81
86
82
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
+ ) ;
88
88
let parsed = JSON . parse ( stdout . toString ( ) ) ;
89
89
if ( parsed && parsed [ 0 ] ) {
90
90
return parsed ;
0 commit comments