- NSRange match = [speller->checker
- checkSpellingOfString:word_
- startingAt:0
- language:lang_
- wrap:NO
- inSpellDocumentWithTag:speller->doctag
- wordCount:NULL];
-
- SpellCheckResult result = match.length == 0 ? SPELL_CHECK_OK : SPELL_CHECK_FAILED;
- if (result == SPELL_CHECK_OK && [NSSpellChecker instancesRespondToSelector:@selector(hasLearnedWord:)]) {
- if ([speller->checker hasLearnedWord:word_])
- result = SPELL_CHECK_LEARNED;
+ while (result == SPELL_CHECK_FAILED && start < length) {
+ NSRange match = [speller->checker
+ checkSpellingOfString:word_
+ startingAt:start
+ language:lang_
+ wrap:(BOOL)NO
+ inSpellDocumentWithTag:speller->doctag
+ wordCount:NULL];
+
+ result = match.length == 0 ? SPELL_CHECK_OK : SPELL_CHECK_FAILED;
+ if (result == SPELL_CHECK_OK) {
+ if ([NSSpellChecker instancesRespondToSelector:@selector(hasLearnedWord:)]) {
+ if ([speller->checker hasLearnedWord:word_])
+ result = SPELL_CHECK_LEARNED;
+ }
+ } else {
+#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1050)
+ NSUInteger capacity = [speller->misspelled count] + 1;
+#else
+ int capacity = [speller->misspelled count] + 1;
+#endif
+ NSMutableArray * misspelled = [NSMutableArray arrayWithCapacity:capacity];
+ [misspelled addObjectsFromArray:speller->misspelled];
+ [misspelled addObject:[NSValue valueWithRange:match]];
+ [speller->misspelled release];
+ speller->misspelled = [[NSArray arrayWithArray:misspelled] retain];
+ start = match.location + match.length + 1;
+ }