Support Append mode for Editor::select and use it for 'N' key
This commit is contained in:
parent
4c8b4890e6
commit
5bb37ad755
|
@ -174,6 +174,16 @@ void Editor::select(const Selector& selector, SelectMode mode)
|
||||||
{
|
{
|
||||||
check_invariant();
|
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)
|
for (auto& sel : m_selections)
|
||||||
{
|
{
|
||||||
SelectionAndCaptures res = selector(sel.selection);
|
SelectionAndCaptures res = selector(sel.selection);
|
||||||
|
|
|
@ -411,7 +411,7 @@ std::unordered_map<Key, std::function<void (Context& context)>> keymap =
|
||||||
{ { Key::Modifiers::None, '/' }, do_search<SelectMode::Replace> },
|
{ { Key::Modifiers::None, '/' }, do_search<SelectMode::Replace> },
|
||||||
{ { Key::Modifiers::None, '?' }, do_search<SelectMode::Extend> },
|
{ { Key::Modifiers::None, '?' }, do_search<SelectMode::Extend> },
|
||||||
{ { Key::Modifiers::None, 'n' }, do_search_next<SelectMode::Replace> },
|
{ { Key::Modifiers::None, 'n' }, do_search_next<SelectMode::Replace> },
|
||||||
{ { Key::Modifiers::None, 'N' }, do_search_next<SelectMode::Extend> },
|
{ { Key::Modifiers::None, 'N' }, do_search_next<SelectMode::Append> },
|
||||||
|
|
||||||
{ { 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().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"); } }) },
|
{ { Key::Modifiers::None, 'U' }, repeated([](Context& context) { if (not context.editor().redo()) { context.print_status("nothing left to redo"); } }) },
|
||||||
|
|
Loading…
Reference in New Issue
Block a user