Jürgen Spitzmüller schreef:
Vincent van Ravesteijn wrote:
Can I start backporting the fixes for the following bugs:

5998, 2034, 2213, 3706, 3918, 4177, 4509, 4952, 5390, 5435, 5458, 5944,
5948 ?

Yes. Please post the patches subsequently.

Jürgen
Patch for bug 5435.

Vincent
Index: src/Text3.cpp
===================================================================
--- src/Text3.cpp       (revision 30512)
+++ src/Text3.cpp       (working copy)
@@ -569,6 +569,19 @@
                                && cur.boundary() == oldBoundary) {
                        cur.undispatched();
                        cmd = FuncRequest(LFUN_FINISHED_FORWARD);
+               
+                       // we will probably be moving out the inset, so we 
should execute
+                       // the depm-mechanism, but only when the cursor has a 
place to 
+                       // go outside this inset, i.e. in a slice above.
+                       if (cur.depth() > 1 && cur.pos() == cur.lastpos() 
+                                 && cur.pit() == cur.lastpit()) {
+                               // The cursor hasn't changed yet. To give the 
+                               // DEPM the possibility of doing something we 
must
+                               // provide it with two different cursors.
+                               Cursor dummy = cur;
+                               dummy.pos() = dummy.pit() = 0;
+                               cur.bv().checkDepm(dummy, cur);
+                       }
                }
                break;
 
@@ -582,6 +595,19 @@
                        && cur.boundary() == oldBoundary) {
                        cur.undispatched();
                        cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
+
+                       // we will probably be moving out the inset, so we 
should execute
+                       // the depm-mechanism, but only when the cursor has a 
place to 
+                       // go outside this inset, i.e. in a slice above.
+                       if (cur.depth() > 1 && cur.pos() == 0 && cur.pit() == 
0) {
+                               // The cursor hasn't changed yet. To give the 
+                               // DEPM the possibility of doing something we 
must
+                               // provide it with two different cursors.
+                               Cursor dummy = cur;
+                               dummy.pos() = cur.lastpos();
+                               dummy.pit() = cur.lastpit();
+                               cur.bv().checkDepm(dummy, cur);
+                       }
                }
                break;
 
Index: src/Cursor.cpp
===================================================================
--- src/Cursor.cpp      (revision 30512)
+++ src/Cursor.cpp      (working copy)
@@ -322,6 +322,15 @@
        // object will be used again.
        if (!disp_.dispatched()) {
                LYXERR(Debug::DEBUG, "RESTORING OLD CURSOR!");
+               // We might have invalidated the cursor when removing an empty
+               // paragraph while the cursor could not be moved out the inset
+               // while we initially thought we could. This might happen when
+               // a multiline inset becomes an inline inset when the second 
+               // paragraph is removed.
+               if (safe.pit() > safe.lastpit()) {
+                       safe.pit() = safe.lastpit();
+                       safe.pos() = safe.lastpos();
+               }
                operator=(safe);
                disp_.update(Update::None);
                disp_.dispatched(false);
@@ -1790,9 +1799,35 @@
                row = pm.pos2row(pos() - 1);
        else
                row = pm.pos2row(pos());
-               
-       if (atFirstOrLastRow(up))
+
+       if (atFirstOrLastRow(up)) {
+               // Is there a place for the cursor to go ? If yes, we
+               // can execute the DEPM, otherwise we should keep the
+               // paragraph to host the cursor.
+               Cursor dummy = *this;
+               bool valid_destination = false;
+               for(; dummy.depth(); dummy.pop())
+                       if (!dummy.atFirstOrLastRow(up)) {
+                               valid_destination = true;
+                               break;
+                       }
+
+               // will a next dispatch follow and if there is a new 
+               // dispatch will it move the cursor out ?
+               if (depth() > 1 && valid_destination) {
+                       // The cursor hasn't changed yet. This happens when
+                       // you e.g. move out of an inset. And to give the 
+                       // DEPM the possibility of doing something we must
+                       // provide it with two different cursors. (Lgb, vfr)
+                       dummy = *this;
+                       dummy.pos() = dummy.pos() == 0 ? dummy.lastpos() : 0;
+                       dummy.pit() = dummy.pit() == 0 ? dummy.lastpit() : 0;
+
+                       updateNeeded |= bv().checkDepm(dummy, *this);
+                       updateTextTargetOffset();
+               }       
                return false;
+       }
 
        // with and without selection are handled differently
        if (!selection()) {
Index: status.16x
===================================================================
--- status.16x  (revision 30513)
+++ status.16x  (working copy)
@@ -211,6 +211,8 @@
 - Do not open files during startup that were closed in the previous
   session by Close View or Close Window (bug 5458).
 
+- Remove empty paragraphs and superfluous spaces when leaving an inset
+  (bug 5435).
 
 * DOCUMENTATION AND LOCALIZATION
 

Reply via email to