From 89f016d871c9ccc516e244e8bc594defe3678daf Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 12 Oct 2017 14:38:19 +0800 Subject: Refactor column highlighter to make it more robust MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support arbitrary orders for column highlighters (it was previously failing when column highlighters were not applied in column order). Fix show_matching tab handling at the same time (horizontal scrolling, tab characters and show_matching were behaving badly). Window highlighting now runs user highlighters, then built-ins for each phases, instead of running all phases for user highlighters, then all phases for built-ins. We now consider unprintable character to be 1-column width as we know we will display them as "�". Fixes #1615 Fixes #1023 --- src/display_buffer.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/display_buffer.cc') diff --git a/src/display_buffer.cc b/src/display_buffer.cc index e6ae2a34..3a1449d7 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -92,15 +92,22 @@ DisplayLine::iterator DisplayLine::split(iterator it, BufferCoord pos) return m_atoms.insert(it, std::move(atom)); } -DisplayLine::iterator DisplayLine::split(iterator it, ColumnCount pos) +DisplayLine::iterator DisplayLine::split(iterator it, ColumnCount count) { - kak_assert(it->type() == DisplayAtom::Text); - kak_assert(pos > 0); - kak_assert(pos < it->length()); + kak_assert(count > 0); + kak_assert(count < it->length()); - DisplayAtom atom(it->m_text.substr(0, pos).str()); - it->m_text = it->m_text.substr(pos).str(); - return m_atoms.insert(it, std::move(atom)); + if (it->type() == DisplayAtom::Text or it->type() == DisplayAtom::ReplacedRange) + { + DisplayAtom atom = *it; + atom.m_text = atom.m_text.substr(0, count).str(); + it->m_text = it->m_text.substr(count).str(); + return m_atoms.insert(it, std::move(atom)); + } + auto pos = utf8::advance(get_iterator(it->buffer(), it->begin()), + get_iterator(it->buffer(), it->end()), + count).coord(); + return split(it, pos); } DisplayLine::iterator DisplayLine::insert(iterator it, DisplayAtom atom) -- cgit v1.2.3