From 5743ea738400d3436b8c164d53572ae768ba2773 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 18 Nov 2015 20:13:03 +0000 Subject: [PATCH] Respect count argument on search --- src/normal.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/normal.cc b/src/normal.cc index bee88b98..9b9f5088 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -630,14 +630,20 @@ template void search(Context& context, NormalParams params) { const char reg = to_lower(params.reg ? params.reg : '/'); + int count = params.count; regex_prompt(context, direction == Forward ? "search:" : "reverse search:", - [reg](Regex ex, PromptEvent event, Context& context) { + [reg, count](Regex ex, PromptEvent event, Context& context) { if (ex.empty()) ex = Regex{context.main_sel_register_value(reg)}; else if (event == PromptEvent::Validate) RegisterManager::instance()[reg] = ex.str(); if (not ex.empty() and not ex.str().empty()) - select_next_match(context.buffer(), context.selections(), ex); + { + int c = count; + do { + select_next_match(context.buffer(), context.selections(), ex); + } while (--c > 0); + } }); }