summaryrefslogtreecommitdiff
path: root/src/normal.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-06-02 15:13:56 +0100
committerMaxime Coste <frrrwww@gmail.com>2014-06-02 15:13:56 +0100
commitd33c27acdf7ebf5c9be0ab1406ae4c7e66fb671e (patch)
tree33b69998aa4b2429d2d1e2e024c575f1bd66c199 /src/normal.cc
parent23a1914d7e0bff8f71608b81348632c676e3ae19 (diff)
Move compute_modified_ranges to selection.cc and use an optimized approach
Diffstat (limited to 'src/normal.cc')
-rw-r--r--src/normal.cc49
1 files changed, 0 insertions, 49 deletions
diff --git a/src/normal.cc b/src/normal.cc
index 5cc013df..1a046b6d 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -1155,55 +1155,6 @@ void spaces_to_tabs(Context& context, int ts)
}
}
-static std::vector<Selection> compute_modified_ranges(Buffer& buffer, size_t timestamp)
-{
- std::vector<Selection> ranges;
- for (auto& change : buffer.changes_since(timestamp))
- {
- const ByteCoord& begin = change.begin;
- const ByteCoord& end = change.end;
- if (change.type == Buffer::Change::Insert)
- {
- update_insert(ranges, begin, end);
- auto it = std::upper_bound(ranges.begin(), ranges.end(), begin,
- [](ByteCoord c, const Selection& sel)
- { return c < sel.min(); });
- ranges.insert(it, Selection{begin, end});
- }
- else
- {
- update_erase(ranges, begin, end);
- auto pos = begin;
- if (change.at_end)
- pos = begin.column ? ByteCoord{begin.line, begin.column - 1}
- : ByteCoord{begin.line - 1};
- auto it = std::upper_bound(ranges.begin(), ranges.end(), pos,
- [](ByteCoord c, const Selection& sel)
- { return c < sel.min(); });
- ranges.insert(it, Selection{pos, pos});
- }
- }
- for (auto& sel : ranges)
- {
- sel.anchor() = buffer.clamp(sel.anchor());
- sel.cursor() = buffer.clamp(sel.cursor());
- }
-
- auto touches = [&](const Selection& lhs, const Selection& rhs) {
- return lhs.min() <= rhs.min() ? buffer.char_next(lhs.max()) >= rhs.min()
- : lhs.min() <= buffer.char_next(rhs.max());
- };
- size_t main = 0;
- merge_overlapping(ranges.begin(), ranges.end(), main, touches);
-
- for (auto& sel : ranges)
- {
- if (sel.anchor() != sel.cursor())
- sel.cursor() = buffer.char_prev(sel.cursor());
- }
- return ranges;
-}
-
void undo(Context& context, int)
{
Buffer& buffer = context.buffer();