summaryrefslogtreecommitdiff
path: root/src/display_buffer.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2020-04-27 13:36:12 +1000
committerMaxime Coste <mawww@kakoune.org>2020-04-27 17:39:21 +1000
commit954373d3cfa9d168f7949f12cb7b2e730d18de99 (patch)
tree780e9cd53936d9d0fa54d0dea2b7edf5203e7123 /src/display_buffer.cc
parent65620fb8306f65247c8a2fb9732aa68dfe707308 (diff)
Support multi-line replace-ranges
This likely has lots of rough edges, but should be an initial proof of concept to support folding.
Diffstat (limited to 'src/display_buffer.cc')
-rw-r--r--src/display_buffer.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/display_buffer.cc b/src/display_buffer.cc
index 3d68356f..8ade4047 100644
--- a/src/display_buffer.cc
+++ b/src/display_buffer.cc
@@ -111,6 +111,14 @@ DisplayLine::iterator DisplayLine::split(iterator it, ColumnCount count)
return split(it, pos);
}
+DisplayLine::iterator DisplayLine::split(BufferCoord pos)
+{
+ auto it = find_if(begin(), end(), [pos](const DisplayAtom& a) { return a.type() == DisplayAtom::Range and a.end() > pos; });
+ if (it == end() or it->begin() >= pos)
+ return it;
+ return ++split(it, pos);
+}
+
DisplayLine::iterator DisplayLine::insert(iterator it, DisplayAtom atom)
{
if (atom.has_buffer_range())
@@ -118,7 +126,9 @@ DisplayLine::iterator DisplayLine::insert(iterator it, DisplayAtom atom)
m_range.begin = std::min(m_range.begin, atom.begin());
m_range.end = std::max(m_range.end, atom.end());
}
- return m_atoms.insert(it, std::move(atom));
+ auto res = m_atoms.insert(it, std::move(atom));
+ compute_range();
+ return res;
}
void DisplayLine::push_back(DisplayAtom atom)