From 86507cbe9fe0a12668b8a66003e2b0d7b482850e Mon Sep 17 00:00:00 2001 From: Mike Skec Date: Sat, 6 Mar 2021 19:28:55 +1100 Subject: Fix #186: screwed line endings in copied text --- src/widgets/kristalltextbrowser.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/widgets/kristalltextbrowser.cpp') diff --git a/src/widgets/kristalltextbrowser.cpp b/src/widgets/kristalltextbrowser.cpp index b00a870..67e7976 100644 --- a/src/widgets/kristalltextbrowser.cpp +++ b/src/widgets/kristalltextbrowser.cpp @@ -141,5 +141,15 @@ void KristallTextBrowser::betterCopy() static const QRegularExpression REGEX_QUOTES_D("(“|”)"), REGEX_QUOTES_S("(‘|’)"); text.replace(REGEX_QUOTES_D, "\"").replace(REGEX_QUOTES_S, "'"); + // From docs: + // "If the selection obtained from an editor spans a line break, the text will + // contain a Unicode U+2029 paragraph separator character instead of a newline \n character" + // Hence, we replace with \r\n on Win$hit, and \n on all other platforms +#ifdef Q_OS_WIN32 + text.replace(QChar(0x2029), "\r\n"); +#else + text.replace(QChar(0x2029), "\n"); +#endif + kristall::clipboard->setText(text); } -- cgit v1.2.3