diff --git a/src/plugins/genericeditor/genericeditorplugin.cpp b/src/plugins/genericeditor/genericeditorplugin.cpp
index 68559976f57fe08d7666d108a4e98e9692431e1f..937171b0cccb92097e681ce3009ee6731306a3aa 100644
--- a/src/plugins/genericeditor/genericeditorplugin.cpp
+++ b/src/plugins/genericeditor/genericeditorplugin.cpp
@@ -30,7 +30,6 @@
 #include "genericeditorplugin.h"
 #include "highlightdefinition.h"
 #include "highlightdefinitionhandler.h"
-#include "highlighter.h"
 #include "highlighterexception.h"
 #include "genericeditorconstants.h"
 #include "editor.h"
@@ -127,7 +126,7 @@ QString GenericEditorPlugin::definitionIdByMimeType(const QString &mimeType) con
             candidateIds.append(it.value());
 
         qSort(candidateIds.begin(), candidateIds.end(), m_priorityComp);
-        return candidateIds.first();
+        return candidateIds.last();
     }
 }
 
@@ -216,8 +215,9 @@ void GenericEditorPlugin::parseDefinitionMetadata(const QFileInfo &fileInfo)
             }
 
             // The priority below should not be confused with the priority used when matching files
-            // to MIME types. This priority is for choosing a highlight definition when there are
-            // multiple ones associated with the same MIME type or file extensions/patterns.
+            // to MIME types. Kate uses this when there are definitions which share equal
+            // extensions/patterns. Here it is for choosing a highlight definition if there are
+            // multiple ones associated with the same MIME type (should not happen in general).
             m_priorityComp.m_priorityById.insert(id, attr.value(kPriority).toString().toInt());
 
             registerMimeTypes(name, mimeTypes, patterns);
@@ -237,7 +237,7 @@ void GenericEditorPlugin::registerMimeTypes(const QString &comment,
     // A definition can specify multiple MIME types and file extensions/patterns. However, each
     // thing is done with a single string. Then, there is no direct way to tell which extensions/
     // patterns belong to which MIME types nor whether a MIME type is just an alias for the other.
-    // Currently, I associate all expressions/patterns with all MIME types.
+    // Currentl y, I associate all expressions/patterns with all MIME types from a definition.
 
     QList<QRegExp> expressions;
     foreach (const QString &type, types) {
diff --git a/src/plugins/genericeditor/genericeditorplugin.h b/src/plugins/genericeditor/genericeditorplugin.h
index 7fa5393ac54157f7125fc8e8bafe8f3fe991d261..b00e14cd53b1fe903ee9b054a1b8f346d83b227d 100644
--- a/src/plugins/genericeditor/genericeditorplugin.h
+++ b/src/plugins/genericeditor/genericeditorplugin.h
@@ -90,7 +90,7 @@ private:
 
     struct PriorityCompare
     {
-        bool operator()(const QString &a, const QString &b)
+        bool operator()(const QString &a, const QString &b) const
         { return m_priorityById.value(a) < m_priorityById.value(b); }
 
         QHash<QString, int> m_priorityById;