Skip to content

Commit 9e9ab08

Browse files
authored
feat: relative paths in envPathExtensions setting (#739)
1 parent 132d329 commit 9e9ab08

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

vscode-lean4/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"lean4.envPathExtensions": {
7474
"type": "array",
7575
"default": [],
76-
"markdownDescription": "Additional entries to add to the PATH variable of the Lean 4 VS Code extension process and any of its child processes.",
76+
"markdownDescription": "Additional entries to add to the PATH variable of the Lean 4 VS Code extension process and any of its child processes. Relative paths are resolved against each workspace folder.",
7777
"items": {
7878
"type": "string",
7979
"description": "Entry to add to the PATH variable"

vscode-lean4/src/utils/pathExtensionProvider.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as nodePath from 'path'
12
import { Disposable, workspace } from 'vscode'
23
import { envPathExtensions } from '../config'
34
import { PATH, setProcessEnvPATH } from './envPath'
@@ -14,6 +15,9 @@ export class PathExtensionProvider implements Disposable {
1415
this.replaceEnvPathExtensionsInPATH()
1516
}
1617
}),
18+
workspace.onDidChangeWorkspaceFolders(_ => {
19+
this.replaceEnvPathExtensionsInPATH()
20+
}),
1721
)
1822
}
1923

@@ -23,7 +27,18 @@ export class PathExtensionProvider implements Disposable {
2327

2428
replaceEnvPathExtensionsInPATH() {
2529
const previousPathExtensions = this.currentPathExtensions
26-
this.currentPathExtensions = envPathExtensions()
30+
const exts = envPathExtensions()
31+
const resolvedPaths: string[] = []
32+
for (const p of exts.paths) {
33+
if (nodePath.isAbsolute(p)) {
34+
resolvedPaths.push(p)
35+
continue
36+
}
37+
for (const folder of workspace.workspaceFolders ?? []) {
38+
resolvedPaths.push(nodePath.resolve(folder.uri.fsPath, p))
39+
}
40+
}
41+
this.currentPathExtensions = new PATH(resolvedPaths)
2742
const path = PATH.ofProcessEnv()
2843
const originalPath = path.filter(path => !previousPathExtensions.includes(path))
2944
setProcessEnvPATH(this.currentPathExtensions.join(originalPath))

0 commit comments

Comments
 (0)