http://bugzilla.lyx.org/show_bug.cgi?id=3625

Bug 3625 is about the fact that you can't copy text with leading spaces.
Ironically this is actively disabled by the following lines:

CutAndPaste.cpp:715-722
// copy behind a space if there is one
...
while (pos < pars[par].size() &&
       pars[par].isLineSeparator(pos) &&
       (par != cur.selEnd().pit() || pos < cur.selEnd().pos()))
            ++pos;

Why do we want to start copying text after a space ? Well, removing
these lines solves the bug.

In Buffer::insertStringAsLines we can allow leading spaces from other
applications by initializing the space_inserted variable differently.

Vincent
Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp	(revision 26708)
+++ src/Buffer.cpp	(working copy)
@@ -593,8 +593,8 @@
 {
 	Font font = fn;
 
 	// insert the string, don't insert doublespace
-	bool space_inserted = true;
+	bool space_inserted = false;
 	for (docstring::const_iterator cit = str.begin();
 	    cit != str.end(); ++cit) {
 		Paragraph & par = pars[pit];
Index: src/CutAndPaste.cpp
===================================================================
--- src/CutAndPaste.cpp	(revision 26708)
+++ src/CutAndPaste.cpp	(working copy)
@@ -705,14 +705,9 @@
 		// ok we have a selection. This is always between cur.selBegin()
 		// and sel_end cursor
 
-		// copy behind a space if there is one
 		ParagraphList & pars = text->paragraphs();
 		pos_type pos = cur.selBegin().pos();
 		pit_type par = cur.selBegin().pit();
-		while (pos < pars[par].size() &&
-		       pars[par].isLineSeparator(pos) &&
-		       (par != cur.selEnd().pit() || pos < cur.selEnd().pos()))
-			++pos;
 
 		copySelectionHelper(cur.buffer(), pars, par, cur.selEnd().pit(),
 			pos, cur.selEnd().pos(), 

Reply via email to