Fix highlighting of debugger disassembly view

The disassembly view uses a custom MIME type that derives from x-asm,
but that didn't trigger highlighting.

Make the generic highlighter look at the parent MIME types if no
highlighting was found for the MIME type itself.

Generalize this "go breadth-first through the parents" that was already
used for resolving editor factories.

Change-Id: Ia054058a8c06b9d8849384e79ee3b83fbc12279c
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2023-01-03 11:54:05 +01:00
parent 15fa9e7096
commit b41abc94bb
4 changed files with 49 additions and 30 deletions

View File

@@ -120,13 +120,16 @@ Highlighter::Definitions Highlighter::definitionsForDocument(const TextDocument
if (definitions.isEmpty()) {
const MimeType &mimeType = Utils::mimeTypeForName(document->mimeType());
if (mimeType.isValid()) {
// 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;
}
Utils::visitMimeParents(mimeType, [&](const MimeType &mt) -> bool {
// highlight definitions might not use the canonical name but an alias
const QStringList names = QStringList(mt.name()) + mt.aliases();
for (const QString &name : names) {
definitions = definitionsForMimeType(name);
if (!definitions.isEmpty())
return false; // stop
}
return true; // continue
});
}
}