File tree 1 file changed +6
-11
lines changed
src/System.Management.Automation/engine/Modules
1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -136,17 +136,12 @@ protected internal struct ImportModuleOptions
136
136
137
137
internal SessionState TargetSessionState
138
138
{
139
- get
140
- {
141
- if ( BaseGlobal )
142
- {
143
- return this . Context . TopLevelSessionState . PublicSessionState ;
144
- }
145
- else
146
- {
147
- return this . Context . SessionState ;
148
- }
149
- }
139
+ // Module loading could happen during tab completion triggered by PSReadLine,
140
+ // but that doesn't mean the module should be loaded targeting the PSReadLine
141
+ // module's session state. In that case, use Global session state instead.
142
+ get => BaseGlobal || Context . EngineSessionState . Module ? . Name is "PSReadLine"
143
+ ? Context . TopLevelSessionState . PublicSessionState
144
+ : Context . SessionState ;
150
145
}
151
146
152
147
/// <summary>
You can’t perform that action at this time.
0 commit comments