]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph.C
* QPrefsDialog::QPrefsDialog():
[lyx.git] / src / paragraph.C
index 8f136352fe39d09bee51dee4eb5dbc1f14f06abf..4bfe0db3fe55894c10394b46d69e98e82a5e8efb 100644 (file)
@@ -159,12 +159,15 @@ void Paragraph::write(Buffer const & buf, ostream & os,
        lyx::time_type const curtime(lyx::current_time());
 
        int column = 0;
-       for (pos_type i = 0; i < size(); ++i) {
+       for (pos_type i = 0; i <= size(); ++i) {
 
                Change change = pimpl_->lookupChangeFull(i);
                Changes::lyxMarkChange(os, column, curtime, running_change, change);
                running_change = change;
 
+               if (i == size())
+                       break;
+
                // Write font changes
                LyXFont font2 = getFontSettings(bparams, i);
                if (font2 != font1) {
@@ -223,15 +226,6 @@ void Paragraph::write(Buffer const & buf, ostream & os,
                }
        }
 
-       // to make reading work properly
-       if (!size()) {
-               running_change = pimpl_->lookupChange(0);
-               Changes::lyxMarkChange(os, column, curtime,
-                       Change(Change::UNCHANGED), running_change);
-       }
-       Changes::lyxMarkChange(os, column, curtime,
-               running_change, Change(Change::UNCHANGED));
-
        os << "\n\\end_layout\n";
 }
 
@@ -569,9 +563,8 @@ int Paragraph::stripLeadingSpaces()
                return 0;
 
        int i = 0;
-       while (!empty() && (isNewline(0) || isLineSeparator(0))) {
-               // Set Change::Type to Change::INSERTED to quietly remove it
-               setChange(0, Change::INSERTED);
+       while (!empty() && (isNewline(0) || isLineSeparator(0)) 
+               && (lookupChange(0) != Change::DELETED)) {
                erase(0);
                ++i;
        }
@@ -1639,14 +1632,14 @@ void Paragraph::cleanChanges()
 
 Change::Type Paragraph::lookupChange(lyx::pos_type pos) const
 {
-       BOOST_ASSERT(empty() || pos < size());
+       BOOST_ASSERT(pos <= size());
        return pimpl_->lookupChange(pos);
 }
 
 
 Change const Paragraph::lookupChangeFull(lyx::pos_type pos) const
 {
-       BOOST_ASSERT(empty() || pos < size());
+       BOOST_ASSERT(pos <= size());
        return pimpl_->lookupChangeFull(pos);
 }
 
@@ -1669,6 +1662,12 @@ void Paragraph::setChange(lyx::pos_type pos, Change::Type type)
 }
 
 
+void Paragraph::setChangeFull(lyx::pos_type pos, Change change)
+{
+       pimpl_->setChangeFull(pos, change);
+}
+
+
 void Paragraph::markErased(bool erased)
 {
        pimpl_->markErased(erased);