From 5bb37ad755439d9a5a814af3a412f12d5c5658ba Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 10 Oct 2012 13:57:52 +0200 Subject: [PATCH] Support Append mode for Editor::select and use it for 'N' key --- src/editor.cc | 10 ++++++++++ src/main.cc | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/editor.cc b/src/editor.cc index b07ed449..8f9b051f 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -174,6 +174,16 @@ void Editor::select(const Selector& selector, SelectMode mode) { check_invariant(); + if (mode == SelectMode::Append) + { + auto& sel = m_selections.back(); + SelectionAndCaptures res = selector(sel.selection); + if (res.captures.empty()) + res.captures = sel.captures; + m_selections.push_back(res); + return; + } + for (auto& sel : m_selections) { SelectionAndCaptures res = selector(sel.selection); diff --git a/src/main.cc b/src/main.cc index 3e8144c5..acd32819 100644 --- a/src/main.cc +++ b/src/main.cc @@ -411,7 +411,7 @@ std::unordered_map> keymap = { { Key::Modifiers::None, '/' }, do_search }, { { Key::Modifiers::None, '?' }, do_search }, { { Key::Modifiers::None, 'n' }, do_search_next }, - { { Key::Modifiers::None, 'N' }, do_search_next }, + { { Key::Modifiers::None, 'N' }, do_search_next }, { { Key::Modifiers::None, 'u' }, repeated([](Context& context) { if (not context.editor().undo()) { context.print_status("nothing left to undo"); } }) }, { { Key::Modifiers::None, 'U' }, repeated([](Context& context) { if (not context.editor().redo()) { context.print_status("nothing left to redo"); } }) },