1
0
forked from VimPlug/jedi

Nested list comprehensions seem to be working pretty well.

This commit is contained in:
Dave Halter
2014-11-12 12:30:59 +01:00
parent c326562c27
commit f760a7755d

View File

@@ -135,8 +135,17 @@ class Comprehension(IterableWrapper):
[x + 1 for x in foo]
"""
comprehension = self._atom.children[1]
c = comprehension.children
return helpers.deep_ast_copy(c[0], {comprehension: c[1]})
# For nested comprehensions we need to search the last one.
last = comprehension.children[-1]
last_comp = comprehension.children[1]
while True:
if isinstance(last, pr.CompFor):
last_comp = last
elif not pr.is_node(last, 'comp_if'):
break
last = last.children[-1]
return helpers.deep_ast_copy(comprehension.children[0], {comprehension: last_comp})
def __repr__(self):
return "<e%s of %s>" % (type(self).__name__, self._atom)