From 02b9fcc3dff812ece35c5e565732afeff50fb035 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 3 Jan 2013 14:00:31 +0100 Subject: [PATCH] Editor: add a ReplaceLast select mode --- src/editor.cc | 7 +++++++ src/editor.hh | 1 + 2 files changed, 8 insertions(+) diff --git a/src/editor.cc b/src/editor.cc index 40de7138..a7db8179 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -241,6 +241,8 @@ void Editor::select(const Selection& selection, SelectMode mode) m_selections.push_back(selection); sort_and_merge_overlapping(m_selections); } + else + assert(false); check_invariant(); } @@ -262,6 +264,11 @@ void Editor::select(const Selector& selector, SelectMode mode) res.captures() = sel.captures(); m_selections.push_back(res); } + else if (mode == SelectMode::ReplaceLast) + { + auto& sel = m_selections.back(); + sel = selector(sel); + } else { for (auto& sel : m_selections) diff --git a/src/editor.hh b/src/editor.hh index dda0fe07..07230ae4 100644 --- a/src/editor.hh +++ b/src/editor.hh @@ -18,6 +18,7 @@ enum class SelectMode Replace, Extend, Append, + ReplaceLast, }; enum class InsertMode : unsigned