summaryrefslogtreecommitdiff
path: root/src/dynamic_selection_list.cc
blob: 6c9fc4c4ac6a918eb6343c84b3f912b267967a19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#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
{
#ifdef KAK_DEBUG
    if (empty())
        return;
    const Buffer* buf = &buffer();
    kak_assert(&front().buffer() == buf);
    SelectionList::check_invariant();
#endif
}

void DynamicSelectionList::on_insert(const BufferCoord& begin, const BufferCoord& end)
{
    update_insert(begin, end);
}

void DynamicSelectionList::on_erase(const BufferCoord& begin, const BufferCoord& end)
{
    update_erase(begin, end);
}

}