From 2d9b4992eccedd19cf6d7e4f84338511c3a87e5e Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Sun, 21 Apr 2019 16:38:08 +0900 Subject: [PATCH] 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. --- toml/region.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toml/region.hpp b/toml/region.hpp index 1720a7f..6ef6f9b 100644 --- a/toml/region.hpp +++ b/toml/region.hpp @@ -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 << ' ';