summaryrefslogtreecommitdiff
path: root/src/display_buffer.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-10-12 14:38:19 +0800
committerMaxime Coste <mawww@kakoune.org>2017-10-12 14:46:15 +0800
commit89f016d871c9ccc516e244e8bc594defe3678daf (patch)
tree6de4767371edb0c424d0e5e8102c4c9b4f81b15c /src/display_buffer.cc
parent446085d32b8a7562fd35a9fb7105874343d8715e (diff)
Refactor column highlighter to make it more robust
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
Diffstat (limited to 'src/display_buffer.cc')
-rw-r--r--src/display_buffer.cc21
1 files changed, 14 insertions, 7 deletions
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)