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()
218218 bool runPipelineForEventProcessing = false ;
219219 foreach ( var sub in eventSubscribers )
220220 {
221- runPipelineForEventProcessing = true ;
222221 if ( sub . SourceIdentifier . Equals ( PSEngineEvent . OnIdle , StringComparison . OrdinalIgnoreCase ) )
223222 {
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 ;
228233 _singleton . _engineIntrinsics . Events . GenerateEvent ( PSEngineEvent . OnIdle , null , null , null ) ;
229234
230235 // Break out so we don't genreate more than one 'OnIdle' event for a timeout.
231236 break ;
232237 }
238+
239+ runPipelineForEventProcessing = true ;
233240 }
234241
235242 // If there are any event subscribers, run a tiny useless PowerShell pipeline
You can’t perform that action at this time.
0 commit comments