| 431 | } |
| 432 | |
| 433 | std::vector<std::wstring> HunspellInterface::get_suggestions(const wchar_t *word) const { |
| 434 | std::vector<std::string> list; |
| 435 | m_last_selected_speller = nullptr; |
| 436 | |
| 437 | switch (m_speller_mode) { |
| 438 | case SpellerMode::SingleLanguage: { |
| 439 | m_last_selected_speller = m_singular_speller; |
| 440 | if (!m_singular_speller->is_loaded()) |
| 441 | return {}; |
| 442 | list = m_singular_speller->hunspell->suggest(m_singular_speller->to_dictionary_encoding(word)); |
| 443 | } |
| 444 | break; |
| 445 | case SpellerMode::MultipleLanguages: { |
| 446 | for (auto speller : m_spellers) { |
| 447 | if (!speller->is_loaded()) |
| 448 | continue; |
| 449 | auto cur_list = speller->hunspell->suggest(speller->to_dictionary_encoding(word)); |
| 450 | if (cur_list.size() > list.size()) { |
| 451 | list = std::move(cur_list); |
| 452 | m_last_selected_speller = speller; |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | break; |
| 457 | } |
| 458 | |
| 459 | if (!m_last_selected_speller) |
| 460 | return {}; |
| 461 | |
| 462 | std::vector<std::wstring> sugg_list(list.size()); |
| 463 | std::transform(list.begin(), list.end(), sugg_list.begin(), [this](const std::string &s) { return m_last_selected_speller->from_dictionary_encoding(s); }); |
| 464 | return sugg_list; |
| 465 | } |
| 466 | |
| 467 | void HunspellInterface::set_directory(const wchar_t *dir) { |
| 468 | if (dir == nullptr || *dir == L'\0') |
nothing calls this directly
no test coverage detected