mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
#9514 improved document iterator for correct check of speller disabled state
This commit is contained in:
parent
9162a3f40e
commit
e93444e7e9
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
//
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user