| 133 | } |
| 134 | |
| 135 | void ContextMenuHandler::process_replace_all(WPARAM result) { |
| 136 | const auto misspelled_text = m_editor.selected_text(); |
| 137 | const auto &suggestion = m_last_suggestions[result - menu_id::replace_all_start - 1]; |
| 138 | UNDO_BLOCK(m_editor); |
| 139 | // not replacing originally selected word is unexpected behaviour, so we replace it with the exact suggestion |
| 140 | m_editor.replace_text(m_word_under_cursor_pos, m_word_under_cursor_pos + m_word_under_cursor_length, m_editor.to_editor_encoding(suggestion).c_str()); |
| 141 | m_editor.set_cursor_pos(m_word_under_cursor_pos + suggestion.length()); |
| 142 | |
| 143 | bool is_proper_name = true; |
| 144 | if (!suggestion.empty()) { |
| 145 | auto suggestion_copy = suggestion; |
| 146 | to_lower_inplace(suggestion_copy); |
| 147 | // if lowercase version is incorrect - the word is not a proper name |
| 148 | if (m_speller_container.active_speller().check_word({suggestion_copy})) |
| 149 | is_proper_name = false; |
| 150 | } |
| 151 | |
| 152 | SpellCheckerHelpers::replace_all_tokens(m_editor, m_settings, misspelled_text.c_str(), suggestion, is_proper_name); |
| 153 | } |
| 154 | |
| 155 | void ContextMenuHandler::process_plugin_menu_result(WPARAM menu_id) { |
| 156 | WPARAM result; |
nothing calls this directly
no test coverage detected