MCPcopy Create free account
hub / github.com/Predelnik/DSpellCheck / process_replace_all

Method process_replace_all

src/ui/ContextMenuHandler.cpp:135–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135void 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
155void ContextMenuHandler::process_plugin_menu_result(WPARAM menu_id) {
156 WPARAM result;

Callers

nothing calls this directly

Calls 9

to_lower_inplaceFunction · 0.85
replace_all_tokensFunction · 0.85
c_strMethod · 0.80
to_editor_encodingMethod · 0.80
set_cursor_posMethod · 0.80
selected_textMethod · 0.45
replace_textMethod · 0.45
emptyMethod · 0.45
check_wordMethod · 0.45

Tested by

no test coverage detected