From 442027541520630a3d470d8b604f4edbfc498081 Mon Sep 17 00:00:00 2001
From: Leandro Melo <leandro.melo@nokia.com>
Date: Thu, 6 May 2010 10:02:55 +0200
Subject: [PATCH] Need to get the highest priority, not the lowest; Minor
 changes.

---
 src/plugins/genericeditor/genericeditorplugin.cpp | 10 +++++-----
 src/plugins/genericeditor/genericeditorplugin.h   |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/plugins/genericeditor/genericeditorplugin.cpp b/src/plugins/genericeditor/genericeditorplugin.cpp
index 68559976f57..937171b0ccc 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 7fa5393ac54..b00e14cd53b 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;
-- 
GitLab