mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
#9514 contents inside of LyX insets with spell check disabled should be ignored by spell checker.
The document iterator now skips math insets and insets like notes where spell check is disabled. The continuous spell checking is part of the row painter drawing and the spell check disabled state has to be passed down recursively while doing the inset painting.
This commit is contained in:
parent
4f3d9d0092
commit
93b0f9c080
@ -4809,12 +4809,13 @@ int Buffer::spellCheck(DocIterator & from, DocIterator & to,
|
||||
// OK, we start from here.
|
||||
for (; from != end; from.forwardPos()) {
|
||||
// We are only interested in text so remove the math CursorSlice.
|
||||
while (from.inMathed()) {
|
||||
// The same is done for insets with disabled spell check.
|
||||
while (from.inMathed() || !from.inset().allowSpellCheck()) {
|
||||
from.pop_back();
|
||||
from.pos()++;
|
||||
}
|
||||
// If from is at the end of the document (which is possible
|
||||
// when leaving the mathed) LyX will crash later otherwise.
|
||||
// when "from" was manipulated) LyX will crash later otherwise.
|
||||
if (from.atEnd() || (!to_end && from >= end))
|
||||
break;
|
||||
to = from;
|
||||
@ -4824,7 +4825,6 @@ int Buffer::spellCheck(DocIterator & from, DocIterator & to,
|
||||
word_lang = wl;
|
||||
break;
|
||||
}
|
||||
|
||||
// Do not increase progress when from == to, otherwise the word
|
||||
// count will be wrong.
|
||||
if (from != to) {
|
||||
|
@ -66,7 +66,7 @@ MetricsInfo::MetricsInfo(BufferView * bv, FontInfo const & font, int textwidth,
|
||||
|
||||
PainterInfo::PainterInfo(BufferView * bv, lyx::frontend::Painter & painter)
|
||||
: pain(painter), ltr_pos(false), change_(), selected(false),
|
||||
full_repaint(true), background_color(Color_background)
|
||||
do_spellcheck(true), full_repaint(true), background_color(Color_background)
|
||||
{
|
||||
base.bv = bv;
|
||||
}
|
||||
|
@ -117,6 +117,8 @@ public:
|
||||
Change change_;
|
||||
/// Whether the parent is selected as a whole
|
||||
bool selected;
|
||||
/// Whether the spell checker is enabled for the parent
|
||||
bool do_spellcheck;
|
||||
///
|
||||
bool full_repaint;
|
||||
/// Current background color
|
||||
|
@ -121,13 +121,15 @@ void RowPainter::paintInset(Inset const * inset, pos_type const pos)
|
||||
LASSERT(inset, return);
|
||||
// Backup full_repaint status because some insets (InsetTabular)
|
||||
// requires a full repaint
|
||||
bool pi_full_repaint = pi_.full_repaint;
|
||||
bool const pi_full_repaint = pi_.full_repaint;
|
||||
bool const pi_do_spellcheck = pi_.do_spellcheck;
|
||||
|
||||
pi_.base.font = inset->inheritFont() ? font.fontInfo() :
|
||||
pi_.base.bv->buffer().params().getFont().fontInfo();
|
||||
pi_.ltr_pos = (bidi_.level(pos) % 2 == 0);
|
||||
Change prev_change = change_;
|
||||
pi_.change_ = change_.changed() ? change_ : par_.lookupChange(pos);
|
||||
pi_.do_spellcheck &= inset->allowSpellCheck();
|
||||
|
||||
int const x1 = int(x_);
|
||||
pi_.base.bv->coordCache().insets().add(inset, x1, yo_);
|
||||
@ -147,6 +149,7 @@ void RowPainter::paintInset(Inset const * inset, pos_type const pos)
|
||||
// Restore full_repaint status.
|
||||
pi_.full_repaint = pi_full_repaint;
|
||||
pi_.change_ = prev_change;
|
||||
pi_.do_spellcheck = pi_do_spellcheck;
|
||||
|
||||
#ifdef DEBUG_METRICS
|
||||
int const x2 = x1 + dim.wid;
|
||||
|
@ -1878,7 +1878,7 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const
|
||||
|| rowSlice == bv_->lastRowSlice();
|
||||
|
||||
// Take this opportunity to spellcheck the row contents.
|
||||
if (row_has_changed && lyxrc.spellcheck_continuously) {
|
||||
if (row_has_changed && pi.do_spellcheck && lyxrc.spellcheck_continuously) {
|
||||
text_->getPar(pit).spellCheck();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user