Juergen Spitzmueller wrote:
> Attached is a patch that fixes the crash for me, but I'm not sure it
> produces the behaviour we want (delete the empty paragraph, which is
> inconsistent to what LFUN_LEFTSEL does in this case).

attached is the proper fix, IMO.
selHandle has to be used, because it makes sure that the selection is properly 
set, which was not the case without that method. That's why DEPM was 
erroneously triggered.

This patch also fixes bug 2119 (Selection of text via keyboard sometimes 
fails) and bug 2259 (screen-up/down-select do not work).

Too late for 1.4.2?

Jürgen
Index: src/text3.C
===================================================================
--- src/text3.C	(Revision 14351)
+++ src/text3.C	(Arbeitskopie)
@@ -396,8 +396,7 @@ void LyXText::dispatch(LCursor & cur, Fu
 
 	case LFUN_BEGINNINGBUFSEL:
 		if (cur.depth() == 1) {
-			if (!cur.selection())
-				cur.resetAnchor();
+			cur.selHandle(cmd.action == LFUN_BEGINNINGBUFSEL);
 			needsUpdate = cursorTop(cur);
 			finishChange(cur, true);
 		} else {
@@ -418,8 +417,7 @@ void LyXText::dispatch(LCursor & cur, Fu
 
 	case LFUN_ENDBUFSEL:
 		if (cur.depth() == 1) {
-			if (!cur.selection())
-				cur.resetAnchor();
+			cur.selHandle(cmd.action == LFUN_ENDBUFSEL);
 			needsUpdate = cursorBottom(cur);
 			finishChange(cur, true);
 		} else {
@@ -496,8 +494,7 @@ void LyXText::dispatch(LCursor & cur, Fu
 		break;
 
 	case LFUN_UP_PARAGRAPHSEL:
-		if (!cur.selection())
-			cur.resetAnchor();
+		cur.selHandle(cmd.action == LFUN_UP_PARAGRAPHSEL);
 		cursorUpParagraph(cur);
 		finishChange(cur, true);
 		break;
@@ -510,47 +507,41 @@ void LyXText::dispatch(LCursor & cur, Fu
 		break;
 
 	case LFUN_DOWN_PARAGRAPHSEL:
-		if (!cur.selection())
-			cur.resetAnchor();
+		cur.selHandle(cmd.action == LFUN_DOWN_PARAGRAPHSEL);
 		cursorDownParagraph(cur);
 		finishChange(cur, true);
 		break;
 
 	case LFUN_PRIORSEL:
 		update(cur);
-		if (!cur.selection())
-			cur.resetAnchor();
+		cur.selHandle(cmd.action == LFUN_PRIORSEL);
 		needsUpdate = cursorPrevious(cur);
 		finishChange(cur, true);
 		break;
 
 	case LFUN_NEXTSEL:
 		update(cur);
-		if (!cur.selection())
-			cur.resetAnchor();
+		cur.selHandle(cmd.action == LFUN_NEXTSEL);
 		needsUpdate = cursorNext(cur);
 		finishChange(cur, true);
 		break;
 
 	case LFUN_HOMESEL:
 		update(cur);
-		if (!cur.selection())
-			cur.resetAnchor();
+		cur.selHandle(cmd.action == LFUN_HOMESEL);
 		needsUpdate = cursorHome(cur);
 		finishChange(cur, true);
 		break;
 
 	case LFUN_ENDSEL:
 		update(cur);
-		if (!cur.selection())
-			cur.resetAnchor();
+		cur.selHandle(cmd.action == LFUN_ENDSEL);
 		needsUpdate = cursorEnd(cur);
 		finishChange(cur, true);
 		break;
 
 	case LFUN_WORDRIGHTSEL:
-		if (!cur.selection())
-			cur.resetAnchor();
+		cur.selHandle(cmd.action == LFUN_WORDRIGHTSEL);
 		if (isRTL(cur.paragraph()))
 			cursorLeftOneWord(cur);
 		else
@@ -559,8 +550,7 @@ void LyXText::dispatch(LCursor & cur, Fu
 		break;
 
 	case LFUN_WORDLEFTSEL:
-		if (!cur.selection())
-			cur.resetAnchor();
+		cur.selHandle(cmd.action == LFUN_WORDLEFTSEL);
 		if (isRTL(cur.paragraph()))
 			cursorRightOneWord(cur);
 		else

Reply via email to