@@ -366,18 +366,18 @@ void MaybeEmphasize(int i, string currColor)
366366 /// </returns>
367367 private bool RenderErrorPrompt ( RenderData renderData , string defaultColor )
368368 {
369- // We may need to flip the color on the prompt if the error state changed.
370-
371- int bufferWidth = _console . BufferWidth ;
372- string promptText = _options . PromptText ;
373-
374- if ( string . IsNullOrEmpty ( promptText ) || _initialY < 0 )
369+ if ( _initialY < 0
370+ || _options . PromptText == null
371+ || _options . PromptText . Length == 0
372+ || String . IsNullOrEmpty ( _options . PromptText [ 0 ] ) )
375373 {
376374 // No need to flip the prompt color if either the error prompt is not defined
377375 // or the initial cursor point has already been scrolled off the buffer.
378376 return false ;
379377 }
380378
379+ // We may need to flip the color on the prompt if the error state changed.
380+
381381 renderData . errorPrompt = ( _parseErrors != null && _parseErrors . Length > 0 ) ;
382382 if ( renderData . errorPrompt == _previousRender . errorPrompt )
383383 {
@@ -388,9 +388,15 @@ private bool RenderErrorPrompt(RenderData renderData, string defaultColor)
388388 // We need to update the prompt
389389 _console . SetCursorPosition ( _initialX , _initialY ) ;
390390
391+ string promptText =
392+ ( renderData . errorPrompt && _options . PromptText . Length == 2 )
393+ ? _options . PromptText [ 1 ]
394+ : _options . PromptText [ 0 ] ;
395+
391396 // promptBufferCells is the number of visible characters in the prompt
392397 int promptBufferCells = LengthInBufferCells ( promptText ) ;
393398 bool renderErrorPrompt = false ;
399+ int bufferWidth = _console . BufferWidth ;
394400
395401 if ( _console . CursorLeft >= promptBufferCells )
396402 {
@@ -421,12 +427,15 @@ private bool RenderErrorPrompt(RenderData renderData, string defaultColor)
421427
422428 if ( renderErrorPrompt )
423429 {
424- string color = renderData . errorPrompt ? _options . _errorColor : defaultColor ;
425- if ( renderData . errorPrompt && promptBufferCells != promptText . Length )
430+ if ( ! promptText . Contains ( '\x1b ' ) )
426431 {
427- promptText = promptText . Substring ( promptText . Length - promptBufferCells ) ;
432+ string color = renderData . errorPrompt ? _options . _errorColor : defaultColor ;
433+ if ( renderData . errorPrompt && promptBufferCells != promptText . Length )
434+ {
435+ promptText = promptText . Substring ( promptText . Length - promptBufferCells ) ;
436+ }
437+ _console . Write ( color ) ;
428438 }
429- _console . Write ( color ) ;
430439 _console . Write ( promptText ) ;
431440 _console . Write ( "\x1b [0m" ) ;
432441 }
0 commit comments