forked from qt-creator/qt-creator
Generic highlighter: Try mime type aliases when looking for definitions
For example the yaml highlighting file declares text/yaml as the supported mime type, but that is not the canonical name, which is application/x-yaml. Change-Id: If9e3f5e31bc5593a82cbbdac916ef41b0d23de7c Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -119,8 +119,15 @@ Highlighter::Definitions Highlighter::definitionsForDocument(const TextDocument
|
|||||||
}
|
}
|
||||||
if (definitions.isEmpty()) {
|
if (definitions.isEmpty()) {
|
||||||
const MimeType &mimeType = Utils::mimeTypeForName(document->mimeType());
|
const MimeType &mimeType = Utils::mimeTypeForName(document->mimeType());
|
||||||
if (mimeType.isValid())
|
if (mimeType.isValid()) {
|
||||||
definitions = definitionsForMimeType(mimeType.name());
|
// highlight definitions might not use the canonical name but an alias
|
||||||
|
const QStringList names = QStringList(mimeType.name()) + mimeType.aliases();
|
||||||
|
for (const QString &name : names) {
|
||||||
|
definitions = definitionsForMimeType(name);
|
||||||
|
if (!definitions.isEmpty())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return definitions;
|
return definitions;
|
||||||
|
Reference in New Issue
Block a user