diff --git a/jedi/parser/fast.py b/jedi/parser/fast.py index 41f3a525..672b7202 100644 --- a/jedi/parser/fast.py +++ b/jedi/parser/fast.py @@ -489,7 +489,7 @@ class FastTokenizer(object): return current if value in ('def', 'class') and self._parentheses_level \ - and re.match('\n[ \t]*\Z', prefix): + and re.search(r'\n[ \t]*\Z', prefix): # Account for the fact that an open parentheses before a function # will reset the parentheses counter, but new lines before will # still be ignored. So check the prefix. diff --git a/test/test_parser/test_fast_parser.py b/test/test_parser/test_fast_parser.py index 7a524fab..7d0a5289 100644 --- a/test/test_parser/test_fast_parser.py +++ b/test/test_parser/test_fast_parser.py @@ -324,10 +324,10 @@ def test_wrong_indentation(): def test_open_parentheses(): func = 'def func():\n a' - p = FastParser(load_grammar(), 'isinstance(\n' + func) + p = FastParser(load_grammar(), 'isinstance(\n\n' + func) # As you can see, the isinstance call cannot be seen anymore after # get_code, because it isn't valid code. - assert p.module.get_code() == '\n' + func + assert p.module.get_code() == '\n\n' + func assert p.number_of_splits == 2 assert p.number_parsers_used == 2 cache.save_parser(None, None, p, pickling=False)