Skip to content

Commit

Permalink
ignore existing zig installation when modifying $PATH env variable
Browse files Browse the repository at this point in the history
This means that the version in the status bar is always the same as in
the terminal.
  • Loading branch information
Techatrix committed Jan 23, 2025
1 parent 222965e commit 27789ea
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/zigSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,9 @@ function updateLanguageStatusItem(item: vscode.LanguageStatusItem, version: semv

function updateZigEnvironmentVariableCollection(context: vscode.ExtensionContext, zigExePath: string | null) {
if (zigExePath) {
const envValue = path.delimiter + path.dirname(zigExePath);
// Calling `append` means that zig from a user-defined PATH value will take precedence.
// The added value may have already been added by the user but since we
// append, it doesn't have any observable.
context.environmentVariableCollection.append("PATH", envValue);
const envValue = path.dirname(zigExePath) + path.delimiter;
// This will take priority over a user-defined PATH values.
context.environmentVariableCollection.prepend("PATH", envValue);
} else {
context.environmentVariableCollection.delete("PATH");
}
Expand Down

0 comments on commit 27789ea

Please sign in to comment.