From e892be548eaab7ffd8dba4e84a2a069659e718c0 Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 16 Sep 2019 20:53:22 +0000 Subject: [PATCH] RichEdit: PasteText added text normalization git-svn-id: svn://ultimatepp.org/upp/trunk@13607 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/RichEdit/Modify.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/uppsrc/RichEdit/Modify.cpp b/uppsrc/RichEdit/Modify.cpp index 28cc90b4b..707c34d9f 100644 --- a/uppsrc/RichEdit/Modify.cpp +++ b/uppsrc/RichEdit/Modify.cpp @@ -301,9 +301,19 @@ void RichEdit::PasteText(const RichText& text) SetModify(); modified = true; RemoveSelection(); - Insert(cursor, text, false); - ReadStyles(); - Move(cursor + text.GetLength(), false); + int n = text.GetPartCount() - 1; + if(!text.IsPara(0) || !text.IsPara(n)) { // inserted section must start/end with para + RichText pp = clone(text); + pp.Normalize(); + Insert(cursor, pp, false); + ReadStyles(); + Move(cursor + pp.GetLength(), false); + } + else { + Insert(cursor, text, false); + ReadStyles(); + Move(cursor + text.GetLength(), false); + } } struct ToParaIterator : RichText::Iterator {