File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -218,18 +218,25 @@ internal static PSKeyInfo ReadKey()
218
218
bool runPipelineForEventProcessing = false ;
219
219
foreach ( var sub in eventSubscribers )
220
220
{
221
- runPipelineForEventProcessing = true ;
222
221
if ( sub . SourceIdentifier . Equals ( PSEngineEvent . OnIdle , StringComparison . OrdinalIgnoreCase ) )
223
222
{
224
- // There is an OnIdle event. We're idle because we timed out. Normally
225
- // PowerShell generates this event, but PowerShell assumes the engine is not
226
- // idle because it called PSConsoleHostReadLine which isn't returning.
227
- // So we generate the event instead.
223
+ // If the buffer is not empty, let's not consider we are idle because the user is in the middle of typing something.
224
+ if ( _singleton . _buffer . Length > 0 )
225
+ {
226
+ continue ;
227
+ }
228
+
229
+ // There is an OnIdle event subscriber and we are idle because we timed out and the buffer is empty.
230
+ // Normally PowerShell generates this event, but PowerShell assumes the engine is not idle because
231
+ // it called PSConsoleHostReadLine which isn't returning. So we generate the event instead.
232
+ runPipelineForEventProcessing = true ;
228
233
_singleton . _engineIntrinsics . Events . GenerateEvent ( PSEngineEvent . OnIdle , null , null , null ) ;
229
234
230
235
// Break out so we don't genreate more than one 'OnIdle' event for a timeout.
231
236
break ;
232
237
}
238
+
239
+ runPipelineForEventProcessing = true ;
233
240
}
234
241
235
242
// If there are any event subscribers, run a tiny useless PowerShell pipeline
You can’t perform that action at this time.
0 commit comments