diff --git a/src/editor.cc b/src/editor.cc index 77080312..6f3255ed 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -119,7 +119,7 @@ std::vector Editor::selections_content() const { std::vector contents; for (auto& sel : m_selections) - contents.push_back(m_buffer->string(sel.begin(), sel.end())); + contents.push_back(sel.content()); return contents; } diff --git a/src/selection.cc b/src/selection.cc index 04ebae81..7868fb15 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -24,6 +24,11 @@ BufferIterator Range::end() const return utf8::next(std::max(m_first, m_last)); } +String Range::content() const +{ + return m_first.buffer().string(begin(), end()); +} + void Range::check_invariant() const { #ifdef KAK_DEBUG diff --git a/src/selection.hh b/src/selection.hh index 294ecee1..9bf2065f 100644 --- a/src/selection.hh +++ b/src/selection.hh @@ -31,6 +31,8 @@ public: // returns max(first, last) + 1 BufferIterator end() const; + String content() const; + void check_invariant() const; private: BufferIterator m_first;