From 7f8d5c1fd0808e7151f5465ede8a5548f05b2f6f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 27 May 2013 14:22:21 +0200 Subject: [PATCH] Remove Range::content --- src/editor.cc | 2 +- src/main.cc | 3 ++- src/normal.cc | 3 ++- src/selection.cc | 5 ----- src/selection.hh | 1 - 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/editor.cc b/src/editor.cc index afdbafef..5ccb7889 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -129,7 +129,7 @@ std::vector Editor::selections_content() const { std::vector contents; for (auto& sel : m_selections) - contents.push_back(sel.content()); + contents.push_back(m_buffer->string(sel.min(), utf8::next(sel.max()))); return contents; } diff --git a/src/main.cc b/src/main.cc index 752374ac..fc196564 100644 --- a/src/main.cc +++ b/src/main.cc @@ -67,7 +67,8 @@ void register_env_vars() { return to_string(context.buffer().timestamp()); }); shell_manager.register_env_var("selection", [](const String& name, const Context& context) - { return context.editor().main_selection().content(); }); + { const Range& sel = context.editor().main_selection(); + return context.buffer().string(sel.min(), utf8::next(sel.max())); }); shell_manager.register_env_var("selections", [](const String& name, const Context& context) { auto sels = context.editor().selections_content(); diff --git a/src/normal.cc b/src/normal.cc index 3506e4fa..f09900db 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -135,7 +135,8 @@ void goto_commands(Context& context) } case 'f': { - String filename = context.editor().main_selection().content(); + const Range& sel = context.editor().main_selection(); + String filename = context.buffer().string(sel.min(), utf8::next(sel.max())); static constexpr char forbidden[] = { '\'', '\\', '\0' }; for (auto c : forbidden) if (contains(filename, c)) diff --git a/src/selection.cc b/src/selection.cc index d616aa8b..60ebe441 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -14,11 +14,6 @@ void Range::merge_with(const Range& range) m_first = std::max(m_first, range.m_first); } -String Range::content() const -{ - return m_first.buffer().string(min(), utf8::next(max())); -} - void Range::check_invariant() const { #ifdef KAK_DEBUG diff --git a/src/selection.hh b/src/selection.hh index d7fb8f6b..7f7e3db9 100644 --- a/src/selection.hh +++ b/src/selection.hh @@ -29,7 +29,6 @@ public: const BufferIterator& min() const { return std::min(m_first, m_last); } const BufferIterator& max() const { return std::max(m_first, m_last); } - String content() const; void check_invariant() const; private: