Convert text model to CR+LF when saving

Thu, 14 Jul 2022 16:47:59 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Thu, 14 Jul 2022 16:47:59 +0300
changeset 334
083b0d8e220a
parent 333
07e65a4c6611
child 335
c5830bce1c23

Convert text model to CR+LF when saving

src/documentmanager.cpp file | annotate | diff | comparison | revisions
--- a/src/documentmanager.cpp	Mon Jul 04 19:53:13 2022 +0300
+++ b/src/documentmanager.cpp	Thu Jul 14 16:47:59 2022 +0300
@@ -195,7 +195,7 @@
 		QSaveFile file{info->path};
 		file.setDirectWriteFallback(true);
 		if (file.open(QSaveFile::WriteOnly)) {
-			file.write(info->model->toPlainText().toUtf8());
+			file.write(info->model->toPlainText().replace("\n", "\r\n").toUtf8());
 			const bool commitSucceeded = file.commit();
 			if (not commitSucceeded) {
 				errors << QObject::tr("Could not save: %1").arg(file.errorString());

mercurial