Skip to content

Commit bb183cf

Browse files
Andreas Buhrtzlaine
authored andcommitted
Improve error visualization.
If the parsed string contains tab characters on the failing line, the underlining in the error message pointed to the wrong position. This patch adds as many tab characters to the underlining as there are in the parsed line. So the underlining points to the correct position.
1 parent 885595f commit bb183cf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/boost/parser/error_handling.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ namespace boost { namespace parser {
9090
os << ":\n";
9191

9292
std::string underlining(std::distance(position.line_start, it), ' ');
93+
std::transform(position.line_start, it,
94+
underlining.begin(),
95+
[](auto c) { return c == '\t' ? '\t' : ' ';});
9396
detail::trace_input(os, position.line_start, it, false, 1u << 31);
9497
if (it == last) {
9598
os << '\n' << underlining << "^\n";

0 commit comments

Comments
 (0)