Detect errors while parsing flag line and handle them

Fixes #1345
This commit is contained in:
Maxime Coste 2017-05-01 22:05:03 +01:00
parent 053544d740
commit 55631c8d8e

View File

@ -475,7 +475,7 @@ HighlighterAndId create_dynamic_regex_highlighter(HighlighterParameters params)
} }
catch (runtime_error& err) catch (runtime_error& err)
{ {
write_to_debug_buffer(format("Error while evaluating dynamic regex expression", err.what())); write_to_debug_buffer(format("Error while evaluating dynamic regex expression: {}", err.what()));
return Regex{}; return Regex{};
} }
}; };
@ -1144,12 +1144,20 @@ struct FlagLinesHighlighter : Highlighter
auto def_face = get_face(m_default_face); auto def_face = get_face(m_default_face);
Vector<DisplayLine> display_lines; Vector<DisplayLine> display_lines;
auto& lines = line_flags.list; auto& lines = line_flags.list;
try
{
for (auto& line : lines) for (auto& line : lines)
{ {
display_lines.push_back(parse_display_line(std::get<1>(line))); display_lines.push_back(parse_display_line(std::get<1>(line)));
for (auto& atom : display_lines.back()) for (auto& atom : display_lines.back())
atom.face = merge_faces(def_face, atom.face); atom.face = merge_faces(def_face, atom.face);
} }
}
catch (runtime_error& err)
{
write_to_debug_buffer(format("Error while evaluating line flag: {}", err.what()));
return;
}
ColumnCount width = 0; ColumnCount width = 0;
for (auto& l : display_lines) for (auto& l : display_lines)
@ -1188,8 +1196,16 @@ struct FlagLinesHighlighter : Highlighter
update_line_flags_ifn(buffer, line_flags); update_line_flags_ifn(buffer, line_flags);
ColumnCount width = 0; ColumnCount width = 0;
try
{
for (auto& line : line_flags.list) for (auto& line : line_flags.list)
width = std::max(parse_display_line(std::get<1>(line)).length(), width); width = std::max(parse_display_line(std::get<1>(line)).length(), width);
}
catch (runtime_error& err)
{
write_to_debug_buffer(format("Error while evaluating line flag: {}", err.what()));
return;
}
setup.window_range.column -= width; setup.window_range.column -= width;
} }