>>>>> "Joost" == Joost Verburg <[EMAIL PROTECTED]> writes:

Joost> Juergen Spitzmueller wrote:
>> But it's safer to have it (it was forgotten in the other cases,
>> probably by me).

Joost> Here is an updated patch to fix the table regressions.

I committed the cutSelection part (see cutsel.diff). The remaining
part is attached. Note that I changed the font-changing stuff to use a
temporary cursor so that there is no need to restore the original
selection. Does that seem reasonable?

Concerning the ascii paste part, the cursor should have been updated
to point to the end of the inserted string. insertAsciiString really
needs a cleanup. In what cases do you get a crash?

Update patch attached.

JMarc

Index: src/insets/insettabular.C
===================================================================
--- src/insets/insettabular.C	(revision 15086)
+++ src/insets/insettabular.C	(working copy)
@@ -684,7 +684,10 @@ void InsetTabular::doDispatch(LCursor & 
 			if (insertAsciiString(cur.bv(), clip, false)) {
 				// content has been replaced,
 				// so cursor might be invalid
-				cur.pos() = cur.lastpos();
+				if (cur.pit() > cur.lastpit())
+					cur.pit() = cur.lastpit();
+				if (cur.pos() > cur.lastpos())
+					cur.pos() = cur.lastpos();
 				bvcur.setCursor(cur);
 				break;
 			}
@@ -731,24 +734,20 @@ void InsetTabular::doDispatch(LCursor & 
 			for (row_type i = rs; i <= re; ++i) {
 				for (col_type j = cs; j <= ce; ++j) {
 					// cursor follows cell:
-					cur.idx() = tabular.getCellNumber(i, j);
+					LCursor tmpcur = cur;
+					int cur;
+					tmpcur.idx() = tabular.getCellNumber(i, j);
 					// select this cell only:
-					cur.pos() = 0;
-					cur.resetAnchor();
-					cur.pos() = cur.top().lastpos();
-					cur.setCursor(cur);
-					cur.setSelection();
-					cell(cur.idx())->dispatch(cur, cmd);
+					tmpcur.pit() = 0;
+					tmpcur.pos() = 0;
+					tmpcur.resetAnchor();
+					tmpcur.pit() = tmpcur.lastpit();
+					tmpcur.pos() = tmpcur.top().lastpos();
+					tmpcur.setCursor(tmpcur);
+					tmpcur.setSelection();
+					cell(tmpcur.idx())->dispatch(tmpcur, cmd);
 				}
 			}
-			// Restore original selection
-			cur.idx() = tabular.getCellNumber(rs, cs);
-			cur.pos() = 0;
-			cur.resetAnchor();
-			cur.idx() = tabular.getCellNumber(re, ce);
-			cur.pos() = cur.top().lastpos();
-			cur.setCursor(cur);
-			cur.setSelection();
 			break;
 		} else {
 			cell(cur.idx())->dispatch(cur, cmd);
Index: status.14x
===================================================================
--- status.14x	(revision 15086)
+++ status.14x	(working copy)
@@ -90,6 +90,8 @@ What's new
 
 - Fix a crash with change tracking in tables (bug 2600).
 
+- Fix a crash when deleting a multi-cell selection in a tabular.
+
 - Fix a crash when undoing super/subscript deletion (bug 2727).
 
 - Fix a crash when the cursor is in an empty script and the user
Index: src/insets/insettabular.C
===================================================================
--- src/insets/insettabular.C	(revision 15086)
+++ src/insets/insettabular.C	(working copy)
@@ -1757,7 +1757,10 @@ void InsetTabular::cutSelection(LCursor 
 	}
 
 	// cursor position might be invalid now
-	cur.pos() = cur.lastpos();
+	if (cur.pit() > cur.lastpit())
+		cur.pit() = cur.lastpit();
+	if (cur.pos() > cur.lastpos())
+		cur.pos() = cur.lastpos();
 	cur.clearSelection();
 }
 
Index: src/insets/ChangeLog
===================================================================
--- src/insets/ChangeLog	(revision 15086)
+++ src/insets/ChangeLog	(working copy)
@@ -1,3 +1,7 @@
+2006-09-20  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* insettabular.C (cutSelection): reset cursor when it is invalid.
+
 2006-09-19  Jürgen Spitzmüller  <[EMAIL PROTECTED]>
 
 	* insetert.C (doDispatch):

Reply via email to