Merge pull request #3465 from dodexahedron/v2_3464_dont_alter_ps_prompt

Fixes #3464 - dont alter ps prompt on module import or remove
This commit is contained in:
Tig
2024-05-09 12:16:36 -06:00
committed by GitHub

View File

@@ -73,12 +73,6 @@ Function Set-PowerShellEnvironment {
New-Variable -Name InternalAnalyzersProjectDirectory -Value (Join-Path -Resolve $AnalyzersDirectory "Terminal.Gui.Analyzers.Internal") -Option ReadOnly -Scope Global -Visibility Public
New-Variable -Name InternalAnalyzersProjectFilePath -Value (Join-Path -Resolve $InternalAnalyzersProjectDirectory "Terminal.Gui.Analyzers.Internal.csproj") -Option ReadOnly -Scope Global -Visibility Public
# Set a custom prompt to indicate we're in our modified environment.
# Save the normal one first, though.
# And save it as ReadOnly and without the -Force parameter, so this will be skipped if run more than once in the same session without a reset.
New-Variable -Name NormalPrompt -Option ReadOnly -Scope Global -Value (Get-Item Function:prompt).ScriptBlock -ErrorAction SilentlyContinue
Set-Item Function:prompt { "TGPS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "; }
# Save existing PSModulePath for optional reset later.
# If it is already saved, do not overwrite, but continue anyway.
New-Variable -Name OriginalPSModulePath -Visibility Public -Option ReadOnly -Scope Global -Value ($Env:PSModulePath) -ErrorAction SilentlyContinue
@@ -132,11 +126,6 @@ Function Reset-PowerShellEnvironment {
[Environment]::Exit(0)
}
if(Get-Variable -Name NormalPrompt -Scope Global -ErrorAction SilentlyContinue){
Set-Item Function:prompt $NormalPrompt
Remove-Variable -Name NormalPrompt -Scope Global -Force -ErrorAction SilentlyContinue
}
if(Get-Variable -Name OriginalPSModulePath -Scope Global -ErrorAction SilentlyContinue){
$Env:PSModulePath = $OriginalPSModulePath
Remove-Variable -Name OriginalPSModulePath -Scope Global -Force -ErrorAction SilentlyContinue