diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-12-12 13:45:08 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-12-12 13:45:08 +0000 |
| commit | bd80cf0404b89b531312ac86e7868f8fd18052d5 (patch) | |
| tree | 4f3898dca87e362ef5451195483ddddb534a7331 /src/display_buffer.cc | |
| parent | 277b02eee6cb0037d2ecce46d1f2a455dfb0b001 (diff) | |
Add DisplayAtom::check_invariant method
Diffstat (limited to 'src/display_buffer.cc')
| -rw-r--r-- | src/display_buffer.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/display_buffer.cc b/src/display_buffer.cc index 89f2c74b..abd77cc2 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -12,6 +12,7 @@ void DisplayAtom::trim_begin(CharCount count) m_buffer->iterator_at(m_end), count).coord(); else m_text = m_text.substr(count); + check_invariant(); } void DisplayAtom::trim_end(CharCount count) @@ -21,6 +22,18 @@ void DisplayAtom::trim_end(CharCount count) m_buffer->iterator_at(m_begin), -count).coord(); else m_text = m_text.substr(0, m_text.char_length() - count); + check_invariant(); +} + +void DisplayAtom::check_invariant() const +{ +#ifdef KAK_DEBUG + if (has_buffer_range()) + { + kak_assert(m_buffer->is_valid(m_begin)); + kak_assert(m_buffer->is_valid(m_end)); + } +#endif } DisplayLine::DisplayLine(AtomList atoms) @@ -38,6 +51,8 @@ DisplayLine::iterator DisplayLine::split(iterator it, BufferCoord pos) DisplayAtom atom = *it; atom.m_end = pos; it->m_begin = pos; + atom.check_invariant(); + it->check_invariant(); return m_atoms.insert(it, std::move(atom)); } @@ -105,6 +120,7 @@ void DisplayLine::optimize() next_atom_it = m_atoms.erase(next_atom_it); else atom_it = next_atom_it++; + atom_it->check_invariant(); } } |
