From 4a24f4cbe6f82fa8f37ba7b8d60b1f5188636a1d Mon Sep 17 00:00:00 2001 From: "masayuki%d-toybox.com" Date: Fri, 25 Mar 2005 16:37:14 +0000 Subject: [PATCH] Bug 286804 Newline improperly getting into single-line edit field. r=timeless, sr=neil.parkwaycc.co.uk --- editor/libeditor/text/nsTextEditRules.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/editor/libeditor/text/nsTextEditRules.cpp b/editor/libeditor/text/nsTextEditRules.cpp index 641211c5709..1d7dc9a173f 100644 --- a/editor/libeditor/text/nsTextEditRules.cpp +++ b/editor/libeditor/text/nsTextEditRules.cpp @@ -592,8 +592,18 @@ nsTextEditRules::WillInsertText(PRInt32 aAction, else if (singleLineNewlineBehavior == ePasteFirstLine) { PRInt32 firstCRLF = tString.FindCharInSet(CRLF); + + // we get first *non-empty* line. + PRInt32 offset = 0; + while (firstCRLF == offset) + { + offset++; + firstCRLF = tString.FindCharInSet(CRLF, offset); + } if (firstCRLF > 0) tString.Truncate(firstCRLF); + if (offset > 0) + tString.Cut(0, offset); } else if (singleLineNewlineBehavior == eReplaceWithCommas) {