diff options
author | Ash Searle <ash@hexmen.com> | 2016-09-02 14:50:53 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2019-11-29 05:54:20 +0100 |
commit | 48e55050f8bec34d57a1a86e06e779c6288b8341 (patch) | |
tree | 98ea4b3cef315cf3c67675a131bb5feb1c7398e6 | |
parent | a01c60f15011e7bc945811f548bb0bbe701d6437 (diff) | |
download | pygments-git-48e55050f8bec34d57a1a86e06e779c6288b8341.tar.gz |
Fix issue #1264: tweak patterns for regex and double-quoted strings for performance, avoiding slow back-tracking
-rw-r--r-- | pygments/lexers/textedit.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pygments/lexers/textedit.py b/pygments/lexers/textedit.py index 66b36924..3c6fb570 100644 --- a/pygments/lexers/textedit.py +++ b/pygments/lexers/textedit.py @@ -102,9 +102,9 @@ class VimLexer(RegexLexer): (r'[ \t]+', Text), # TODO: regexes can have other delims - (r'/(\\\\|\\/|[^\n/])*/', String.Regex), - (r'"(\\\\|\\"|[^\n"])*"', String.Double), - (r"'(''|[^\n'])*'", String.Single), + (r'/[^/\\\n]*(?:\\[\s\S][^/\\\n]*)*/', String.Regex), + (r'"[^"\\\n]*(?:\\[\s\S][^"\\\n]*)*"', String.Double), + (r"'[^\n']*(?:''[^\n']*)*'", String.Single), # Who decided that doublequote was a good comment character?? (r'(?<=\s)"[^\-:.%#=*].*', Comment), |