Editor: Highlight cmake configure_file input files

Usually cmake configure input files have the *.in suffix, so if we can
not find highlight definitions for a filename and it has the .in suffix
try again without that suffix.

Fixes: QTCREATORBUG-24465
Change-Id: I7a132eb407c299eb1670e89e2d043a924aed1ede
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
David Schulz
2020-09-25 08:08:19 +02:00
parent c8d565563d
commit 62e7d7eb49

View File

@@ -125,13 +125,23 @@ Highlighter::Definitions Highlighter::definitionsForDocument(const TextDocument
// If we check the MIME type first and then skip the pattern, the definition for "*.rb.xml" is // If we check the MIME type first and then skip the pattern, the definition for "*.rb.xml" is
// never considered. // never considered.
// The KSyntaxHighlighting CLI also completely ignores MIME types. // The KSyntaxHighlighting CLI also completely ignores MIME types.
const Definitions &fileNameDefinitions = definitionsForFileName(document->filePath()); const Utils::FilePath &filePath = document->filePath();
if (!fileNameDefinitions.isEmpty()) Definitions definitions = definitionsForFileName(filePath);
return fileNameDefinitions; if (definitions.isEmpty()) {
const Utils::MimeType &mimeType = Utils::mimeTypeForName(document->mimeType()); // check for *.in filename since those are usually used for
if (!mimeType.isValid()) // cmake configure_file input filenames without the .in extension
return fileNameDefinitions; if (filePath.endsWith(".in")) {
return definitionsForMimeType(mimeType.name()); definitions = definitionsForFileName(
Utils::FilePath::fromString(filePath.toFileInfo().completeBaseName()));
}
}
if (definitions.isEmpty()) {
const Utils::MimeType &mimeType = Utils::mimeTypeForName(document->mimeType());
if (mimeType.isValid())
definitions = definitionsForMimeType(mimeType.name());
}
return definitions;
} }
static Highlighter::Definition definitionForSetting(const QString &settingsKey, static Highlighter::Definition definitionForSetting(const QString &settingsKey,