reader: clarify bounds check when probing for cached highlighting

When we insert characters that don't yet have highlighting, we use the
highlighting to the left, unless there is nothing to our left.  The logic to
check if we are the leftmost character uses an overly loose comparison. Let's
make it more specific.
No functional change.
This commit is contained in:
Johannes Altmanninger 2022-10-26 19:48:26 +02:00
parent 0b6eab4ec3
commit f6db6c41e6

View File

@ -211,7 +211,7 @@ void apply_edit(wcstring *target, std::vector<highlight_spec_t> *colors, const e
// Now do the same to highlighting.
auto it = colors->begin() + offset;
colors->erase(it, it + edit.length);
highlight_spec_t last_color = offset < 1 ? highlight_spec_t{} : colors->at(offset - 1);
highlight_spec_t last_color = offset == 0 ? highlight_spec_t{} : colors->at(offset - 1);
colors->insert(it, edit.replacement.size(), last_color);
}