Skip to content

Commit 41300d8

Browse files
committed
Fix prompt error highlight characters
When deciding what character to color red for errors, we were using IsSymbol - that was a bit too restrictive so it was changed to be any non-whitespace and non-alphanumeric characters. Fixes #127
1 parent 2f2db97 commit 41300d8

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

PSReadLine/Render.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,22 @@ private void ReallyRender()
209209

210210
while (promptChar >= 0)
211211
{
212-
if (char.IsSymbol((char)_consoleBuffer[promptChar].UnicodeChar))
212+
var c = (char)_consoleBuffer[promptChar].UnicodeChar;
213+
if (char.IsWhiteSpace(c))
214+
{
215+
promptChar -= 1;
216+
continue;
217+
}
218+
219+
if (!char.IsLetterOrDigit(c))
213220
{
214221
ConsoleColor prevColor = _consoleBuffer[promptChar].ForegroundColor;
215222
_consoleBuffer[promptChar].ForegroundColor = ConsoleColor.Red;
216223
WriteBufferLines(_consoleBuffer, ref _initialY);
217224
rendered = true;
218225
_consoleBuffer[promptChar].ForegroundColor = prevColor;
219-
break;
220226
}
221-
promptChar -= 1;
227+
break;
222228
}
223229
}
224230

TestPSReadLine/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ static void Main()
119119
PSConsoleReadLine.SetKeyHandler(new[] {"Ctrl+D,Ctrl+X"}, CauseCrash, "", "");
120120
while (true)
121121
{
122-
//Console.Write("C:\\Windows\nPS> ");
123-
Console.Write("PS> ");
122+
Console.Write("PS# ");
124123

125124
var line = PSConsoleReadLine.ReadLine();
126125
Console.WriteLine(line);

0 commit comments

Comments
 (0)