]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph_pimpl.C
Updates from Bennett and myself.
[lyx.git] / src / paragraph_pimpl.C
index ce44bf2968af07d391383a602972e70459741935..aad1f2bb493aac4199acaaaf8d132be966689a6f 100644 (file)
@@ -87,6 +87,19 @@ bool Paragraph::Pimpl::isChanged(pos_type start, pos_type end) const
 }
 
 
+bool Paragraph::Pimpl::isMergedOnEndOfParDeletion(bool trackChanges) const {
+       // keep the logic here in sync with the logic of eraseChars()
+
+       if (!trackChanges) {
+               return true;
+       }
+
+       Change change = changes_.lookup(size());
+
+       return change.type == Change::INSERTED && change.author == 0;
+}
+
+
 void Paragraph::Pimpl::setChange(Change const & change)
 {
        // beware of the imaginary end-of-par character!
@@ -263,6 +276,8 @@ bool Paragraph::Pimpl::eraseChar(pos_type pos, bool trackChanges)
 {
        BOOST_ASSERT(pos >= 0 && pos <= size());
 
+       // keep the logic here in sync with the logic of isMergedOnEndOfParDeletion()
+
        if (trackChanges) {
                Change change = changes_.lookup(pos);
 
@@ -280,10 +295,10 @@ bool Paragraph::Pimpl::eraseChar(pos_type pos, bool trackChanges)
                        return false;
        }
 
-       // Don't physically access nonexistent end-of-paragraph char
+       // Don't physically access the imaginary end-of-paragraph character.
+       // eraseChar() can only mark it as DELETED. A physical deletion of
+       // end-of-par must be handled externally.
        if (pos == size()) {
-               // FIXME: change tracking (MG)
-               // how do we handle end-of-pars previously marked inserted?
                return false;
        }
 
@@ -337,7 +352,7 @@ bool Paragraph::Pimpl::eraseChar(pos_type pos, bool trackChanges)
 int Paragraph::Pimpl::eraseChars(pos_type start, pos_type end, bool trackChanges)
 {
        BOOST_ASSERT(start >= 0 && start <= size());
-       BOOST_ASSERT(end > start && end <= size() + 1);
+       BOOST_ASSERT(end >= start && end <= size() + 1);
 
        pos_type i = start;
        for (pos_type count = end - start; count; --count) {