fix: restrict length of underline by size of line

in some cases, `region` contains several lines and `region::size`
returns the whole size that is a sum of lengthes of all the lines.
To avoid too long underlines, restrict the length of underline by
the length of the line that is shown in the message.
This commit is contained in:
ToruNiina
2019-04-21 16:38:08 +09:00
parent 82e8c1e68b
commit 2d9b4992ec

View File

@@ -343,7 +343,8 @@ inline std::string format_underline(const std::string& message,
{
// invalid
// ~~~~~~~
retval << make_string(reg->size(), '~');
const auto underline_len = std::min(reg->size(), reg->line().size());
retval << make_string(underline_len, '~');
}
retval << ' ';