Skip to content

Commit 30437c5

Browse files
fix: always start command inside workspace folder
1 parent 6fad78b commit 30437c5

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/extension/common.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ export function resolveBinary() {
4040
}
4141

4242
export async function testBinaryExist(command: string) {
43+
const uris = workspace.workspaceFolders?.map(i => i.uri?.fsPath) ?? []
4344
return new Promise(r => {
4445
execFile(
4546
command,
4647
['-h'],
4748
{
4849
// for windows
4950
shell: process.platform === 'win32',
51+
cwd: uris[0],
5052
},
5153
err => {
5254
r(!err)

src/extension/lsp.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const languageClientId = 'ast-grep-client'
1414
const languageClientName = 'ast-grep language client'
1515

1616
function getExecutable(isDebug: boolean): Executable {
17+
const uris = workspace.workspaceFolders?.map(i => i.uri?.fsPath) ?? []
1718
const command = resolveBinary()
1819
return {
1920
command,
@@ -25,6 +26,7 @@ function getExecutable(isDebug: boolean): Executable {
2526
},
2627
// shell is required for Windows cmd to pick up global npm binary
2728
shell: process.platform === 'win32',
29+
cwd: uris[0],
2830
},
2931
}
3032
}

0 commit comments

Comments
 (0)