mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Never load a module targeting the PSReadLine module's SessionState (#24909)
This commit is contained in:
@@ -136,17 +136,12 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
internal SessionState TargetSessionState
|
||||
{
|
||||
get
|
||||
{
|
||||
if (BaseGlobal)
|
||||
{
|
||||
return this.Context.TopLevelSessionState.PublicSessionState;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Context.SessionState;
|
||||
}
|
||||
}
|
||||
// Module loading could happen during tab completion triggered by PSReadLine,
|
||||
// but that doesn't mean the module should be loaded targeting the PSReadLine
|
||||
// module's session state. In that case, use Global session state instead.
|
||||
get => BaseGlobal || Context.EngineSessionState.Module?.Name is "PSReadLine"
|
||||
? Context.TopLevelSessionState.PublicSessionState
|
||||
: Context.SessionState;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user