diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2016-07-13 19:25:32 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2016-07-13 19:25:32 +0100 |
| commit | 52d3b60aaab913f80c361eb130dce6ea98f6e238 (patch) | |
| tree | 7ae8f8850f4bd4be1c0ccf104112f1588f18e9d7 /src/selection.cc | |
| parent | bbceae97a21487b3c50d2cd53abae329d680dd62 (diff) | |
Clamp selection generated in selection_list_from_string
Fixes #733
Diffstat (limited to 'src/selection.cc')
| -rw-r--r-- | src/selection.cc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/selection.cc b/src/selection.cc index 3cde21e4..36c1cdf2 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -337,6 +337,12 @@ Vector<Selection> compute_modified_ranges(Buffer& buffer, size_t timestamp) return ranges; } +static void clamp(Selection& sel, const Buffer& buffer) +{ + sel.anchor() = buffer.clamp(sel.anchor()); + sel.cursor() = buffer.clamp(sel.cursor()); +} + void update_selections(Vector<Selection>& selections, size_t& main, Buffer& buffer, size_t timestamp) { if (timestamp == buffer.timestamp()) @@ -366,10 +372,8 @@ void update_selections(Vector<Selection>& selections, size_t& main, Buffer& buff compare_selections)); } for (auto& sel : selections) - { - sel.anchor() = buffer.clamp(sel.anchor()); - sel.cursor() = buffer.clamp(sel.cursor()); - } + clamp(sel, buffer); + selections.erase(merge_overlapping(selections.begin(), selections.end(), main, overlaps), selections.end()); } @@ -604,7 +608,11 @@ SelectionList selection_list_from_string(Buffer& buffer, StringView desc) Vector<Selection> sels; for (auto sel_desc : desc | split<StringView>(':')) - sels.push_back(selection_from_string(sel_desc)); + { + auto sel = selection_from_string(sel_desc); + clamp(sel, buffer); + sels.push_back(sel); + } return {buffer, std::move(sels)}; } |
