add SelectionList::check_invariant
This commit is contained in:
parent
9b3e0c8055
commit
4c4b6a404d
|
@ -21,12 +21,11 @@ DynamicSelectionList& DynamicSelectionList::operator=(SelectionList selections)
|
|||
void DynamicSelectionList::check_invariant() const
|
||||
{
|
||||
#ifdef KAK_DEBUG
|
||||
if (empty())
|
||||
return;
|
||||
const Buffer* buf = &buffer();
|
||||
for (auto& sel : *this)
|
||||
{
|
||||
kak_assert(buf == &sel.buffer());
|
||||
sel.check_invariant();
|
||||
}
|
||||
kak_assert(&front().buffer() == buf);
|
||||
SelectionList::check_invariant();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -142,4 +142,17 @@ void SelectionList::update_erase(const BufferCoord& begin, const BufferCoord& en
|
|||
on_buffer_change<UpdateErase>(*this, begin, end, end.line);
|
||||
}
|
||||
|
||||
void SelectionList::check_invariant() const
|
||||
{
|
||||
#ifdef KAK_DEBUG
|
||||
for (size_t i = 0; i < size(); ++i)
|
||||
{
|
||||
auto& sel = (*this)[i];
|
||||
sel.check_invariant();
|
||||
if (i+1 < size())
|
||||
kak_assert(sel.begin() <= (*this)[i+1].begin());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,6 +74,8 @@ struct SelectionList : std::vector<Selection>
|
|||
|
||||
void update_insert(const BufferCoord& begin, const BufferCoord& end);
|
||||
void update_erase(const BufferCoord& begin, const BufferCoord& end);
|
||||
|
||||
void check_invariant() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user