Mercurial > hg-stable
changeset 6662:22c303a514f8
Truncate input to 1K when using pygments guess_lexer.
This function appears to be exponential with input length.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Thu, 12 Jun 2008 00:11:09 -0700 |
parents | 7f0dd352fb4d |
children | 73f49bef13ad 782dbbdfb1d7 |
files | hgext/highlight.py |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/highlight.py Wed May 07 14:32:00 2008 +0400 +++ b/hgext/highlight.py Thu Jun 12 00:11:09 2008 -0700 @@ -57,11 +57,11 @@ style = self.config("web", "pygments_style", "colorful") # To get multi-line strings right, we can't format line-by-line try: - lexer = guess_lexer_for_filename(fctx.path(), text, + lexer = guess_lexer_for_filename(fctx.path(), text[:1024], encoding=util._encoding) except (ClassNotFound, ValueError): try: - lexer = guess_lexer(text, encoding=util._encoding) + lexer = guess_lexer(text[:1024], encoding=util._encoding) except (ClassNotFound, ValueError): lexer = TextLexer(encoding=util._encoding)