From e63156bcfb58d20465f1795ada4b9309d2793505 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 7 May 2017 14:02:31 +0100 Subject: [PATCH] Fix infinite loop with longer than width words in word wrap mode --- src/highlighters.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/highlighters.cc b/src/highlighters.cc index 0b624e30..2a0d458a 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -792,11 +792,12 @@ struct WrapHighlighter : Highlighter if (m_word_wrap) { StringView line = buffer[coord.line]; - utf8::iterator it{line.data() + (size_t)col, line}; + utf8::iterator it{&line[col], line}; while (it != line.end() and it != line.begin() and is_word(*it)) --it; - if (it != line.begin() and it != line.data() + (size_t)col) + if (it != line.begin() and it != &line[col] and + (it+1) > &line[coord.column]) split_coord.column = (it+1).base() - line.begin(); } return split_coord;