Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vscode-lean4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"lean4.envPathExtensions": {
"type": "array",
"default": [],
"markdownDescription": "Additional entries to add to the PATH variable of the Lean 4 VS Code extension process and any of its child processes.",
"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.",
"items": {
"type": "string",
"description": "Entry to add to the PATH variable"
Expand Down
17 changes: 16 additions & 1 deletion vscode-lean4/src/utils/pathExtensionProvider.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as nodePath from 'path'
import { Disposable, workspace } from 'vscode'
import { envPathExtensions } from '../config'
import { PATH, setProcessEnvPATH } from './envPath'
Expand All @@ -14,6 +15,9 @@ export class PathExtensionProvider implements Disposable {
this.replaceEnvPathExtensionsInPATH()
}
}),
workspace.onDidChangeWorkspaceFolders(_ => {
this.replaceEnvPathExtensionsInPATH()
}),
)
}

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

replaceEnvPathExtensionsInPATH() {
const previousPathExtensions = this.currentPathExtensions
this.currentPathExtensions = envPathExtensions()
const exts = envPathExtensions()
const resolvedPaths: string[] = []
for (const p of exts.paths) {
if (nodePath.isAbsolute(p)) {
resolvedPaths.push(p)
continue
}
for (const folder of workspace.workspaceFolders ?? []) {
resolvedPaths.push(nodePath.resolve(folder.uri.fsPath, p))
}
}
this.currentPathExtensions = new PATH(resolvedPaths)
const path = PATH.ofProcessEnv()
const originalPath = path.filter(path => !previousPathExtensions.includes(path))
setProcessEnvPATH(this.currentPathExtensions.join(originalPath))
Expand Down
Loading