]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
That didn't really work. So revert to old CSS for gray notes.
[lyx.git] / src / Buffer.cpp
index e827bc9780118e1a57a62af5e32918f6a0325d44..90512f0b63cbab0329fd588e93584ff600bbbd96 100644 (file)
@@ -356,6 +356,17 @@ Buffer::~Buffer()
 }
 
 
+Buffer * Buffer::clone() const
+{
+       Buffer * clone = new Buffer(fileName().absFilename(), false);
+       clone->d->file_fully_loaded = true;
+       clone->d->params = d->params;
+       clone->d->inset = static_cast<InsetText *>(d->inset->clone());
+       clone->d->inset->setBuffer(*clone);
+       return clone;
+}
+
+
 void Buffer::changed() const
 {
        if (d->wa_)
@@ -3735,15 +3746,26 @@ int Buffer::spellCheck(DocIterator & from, DocIterator & to,
        DocIterator const end = doc_iterator_end(this);
        for (; from != end; from.forwardPos()) {
                // We are only interested in text so remove the math CursorSlice.
-               while (from.inMathed())
-                       from.forwardInset();
+               while (from.inMathed()) {
+                       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.
+               if (from == end)
+                       break;
                to = from;
                if (from.paragraph().spellCheck(from.pos(), to.pos(), wl, suggestions)) {
                        word_lang = wl;
                        break;
                }
-               from = to;
-               ++progress;
+
+               // Do not increase progress when from == to, otherwise the word
+               // count will be wrong.
+               if (from != to) {
+                       from = to;
+                       ++progress;
+               }
        }
        return progress;
 }