diff --git a/src/buffer.cc b/src/buffer.cc index c8ad73c0..cce72005 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -321,8 +321,6 @@ void Buffer::do_insert(const BufferIterator& pos, const String& content) end_it = BufferIterator{*this, { last_line, m_lines[last_line].length() - suffix.length() }}; } - check_invariant(); - for (auto listener : m_change_listeners) listener->on_insert(begin_it, end_it); } @@ -348,8 +346,6 @@ void Buffer::do_erase(const BufferIterator& begin, const BufferIterator& end) for (LineCount i = begin.line()+1; i < line_count(); ++i) m_lines[i].start -= length; - check_invariant(); - for (auto listener : m_change_listeners) listener->on_erase(begin, end); } diff --git a/src/buffer.hh b/src/buffer.hh index 9879bec7..e01919ee 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -168,10 +168,10 @@ public: const HookManager& hooks() const { return m_hooks; } std::unordered_set& change_listeners() const { return m_change_listeners; } -private: - friend class BufferIterator; void check_invariant() const; +private: + friend class BufferIterator; struct Line { diff --git a/src/editor.cc b/src/editor.cc index ef2d0a9b..6b058f3a 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -88,10 +88,10 @@ void Editor::insert(const String& str, InsertMode mode) { sel.first() = pos; sel.last() = str.empty() ? pos : utf8::character_start(pos + str.length() - 1); - sel.check_invariant(); } sel.avoid_eol(); } + check_invariant(); } void Editor::insert(const memoryview& strings, InsertMode mode) @@ -110,10 +110,10 @@ void Editor::insert(const memoryview& strings, InsertMode mode) { sel.first() = pos; sel.last() = str.empty() ? pos : utf8::character_start(pos + str.length() - 1); - sel.check_invariant(); } sel.avoid_eol(); } + check_invariant(); } std::vector Editor::selections_content() const @@ -408,6 +408,7 @@ void Editor::check_invariant() const assert(not m_selections.empty()); assert(m_main_sel < m_selections.size()); m_selections.check_invariant(); + buffer().check_invariant(); assert(std::is_sorted(m_selections.begin(), m_selections.end(), compare_selections)); #endif } diff --git a/src/editor.hh b/src/editor.hh index 1a99ceed..402f2c9c 100644 --- a/src/editor.hh +++ b/src/editor.hh @@ -87,7 +87,6 @@ public: size_t cursor_pos = String::npos); bool is_editing() const { return m_edition_level!= 0; } - private: friend struct scoped_edition; void begin_edition();