Juergen Spitzmueller wrote:
> What about the attached?

This one is better (using rsplit, in case there are several \n's involved).

Jürgen
Index: src/paragraph.C
===================================================================
--- src/paragraph.C	(Revision 16163)
+++ src/paragraph.C	(Arbeitskopie)
@@ -55,6 +55,8 @@
 
 using lyx::pos_type;
 
+using lyx::support::contains;
+using lyx::support::rsplit;
 using lyx::support::subst;
 
 using std::distance;
@@ -735,6 +737,17 @@ string const corrected_env(string const 
 	return output;
 }
 
+
+int adjust_column_count(string const & str, int oldcol)
+{
+	if (!contains(str, "\n"))
+		return oldcol + str.size();
+	else {
+		string tmp;
+		return rsplit(str, tmp, '\n').size();
+	}
+}
+
 } // namespace anon
 
 
@@ -778,7 +791,7 @@ int Paragraph::startTeXParParams(BufferP
 		else
 			output = corrected_env("\\begin", "flushright", ownerCode());
 		os << output;
-		column += output.size();
+		column = adjust_column_count(output, column);
 		break;
 	} case LYX_ALIGN_RIGHT: {
 		string output;
@@ -787,13 +800,13 @@ int Paragraph::startTeXParParams(BufferP
 		else
 			output = corrected_env("\\begin", "flushleft", ownerCode());
 		os << output;
-		column += output.size();
+		column = adjust_column_count(output, column);
 		break;
 	} case LYX_ALIGN_CENTER: {
 		string output;
 		output = corrected_env("\\begin", "center", ownerCode());
 		os << output;
-		column += output.size();
+		column = adjust_column_count(output, column);
 		break;
 	}
 	}
@@ -837,7 +850,7 @@ int Paragraph::endTeXParParams(BufferPar
 		else
 			output = corrected_env("\n\\par\\end", "flushright", ownerCode());
 		os << output;
-		column += output.size();
+		column = adjust_column_count(output, column);
 		break;
 	} case LYX_ALIGN_RIGHT: {
 		string output;
@@ -846,13 +859,13 @@ int Paragraph::endTeXParParams(BufferPar
 		else
 			output = corrected_env("\n\\par\\end", "flushleft", ownerCode());
 		os << output;
-		column += output.size();
+		column = adjust_column_count(output, column);
 		break;
 	} case LYX_ALIGN_CENTER: {
 		string output;
 		output = corrected_env("\n\\par\\end", "center", ownerCode());
 		os << output;
-		column += output.size();
+		column = adjust_column_count(output, column);
 		break;
 	}
 	}

Reply via email to