@@ -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,7 +20,7 @@ let findExecutable = (uri: string) => {
20
20
return null ;
21
21
} else {
22
22
return {
23
- binaryPathQuoted : '"' + binaryPath + '"' , // path could have white space
23
+ binaryPath : binaryPath ,
24
24
filePathQuoted : '"' + filePath + '"' ,
25
25
cwd : projectRootPath ,
26
26
} ;
@@ -38,16 +38,18 @@ export function runDumpCommand(msg: RequestMessage): dumpCommandResult | null {
38
38
}
39
39
40
40
let command =
41
- executable . binaryPathQuoted +
42
- " dump " +
43
41
executable . filePathQuoted +
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 (
49
+ executable . binaryPath ,
50
+ [ "dump" , command ] ,
51
+ { cwd : executable . cwd }
52
+ ) ;
51
53
let parsed = JSON . parse ( stdout . toString ( ) ) ;
52
54
if ( parsed && parsed [ 0 ] ) {
53
55
return parsed [ 0 ] ;
@@ -73,8 +75,6 @@ export function runCompletionCommand(
73
75
fs . writeFileSync ( tmpname , code , { encoding : "utf-8" } ) ;
74
76
75
77
let command =
76
- executable . binaryPathQuoted +
77
- " complete " +
78
78
executable . filePathQuoted +
79
79
":" +
80
80
msg . params . position . line +
@@ -84,7 +84,10 @@ export function runCompletionCommand(
84
84
tmpname ;
85
85
86
86
try {
87
- let stdout = execSync ( command , { cwd : executable . cwd } ) ;
87
+ let stdout = execFileSync (
88
+ executable . binaryPath ,
89
+ [ "complete" , command ] ,
90
+ { cwd : executable . cwd } ) ;
88
91
let parsed = JSON . parse ( stdout . toString ( ) ) ;
89
92
if ( parsed && parsed [ 0 ] ) {
90
93
return parsed ;
0 commit comments