| 143 | } |
| 144 | |
| 145 | bool is_word_spell_checking_needed(const Settings &settings, const EditorInterface &editor, std::wstring_view word, |
| 146 | TextPosition word_start) { |
| 147 | if (word.empty()) |
| 148 | return false; |
| 149 | |
| 150 | auto style = editor.get_style_at(word_start); |
| 151 | auto lexer = editor.get_lexer(); |
| 152 | auto category = ScintillaUtils::get_style_category(lexer, style, settings); |
| 153 | if (category == ScintillaUtils::StyleCategory::unknown) { |
| 154 | return false; |
| 155 | } |
| 156 | |
| 157 | if (category != ScintillaUtils::StyleCategory::text && |
| 158 | !((category == ScintillaUtils::StyleCategory::comment && settings.data.check_comments) || ( |
| 159 | category == ScintillaUtils::StyleCategory::string && settings.data.check_strings) || |
| 160 | (category == ScintillaUtils::StyleCategory::identifier && settings.data.check_variable_functions))) { |
| 161 | return false; |
| 162 | } |
| 163 | |
| 164 | // ignoring URLs new style: |
| 165 | if (editor.get_indicator_value_at(URL_INDIC, word_start) != 0) |
| 166 | return false; |
| 167 | |
| 168 | if (static_cast<int>(word.length()) < settings.data.word_minimum_length) |
| 169 | return false; |
| 170 | |
| 171 | if (settings.data.ignore_one_letter && word.length() == 1) |
| 172 | return false; |
| 173 | |
| 174 | if (settings.data.ignore_containing_digit && |
| 175 | std::find_if(word.begin(), word.end(), [](wchar_t wc) { return IsCharAlphaNumeric(wc) && !IsCharAlpha(wc); }) != word.end()) |
| 176 | return false; |
| 177 | |
| 178 | if (settings.data.ignore_starting_with_capital && IsCharUpper(word.front())) { |
| 179 | return false; |
| 180 | } |
| 181 | |
| 182 | if (settings.data.ignore_having_a_capital || settings.data.ignore_all_capital) { |
| 183 | bool all_upper = IsCharUpper(word.front()), any_upper = false; |
| 184 | for (auto c : std::wstring_view(word).substr(1)) { |
| 185 | if (IsCharUpper(c)) { |
| 186 | any_upper = true; |
| 187 | } else |
| 188 | all_upper = false; |
| 189 | } |
| 190 | |
| 191 | if (!all_upper && any_upper && settings.data.ignore_having_a_capital) |
| 192 | return false; |
| 193 | |
| 194 | if (all_upper && settings.data.ignore_all_capital) |
| 195 | return false; |
| 196 | } |
| 197 | |
| 198 | if (settings.data.ignore_having_underscore && word.find(L'_') != std::wstring_view::npos) |
| 199 | return false; |
| 200 | |
| 201 | if (settings.data.ignore_starting_or_ending_with_apostrophe) { |
| 202 | if (is_apostrophe(settings, word.front()) || is_apostrophe(settings, word.back())) |
no test coverage detected