#9514 improved document iterator for correct check of speller disabled state

This commit is contained in:
Stephan Witt 2015-05-08 11:13:32 +02:00
parent 9162a3f40e
commit e93444e7e9
4 changed files with 21 additions and 6 deletions

View File

@ -4808,14 +4808,13 @@ int Buffer::spellCheck(DocIterator & from, DocIterator & to,
DocIterator const end = to_end ? doc_iterator_end(this) : to;
// OK, we start from here.
for (; from != end; from.forwardPos()) {
// We are only interested in text so remove the math CursorSlice.
// The same is done for insets with disabled spell check.
while (from.inMathed() || !from.inset().allowSpellCheck()) {
// This skips all insets with spell check disabled.
while (!from.allowSpellCheck()) {
from.pop_back();
from.pos()++;
}
// If from is at the end of the document (which is possible
// when "from" was manipulated) LyX will crash later otherwise.
// when "from" was changed above) LyX will crash later otherwise.
if (from.atEnd() || (!to_end && from >= end))
break;
to = from;

View File

@ -482,6 +482,19 @@ bool DocIterator::hasPart(DocIterator const & it) const
}
bool DocIterator::allowSpellCheck() const
{
/// spell check is disabled if the iterator position
/// is inside of an inset which disables the spell checker
size_t const n = depth();
for (size_t i = 0; i < n; ++i) {
if (!slices_[i].inset_->allowSpellCheck())
return false;
}
return true;
}
void DocIterator::updateInsets(Inset * inset)
{
// this function re-creates the cache of inset pointers.

View File

@ -75,6 +75,9 @@ public:
/// is this the last possible position?
bool atLastPos() const { return pit() == lastpit() && pos() == lastpos(); }
/// checks the cursor slices for disabled spell checker insets
bool allowSpellCheck() const;
//
// access to slice at tip
//

View File

@ -330,8 +330,8 @@ void RowPainter::paintFromPos(pos_type & vpos, bool changed)
--cpos;
new_word = par_.isSameSpellRange(pos, cpos) ;
}
if (!new_word)
paintMisspelledMark(orig_x, changed);
if (!new_word && pi_.do_spellcheck)
paintMisspelledMark(orig_x, changed, font);
}
}