From f6db6c41e6f7b205fc37929423575e6866d4d70f Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 26 Oct 2022 19:48:26 +0200 Subject: [PATCH] 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. --- src/reader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reader.cpp b/src/reader.cpp index 36b5aa452..c50426ff8 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -211,7 +211,7 @@ void apply_edit(wcstring *target, std::vector *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); }