Use real lexer guessing for diffviewer syntax highlighting.
Review Request #7682 — Created Oct. 8, 2015 and submitted
Once upon a time, we used Pygments'
guess_lexer_for_filenamefor the diff
viewer. This turned out to be incredibly slow for large XML files, so we
switched it out for
get_lexer_for_filename, which just chooses the first (in
alphabetical order) lexer that matches the filename, rather than trying to
determine how appropriate that lexer actually is.
Since then, we've added multiple layers of caching in the diff viewer, a
maximum file size for syntax highlighting, and maximum sizes for uploaded
diffs, so we don't have to worry about parsing multi-megabyte XML files.
This change switches us back to the better lexer guessing.
Created a patch with an XML file that was problematically highlighted as an
"Evoque XML" file. Saw that it was rendered nicely.
Please, please, please now recognize my .m files as Matlab :)