Fixed: account for full-width characters in error-line preview.

This commit is contained in:
arookas 2015-12-13 00:55:05 -05:00
parent 6a85f0b8b0
commit dfde9c2b20

View file

@ -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)