diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-01-24 19:18:29 +0000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-01-24 19:18:29 +0000 |
| commit | bbbb513990c070e13ceeb92fdfd9119d77be47c8 (patch) | |
| tree | c83b36cc134a7d71c49a58335f54a06922f088f8 /src/normal.cc | |
| parent | 7ba24c043aced097631e21463d79b21b17442a4e (diff) | |
Fix crash when clearing a regex prompt with multiple selections
Fixes #1124
Diffstat (limited to 'src/normal.cc')
| -rw-r--r-- | src/normal.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/normal.cc b/src/normal.cc index 1f0f6e5a..e07b2a93 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -684,7 +684,7 @@ void search(Context& context, NormalParams params) auto reg_content = RegisterManager::instance()[reg].values(context); 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(), [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); 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), [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); 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), [reg, capture, saved_reg, main_index](Regex ex, PromptEvent event, Context& context) { |
