From: Jean-Marc Lasgouttes [lasgout...@lyx.org]
Sent: Thursday, March 01, 2012 11:05 AM

>I would try to fix the actual place that modifies cursor, which is
>probably in findOne (lyxfind.cpp).

replaceOne is the function called.

What is the point of the following code in CutAndPaste.cpp's function 
replaceSelectionWithString:

        // select the replacement
        if (backwards) { 
                selbeg.pos() += str.length(); 
                cur.setSelection(selbeg, -int(str.length())); 
        } else
                cur.setSelection(selbeg, str.length());

cur.setSelection() is what is setting the selection in this case and I don't 
see why anything should be selected after the replacement. Applying the 
attached patch fixes the bug I described, but it must not be the right thing to 
do. I'm just not sure why. What goes wrong when this code is removed?

Thanks,

Scott
Index: src/CutAndPaste.cpp
===================================================================
--- src/CutAndPaste.cpp	(revision 40891)
+++ src/CutAndPaste.cpp	(working copy)
@@ -1131,13 +1131,6 @@
 
 	// Cut the selection
 	cutSelection(cur, true, false);
-
-	// select the replacement
-	if (backwards) {
-		selbeg.pos() += str.length();
-		cur.setSelection(selbeg, -int(str.length()));
-	} else
-		cur.setSelection(selbeg, str.length());
 }
 
 

Reply via email to