Le 05/03/2016 17:54, Scott Kostyshak a écrit :
I can reproduce the following on master but not in 2.1.x:

1. open mwe.21.lyx
2. place the cursor just to the right of the character "4"
3. press ctrl + return

On master, the cursor does not go to the position where the next letter
will be drawn.

Does this patch fix the problem for you? I had to add explicit tests for some inset codes, but that will be OK for now. The problem is that we allow putting the cursor on the row preceding display math, but not after a newline inset. I plan to rewrite part of this code in 2.3 anyway.

JMarc



>From d810627b1c412402f2b54097233e6dd275165802 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Sun, 6 Mar 2016 15:29:25 +0100
Subject: [PATCH] Do not set cursor to the right of newline with mouse

When a row is broken by for example a display math inset, it is possible to put the cursor at the end of the previous line using the boundary setting of cursor.

For newline insets and separator insets, we want to force the cursor to be before
this inset.
---
 src/TextMetrics.cpp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 03467fa..ad5d9ca 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -1154,9 +1154,14 @@ pos_type TextMetrics::getPosNearX(Row const & row, int & x,
 	 * row is larger than the end of its last element.
 	 */
 	if (!row.empty() && pos == row.back().endpos
-	    && row.back().endpos == row.endpos())
-		boundary = true;
-
+	    && row.back().endpos == row.endpos()) {
+		Inset const * inset = row.back().inset;
+		if (inset && (inset->lyxCode() == NEWLINE_CODE
+		              || inset->lyxCode() == SEPARATOR_CODE))
+			pos = row.back().pos;
+		else
+			boundary = true;
+	}
 	x += xo;
 	//LYXERR0("getPosNearX ==> pos=" << pos << ", boundary=" << boundary);
 	return pos;
-- 
2.5.0

Reply via email to