diff options
| author | hss <hristo.staykov@gmail.com> | 2021-03-20 02:48:33 -0400 |
|---|---|---|
| committer | hss <hristo.staykov@gmail.com> | 2021-03-20 02:48:33 -0400 |
| commit | 8df2bb8bd574ead9ff9a0e8ba610c1a2a044d027 (patch) | |
| tree | 836e6337ed9ace6b84a7ad41311daf485587f1a9 /src | |
| parent | f16783b0a8f211fad608bd0072b7c48307ee0bb0 (diff) | |
Use optionals more wisely in line-numbers
Diffstat (limited to 'src')
| -rw-r--r-- | src/highlighters.cc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc index 6309b0b7..45008d6a 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -1107,14 +1107,13 @@ struct LineNumbersHighlighter : Highlighter throw runtime_error("separator length is limited to 10 bytes"); Optional<StringView> separator_cursor = parser.get_switch("separator-cursor"); - if (separator_cursor.value_or(separator).length() != separator.length()) { + if (separator_cursor && (*separator_cursor).length() != separator.length()) { // Throw runtime error instead? - write_to_debug_buffer("line-numbers: Separator for active line should have the same length as seperator"); + write_to_debug_buffer("number-lines: Separator for active line should have the same length as `separator`"); separator_cursor.reset(); } - // Effectively separator_cursor?.str(), except idk how to code in C++ - Optional<String> separator_cursor_str = separator_cursor ? separator_cursor->str() : Optional<String>{}; + auto separator_cursor_str = separator_cursor.map([](auto&& t){ return t.str(); }); int min_digits = parser.get_switch("min-digits").map(str_to_int).value_or(2); if (min_digits < 0) |
