summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-05-01 22:05:03 +0100
committerMaxime Coste <mawww@kakoune.org>2017-05-07 16:26:14 +0100
commit55631c8d8ef29f8c48d43410d487b6bfeb37c73b (patch)
treec3e5e49150550f81c8ada28c4dbf777663b0a449 /src
parent053544d740ba24d454b9f7c91254a7457c31876f (diff)
Detect errors while parsing flag line and handle them
Fixes #1345
Diffstat (limited to 'src')
-rw-r--r--src/highlighters.cc30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc
index 2d4c3e96..62e01d28 100644
--- a/src/highlighters.cc
+++ b/src/highlighters.cc
@@ -475,7 +475,7 @@ HighlighterAndId create_dynamic_regex_highlighter(HighlighterParameters params)
}
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{};
}
};
@@ -1144,11 +1144,19 @@ struct FlagLinesHighlighter : Highlighter
auto def_face = get_face(m_default_face);
Vector<DisplayLine> display_lines;
auto& lines = line_flags.list;
- for (auto& line : lines)
+ try
{
- display_lines.push_back(parse_display_line(std::get<1>(line)));
- for (auto& atom : display_lines.back())
- atom.face = merge_faces(def_face, atom.face);
+ for (auto& line : lines)
+ {
+ display_lines.push_back(parse_display_line(std::get<1>(line)));
+ for (auto& atom : display_lines.back())
+ 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;
@@ -1188,8 +1196,16 @@ struct FlagLinesHighlighter : Highlighter
update_line_flags_ifn(buffer, line_flags);
ColumnCount width = 0;
- for (auto& line : line_flags.list)
- width = std::max(parse_display_line(std::get<1>(line)).length(), width);
+ try
+ {
+ for (auto& line : line_flags.list)
+ 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;
}