mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 14:34:31 +08:00
parentheses should be ignored when calculating the indent of a new block in the fast parser, fixes davidhalter/jedi-vim#288
This commit is contained in:
@@ -419,8 +419,11 @@ class FastTokenizer(object):
|
|||||||
self.closed = True
|
self.closed = True
|
||||||
raise common.MultiLevelStopIteration()
|
raise common.MultiLevelStopIteration()
|
||||||
|
|
||||||
# ignore comments/ newlines
|
# Ignore comments/newlines/closing parentheses, because they are all
|
||||||
if self.previous.type in (None, NEWLINE) and tok_type not in (COMMENT, NEWLINE):
|
# irrelevant for the indentation.
|
||||||
|
if self.previous.type in (None, NEWLINE) \
|
||||||
|
and tok_type not in (COMMENT, NEWLINE) \
|
||||||
|
and tok_str not in ')]}':
|
||||||
# print c, tok_name[c[0]]
|
# print c, tok_name[c[0]]
|
||||||
indent = current.start_pos[1]
|
indent = current.start_pos[1]
|
||||||
if indent < self.parser_indent: # -> dedent
|
if indent < self.parser_indent: # -> dedent
|
||||||
@@ -428,6 +431,7 @@ class FastTokenizer(object):
|
|||||||
self.new_indent = False
|
self.new_indent = False
|
||||||
if not self.in_flow or indent < self.old_parser_indent:
|
if not self.in_flow or indent < self.old_parser_indent:
|
||||||
close()
|
close()
|
||||||
|
|
||||||
self.in_flow = False
|
self.in_flow = False
|
||||||
elif self.new_indent:
|
elif self.new_indent:
|
||||||
self.parser_indent = indent
|
self.parser_indent = indent
|
||||||
@@ -438,6 +442,7 @@ class FastTokenizer(object):
|
|||||||
self.in_flow = tok_str in FLOWS
|
self.in_flow = tok_str in FLOWS
|
||||||
if not self.is_decorator and not self.in_flow:
|
if not self.is_decorator and not self.in_flow:
|
||||||
close()
|
close()
|
||||||
|
|
||||||
self.is_decorator = '@' == tok_str
|
self.is_decorator = '@' == tok_str
|
||||||
if not self.is_decorator:
|
if not self.is_decorator:
|
||||||
self.old_parser_indent = self.parser_indent
|
self.old_parser_indent = self.parser_indent
|
||||||
|
|||||||
@@ -3,7 +3,11 @@ Issues with the parser not the completion engine should be here.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
class C():
|
class C():
|
||||||
""" issue jedi-vim#288 """
|
"""
|
||||||
|
issue jedi-vim#288
|
||||||
|
Which is really a fast parser issue. It used to start a new block at the
|
||||||
|
parentheses, because it had problems with the indentation.
|
||||||
|
"""
|
||||||
def indent_issues(
|
def indent_issues(
|
||||||
self,
|
self,
|
||||||
):
|
):
|
||||||
|
|||||||
Reference in New Issue
Block a user