Fix crash when clearing a regex prompt with multiple selections

Fixes #1124
This commit is contained in:
Maxime Coste 2017-01-24 19:18:29 +00:00
parent 7ba24c043a
commit bbbb513990

View File

@ -684,7 +684,7 @@ void search(Context& context, NormalParams params)
auto reg_content = RegisterManager::instance()[reg].values(context); auto reg_content = RegisterManager::instance()[reg].values(context);
Vector<String> saved_reg{reg_content.begin(), reg_content.end()}; Vector<String> saved_reg{reg_content.begin(), reg_content.end()};
const int main_index = context.selections().main_index(); const int main_index = std::min(context.selections().main_index(), saved_reg.size()-1);
regex_prompt(context, prompt.str(), regex_prompt(context, prompt.str(),
[reg, count, saved_reg, main_index] [reg, count, saved_reg, main_index]
@ -768,7 +768,7 @@ void select_regex(Context& context, NormalParams params)
auto reg_content = RegisterManager::instance()[reg].values(context); auto reg_content = RegisterManager::instance()[reg].values(context);
Vector<String> saved_reg{reg_content.begin(), reg_content.end()}; Vector<String> saved_reg{reg_content.begin(), reg_content.end()};
const int main_index = context.selections().main_index(); const int main_index = std::min(context.selections().main_index(), saved_reg.size()-1);
regex_prompt(context, std::move(prompt), regex_prompt(context, std::move(prompt),
[reg, capture, saved_reg, main_index](Regex ex, PromptEvent event, Context& context) { [reg, capture, saved_reg, main_index](Regex ex, PromptEvent event, Context& context) {
@ -795,7 +795,7 @@ void split_regex(Context& context, NormalParams params)
auto reg_content = RegisterManager::instance()[reg].values(context); auto reg_content = RegisterManager::instance()[reg].values(context);
Vector<String> saved_reg{reg_content.begin(), reg_content.end()}; Vector<String> saved_reg{reg_content.begin(), reg_content.end()};
const int main_index = context.selections().main_index(); const int main_index = std::min(context.selections().main_index(), saved_reg.size()-1);
regex_prompt(context, std::move(prompt), regex_prompt(context, std::move(prompt),
[reg, capture, saved_reg, main_index](Regex ex, PromptEvent event, Context& context) { [reg, capture, saved_reg, main_index](Regex ex, PromptEvent event, Context& context) {