home/src/dynamic_selection_list.cc

44 lines
1010 B
C++
Raw Normal View History

#include "dynamic_selection_list.hh"
namespace Kakoune
{
DynamicSelectionList::DynamicSelectionList(const Buffer& buffer,
SelectionList selections)
: SelectionList(std::move(selections)),
BufferChangeListener_AutoRegister(buffer)
{
check_invariant();
}
DynamicSelectionList& DynamicSelectionList::operator=(SelectionList selections)
{
SelectionList::operator=(std::move(selections));
check_invariant();
return *this;
}
void DynamicSelectionList::check_invariant() const
{
2013-02-27 19:03:33 +01:00
#ifdef KAK_DEBUG
const Buffer* buf = &buffer();
for (auto& sel : *this)
2013-01-23 14:25:48 +01:00
{
kak_assert(buf == &sel.buffer());
2013-01-23 14:25:48 +01:00
sel.check_invariant();
}
2013-02-27 19:03:33 +01:00
#endif
}
void DynamicSelectionList::on_insert(const BufferIterator& begin, const BufferIterator& end)
{
update_insert(begin.coord(), end.coord());
}
void DynamicSelectionList::on_erase(const BufferIterator& begin, const BufferIterator& end)
{
update_erase(begin.coord(), end.coord());
}
}