summaryrefslogtreecommitdiff
path: root/mako/lexer.py
diff options
context:
space:
mode:
Diffstat (limited to 'mako/lexer.py')
-rw-r--r--mako/lexer.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/mako/lexer.py b/mako/lexer.py
index 527c4b5..c45e20e 100644
--- a/mako/lexer.py
+++ b/mako/lexer.py
@@ -74,12 +74,11 @@ class Lexer:
(start, end) = match.span()
self.match_position = end + 1 if end == start else end
self.matched_lineno = self.lineno
- lines = re.findall(r"\n", self.text[mp : self.match_position])
cp = mp - 1
- while cp >= 0 and cp < self.textlength and self.text[cp] != "\n":
- cp -= 1
+ if cp >= 0 and cp < self.textlength:
+ cp = self.text[: cp + 1].rfind("\n")
self.matched_charpos = mp - cp
- self.lineno += len(lines)
+ self.lineno += self.text[mp : self.match_position].count("\n")
return match
def parse_until_text(self, watch_nesting, *text):