]> git.lyx.org Git - lyx.git/blobdiff - src/text.C
The bug-fix in revision 16531 introduced another bug. This is the right fix. I did...
[lyx.git] / src / text.C
index 10990823ba07992af8ec468a70949c9004b043c3..83eef76405db0bed7778559ffd0ee9a782f68aa6 100644 (file)
@@ -860,18 +860,25 @@ void LyXText::acceptChange(LCursor & cur)
        for (; pit <= et.pit(); ++pit) {
                pos_type left  = (pit == it.pit() ? it.pos() : 0);
                pos_type right = (pit == et.pit() ? et.pos() : pars_[pit].size());
-               pars_[pit].acceptChanges(left, right);
 
-               // merge paragraph if appropriate:
-               // if (right >= pars_[pit].size() && pit + 1 < et.pit() &&
-               //    pars_[pit].isDeleted(pars_[pit].size())) {
-               //      setCursorIntern(cur, pit + 1, 0);
-               //      backspacePos0(cur);
-               //}
+               // handle imaginary end-of-par character first
+               if (right == pars_[pit].size() && !pars_[pit].isUnchanged(right)) {
+                       if (pars_[pit].isInserted(right)) {
+                               pars_[pit].setChange(right, Change(Change::UNCHANGED));
+                       } else {
+                               // if (pit + 1 < et.pit()) {
+                               //      setCursorIntern(cur, pit + 1, 0);
+                               //      backspacePos0(cur);
+                               // }
+                       }
+               }
+
+               pars_[pit].acceptChanges(left, right);
        }
        finishUndo();
        cur.clearSelection();
-       setCursorIntern(cur, it.pit(), 0);
+       setCursorIntern(cur, it.pit(), it.pos());
+       cur.updateFlags(Update::Force);
 }
 
 
@@ -894,18 +901,25 @@ void LyXText::rejectChange(LCursor & cur)
        for (; pit <= et.pit(); ++pit) {
                pos_type left  = (pit == it.pit() ? it.pos() : 0);
                pos_type right = (pit == et.pit() ? et.pos() : pars_[pit].size());
-               pars_[pit].rejectChanges(left, right);
 
-               // merge paragraph if appropriate:      
-               // if (right >= pars_[pit].size() && pit + 1 < et.pit() &&
-               //    pars_[pit].isInserted(pars_[pit].size())) {
-               //      setCursorIntern(cur, pit + 1, 0);
-               //      backspacePos0(cur);
-               //}
+               // handle imaginary end-of-par character first
+               if (right == pars_[pit].size() && !pars_[pit].isUnchanged(right)) {
+                       if (pars_[pit].isDeleted(right)) {
+                               pars_[pit].setChange(right, Change(Change::UNCHANGED));
+                       } else {
+                               // if (pit + 1 < et.pit()) {
+                               //      setCursorIntern(cur, pit + 1, 0);
+                               //      backspacePos0(cur);
+                               // }
+                       }
+               }
+               
+               pars_[pit].rejectChanges(left, right);
        }
        finishUndo();
        cur.clearSelection();
-       setCursorIntern(cur, it.pit(), 0);
+       setCursorIntern(cur, it.pit(), it.pos());
+       cur.updateFlags(Update::Force);
 }