Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions PSReadLine/Render.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,22 @@ void UpdateColorsIfNecessary(string newColor)
PlaceCursor(_initialX, _initialY);

// Possibly need to flip the color on the prompt if the error state changed.
if (!string.IsNullOrEmpty(_options.PromptText))
var promptText = _options.PromptText;
if (!string.IsNullOrEmpty(promptText))
{
renderData.errorPrompt = (_parseErrors != null && _parseErrors.Length > 0);
if (renderData.errorPrompt != _previousRender.errorPrompt)
{
// We need to update the prompt
_console.CursorLeft -= _options.PromptText.Length;
UpdateColorsIfNecessary(renderData.errorPrompt ? _options._errorColor : defaultColor);
_console.Write(_options.PromptText);

// promptBufferCells is the number of visible characters in the prompt
var promptBufferCells = LengthInBufferCells(promptText);
_console.CursorLeft -= promptBufferCells;
var color = renderData.errorPrompt ? _options._errorColor : defaultColor;
if (renderData.errorPrompt && promptBufferCells != promptText.Length)
promptText = promptText.Substring(promptText.Length - promptBufferCells);
UpdateColorsIfNecessary(color);
_console.Write(promptText);
_console.Write("\x1b[0m");
}
}
Expand Down