Am Sonntag, dem 07.03.2021 um 14:04 +0100 schrieb Stephan Witt: > > I can't follow you here. Sure it is. > > IMO it is a new feature.
Where did I claim it isn't? If you want to enhance it: be invited. > > > > Also, as you say it is marked correctly after context menu > > > > action, > > > > there is probably only some call missing here. > > > > > > Yes, probably. > > > > I have just looked again at AppleSpellChecker and really do not see > > how > > this is so special. Maybe you just need to debug a bit > > Paragraph::spellCheck() (the routine which is in if (speller- > > > canCheckParagraph())). Well likely just a simple oversight. Check > > > for > > the return values of speller->check() gathered here. It should be > > LEARNED_WORD for the cases in question. > > The difference is made by the canCheckParagraph() method of spellers. Yes, I know (see my comment above). > Paragraph::spellCheck() has different code paths for it. > > With paragraph check enabled - see AppleSpellChecker.h - the speller > sees the whole sentence as a word and marks one or more words as mis- > spelled at once. I see. Can you try (and maybe play with) the attached patch? Jürgen
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 008ed0e461..00d9dc1de4 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -460,10 +460,12 @@ public: return numskips; } - void markMisspelledWords(pos_type const & first, pos_type const & last, - SpellChecker::Result result, - docstring const & word, - SkipPositions const & skips); + void markMisspelledWords(Language const * lang, + pos_type const & first, pos_type const & last, + SpellChecker::Result result, + docstring const & word, + SkipPositions const & skips, + vector<WordLangTuple> const & docdic); InsetCode ownerCode() const { @@ -4924,10 +4926,12 @@ void Paragraph::anonymize() void Paragraph::Private::markMisspelledWords( + Language const * lang, pos_type const & first, pos_type const & last, SpellChecker::Result result, docstring const & word, - SkipPositions const & skips) + SkipPositions const & skips, + vector<WordLangTuple> const & docdict) { if (!SpellChecker::misspelled(result)) { setMisspelled(first, last, SpellChecker::WORD_OK); @@ -4945,7 +4949,8 @@ void Paragraph::Private::markMisspelledWords( int wlen = 0; speller->misspelledWord(index, wstart, wlen); /// should not happen if speller supports range checks - if (!wlen) continue; + if (!wlen) + continue; docstring const misspelled = word.substr(wstart, wlen); wstart += first + numskipped; if (snext < wstart) { @@ -4955,12 +4960,27 @@ void Paragraph::Private::markMisspelledWords( wstart - 1, SpellChecker::WORD_OK); } snext = wstart + wlen; + vector<WordLangTuple>::const_iterator iit = docdict.begin(); + SpellChecker::Result actresult = result; + for (; iit != docdict.end(); ++iit) { + if (iit->lang()->code() != lang->code()) + continue; + if (iit->word() == misspelled) { + actresult = SpellChecker::WORD_OK; + break; + } + } numskipped += countSkips(it, et, snext); /// mark the range of misspelling - setMisspelled(wstart, snext, result); - LYXERR(Debug::GUI, "misspelled word: \"" << - misspelled << "\" [" << - wstart << ".." << (snext-1) << "]"); + setMisspelled(wstart, snext, actresult); + if (actresult == SpellChecker::WORD_OK) + LYXERR(Debug::GUI, "local dictionary word: \"" << + misspelled << "\" [" << + wstart << ".." << (snext-1) << "]"); + else + LYXERR(Debug::GUI, "misspelled word: \"" << + misspelled << "\" [" << + wstart << ".." << (snext-1) << "]"); ++snext; } if (snext <= last) { @@ -4992,7 +5012,7 @@ void Paragraph::spellCheck() const BufferParams const & bparams = d->inset_owner_->buffer().params(); SpellChecker::Result result = !word.empty() ? speller->check(wl, bparams.spellignore()) : SpellChecker::WORD_OK; - d->markMisspelledWords(first, last, result, word, skips); + d->markMisspelledWords(lang, first, last, result, word, skips, bparams.spellignore()); first = ++last; } } else {
signature.asc
Description: This is a digitally signed message part
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel