Show More
@@ -643,25 +643,23 b' class TransformerManager:' | |||||
643 | and tokens_by_line[-1][-1].type in newline_types: |
|
643 | and tokens_by_line[-1][-1].type in newline_types: | |
644 | tokens_by_line.pop() |
|
644 | tokens_by_line.pop() | |
645 |
|
645 | |||
646 | last_line_token = tokens_by_line[-1] |
|
|||
647 |
|
646 | |||
648 | while tokens_by_line[-1][-1].type in newline_types: |
|
647 | while tokens_by_line[-1] and tokens_by_line[-1][-1].type in newline_types: | |
649 |
|
|
648 | tokens_by_line[-1].pop() | |
650 |
|
649 | |||
651 |
if len( |
|
650 | if len(tokens_by_line) == 1 and not tokens_by_line[-1]: | |
652 | return 'incomplete', 0 |
|
651 | return 'incomplete', 0 | |
653 |
|
652 | |||
654 |
if |
|
653 | if tokens_by_line[-1][-1].string == ':': | |
655 | # The last line starts a block (e.g. 'if foo:') |
|
654 | # The last line starts a block (e.g. 'if foo:') | |
656 | ix = 0 |
|
655 | ix = 0 | |
657 | while last_line_token[ix].type \ |
|
656 | while tokens_by_line[-1][ix].type in {tokenize.INDENT, tokenize.DEDENT}: | |
658 | in {tokenize.INDENT, tokenize.DEDENT}: |
|
|||
659 | ix += 1 |
|
657 | ix += 1 | |
660 |
|
658 | |||
661 |
indent = |
|
659 | indent = tokens_by_line[-1][ix].start[1] | |
662 | return 'incomplete', indent + 4 |
|
660 | return 'incomplete', indent + 4 | |
663 |
|
661 | |||
664 |
if |
|
662 | if tokens_by_line[-1][0].line.endswith('\\'): | |
665 | return 'incomplete', None |
|
663 | return 'incomplete', None | |
666 |
|
664 | |||
667 | # At this point, our checks think the code is complete (or invalid). |
|
665 | # At this point, our checks think the code is complete (or invalid). | |
@@ -677,14 +675,18 b' class TransformerManager:' | |||||
677 | if res is None: |
|
675 | if res is None: | |
678 | return 'incomplete', find_last_indent(lines) |
|
676 | return 'incomplete', find_last_indent(lines) | |
679 |
|
677 | |||
680 |
if |
|
678 | if tokens_by_line[-1][-1].type == tokenize.DEDENT: | |
681 | if ends_with_newline: |
|
679 | if ends_with_newline: | |
682 | return 'complete', None |
|
680 | return 'complete', None | |
683 | return 'incomplete', find_last_indent(lines) |
|
681 | return 'incomplete', find_last_indent(lines) | |
684 |
|
682 | |||
685 |
if len( |
|
683 | if len(tokens_by_line[-1]) <= 1: | |
686 | return 'incomplete', find_last_indent(lines) |
|
684 | return 'incomplete', find_last_indent(lines) | |
687 |
|
685 | |||
|
686 | # If there's a blank line at the end, assume we're ready to execute | |||
|
687 | if not lines[-1].strip(): | |||
|
688 | return 'complete', None | |||
|
689 | ||||
688 | return 'complete', None |
|
690 | return 'complete', None | |
689 |
|
691 | |||
690 |
|
692 |
General Comments 0
You need to be logged in to leave comments.
Login now