Fixed: account for full-width characters in error-line preview.
This commit is contained in:
parent
6a85f0b8b0
commit
dfde9c2b20
1 changed files with 15 additions and 3 deletions
|
@ -149,10 +149,18 @@ namespace arookas
|
|||
sb.AppendLine(preview);
|
||||
for (var column = 1; column < location.Column; ++column)
|
||||
{
|
||||
switch (preview[column - 1])
|
||||
var c = preview[column - 1];
|
||||
if (IsFullWidth(c))
|
||||
{
|
||||
case '\t': sb.Append('\t'); break;
|
||||
default: sb.Append(" "); break;
|
||||
sb.Append(" "); // full-width hack
|
||||
}
|
||||
else if (c == '\t')
|
||||
{
|
||||
sb.Append('\t');
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(" ");
|
||||
}
|
||||
}
|
||||
sb.Append("^");
|
||||
|
@ -160,6 +168,10 @@ namespace arookas
|
|||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
static bool IsFullWidth(char c)
|
||||
{
|
||||
return (c >= 0x2E80 && c <= 0x9FFF) || (c >= 0xFF00 && c <= 0xFFEF);
|
||||
}
|
||||
|
||||
static void Message(string format, params object[] args) { Console.Write(format, args); }
|
||||
static void Warning(string format, params object[] args)
|
||||
|
|
Loading…
Reference in a new issue