summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Aglassinger <roskakori@users.sourceforge.net>2016-10-01 07:02:07 +0200
committerThomas Aglassinger <roskakori@users.sourceforge.net>2016-10-01 07:02:07 +0200
commit4556c61f294ce11b744876aa36be12ace565b263 (patch)
tree68e07092b82dce1a2acd4c511d87a9a15ee83c55
parent56e75b33d66738b072f9f5525f3af4a8ba863d8b (diff)
downloadpygments-4556c61f294ce11b744876aa36be12ace565b263.tar.gz
Changed find_lexer_class_for_filename() to use the lexer name as secondary criteria when sorting for rating. This ensures that even when multiple lexers return the same rating the same lexer wins. Before the lexer with the lowest hashcode in the LEXERS dictionary won, which could return different results between repeated invocations of Python. This also fixes issue #1284.
-rw-r--r--pygments/lexers/__init__.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/pygments/lexers/__init__.py b/pygments/lexers/__init__.py
index d64f163f..0bd799e1 100644
--- a/pygments/lexers/__init__.py
+++ b/pygments/lexers/__init__.py
@@ -149,8 +149,8 @@ def find_lexer_class_for_filename(_fn, code=None):
# gets turned into 0.0. Run scripts/detect_missing_analyse_text.py
# to find lexers which need it overridden.
if code:
- return cls.analyse_text(code) + bonus
- return cls.priority + bonus
+ return cls.analyse_text(code) + bonus, cls.__name__
+ return cls.priority + bonus, cls.__name__
if matches:
matches.sort(key=get_rating)