aboutsummaryrefslogtreecommitdiff
path: root/src/widgets/kristalltextbrowser.cpp
diff options
context:
space:
mode:
authorMike Skec <skec@protonmail.ch>2021-03-06 19:28:55 +1100
committerFelix Queißner <felix@ib-queissner.de>2021-03-06 10:19:34 +0100
commit86507cbe9fe0a12668b8a66003e2b0d7b482850e (patch)
tree01ec60bce686056361b41d0ad4ae4db9fb46fe16 /src/widgets/kristalltextbrowser.cpp
parent51c00f7a01dad2cd3ff5f9f830285aaef7678499 (diff)
downloadkristall-86507cbe9fe0a12668b8a66003e2b0d7b482850e.tar.gz
Fix #186: screwed line endings in copied text
Diffstat (limited to 'src/widgets/kristalltextbrowser.cpp')
-rw-r--r--src/widgets/kristalltextbrowser.cpp10
1 files changed, 10 insertions, 0 deletions
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);
}