Fix opening markdown files

In d2ae2c283d 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
remotes/origin/release/20.12
Albert Astals Cid 5 years ago
parent d112682611
commit 9e23338b00
  1. 6
      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;

Loading…
Cancel
Save