Skip to content
Open
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
16 changes: 14 additions & 2 deletions PSReadLine/Render.Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ internal static int LengthInBufferCells(string str, int start, int end)
for (var i = start; i < end; i++)
{
var c = str[i];
if (c == 0x1b && (i+1) < end && str[i+1] == '[')
if (char.IsHighSurrogate(c) && (i + 1) < end && char.IsLowSurrogate(str[i + 1]))
{
sum++;
i++; // Skip the low surrogate
continue;
}
else if (c == 0x1b && (i + 1) < end && str[i + 1] == '[')
{
// Simple escape sequence skipping
i += 2;
Expand All @@ -77,7 +83,13 @@ internal static int LengthInBufferCells(StringBuilder sb, int start, int end)
for (var i = start; i < end; i++)
{
var c = sb[i];
if (c == 0x1b && (i + 1) < end && sb[i + 1] == '[')
if (char.IsHighSurrogate(c) && (i + 1) < end && char.IsLowSurrogate(sb[i + 1]))
{
sum++;
i++; // Skip the low surrogate
continue;
}
else if (c == 0x1b && (i + 1) < end && sb[i + 1] == '[')
{
// Simple escape sequence skipping
i += 2;
Expand Down