From 9e23338b002cd14d8a9ad191526a7950e72d97e9 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Sun, 20 Dec 2020 00:46:29 +0100 Subject: [PATCH] Fix opening markdown files In d2ae2c283df3d42e72a964d8891e0915f8f3a94b we introduced a tweak that broke opening markdown files. what we really want is this: * If the mimetype from the filename is text (or children) but looking at the data says it's not text, then try opening first opening with the data suggeted mimetype * But if the data suggested mimetype says it's text, use the filename suggested mimetype since for example, the only way to really differentiate markdown from text is the filename, so trust that BUGS: 430538 --- part/part.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/part/part.cpp b/part/part.cpp index 536e412a4..8d57ed0d5 100644 --- a/part/part.cpp +++ b/part/part.cpp @@ -1473,8 +1473,10 @@ bool Part::openFile() } if (mimes[0].inherits(QStringLiteral("text/plain"))) { - QMimeType contentMime = db.mimeTypeForFile(fileNameToOpen, QMimeDatabase::MatchContent); - mimes.prepend(contentMime); + const QMimeType contentMime = db.mimeTypeForFile(fileNameToOpen, QMimeDatabase::MatchContent); + if (contentMime.name() != QLatin1String("text/plain")) { + mimes.prepend(contentMime); + } } } else { mimes << pathMime;