##// END OF EJS Templates
Some propose fixes....
Matthias Bussonnier -
Show More
@@ -418,6 +418,8 b' class HelpEnd(TokenTransformBase):'
418 lines_after = lines[self.q_line + 1:]
418 lines_after = lines[self.q_line + 1:]
419
419
420 m = _help_end_re.search(content)
420 m = _help_end_re.search(content)
421 if not m:
422 raise SyntaxError(content)
421 assert m is not None, content
423 assert m is not None, content
422 target = m.group(1)
424 target = m.group(1)
423 esc = m.group(3)
425 esc = m.group(3)
@@ -460,6 +462,8 b' def make_tokens_by_line(lines):'
460 except tokenize.TokenError:
462 except tokenize.TokenError:
461 # Input ended in a multiline string or expression. That's OK for us.
463 # Input ended in a multiline string or expression. That's OK for us.
462 pass
464 pass
465 if not tokens_by_line[-1]:
466 tokens_by_line.pop()
463
467
464 return tokens_by_line
468 return tokens_by_line
465
469
@@ -524,6 +528,9 b' class TransformerManager:'
524 return False, lines
528 return False, lines
525
529
526 transformer = min(candidates, key=TokenTransformBase.sortby)
530 transformer = min(candidates, key=TokenTransformBase.sortby)
531 transformed = transformer.transform(lines)
532 if transformed is None:
533 return False, lines
527 return True, transformer.transform(lines)
534 return True, transformer.transform(lines)
528
535
529 def do_token_transforms(self, lines):
536 def do_token_transforms(self, lines):
@@ -591,10 +598,13 b' class TransformerManager:'
591 return 'invalid', None
598 return 'invalid', None
592
599
593 tokens_by_line = make_tokens_by_line(lines)
600 tokens_by_line = make_tokens_by_line(lines)
601 if not tokens_by_line:
602 return 'incomplete', find_last_indent(lines)
594 if tokens_by_line[-1][-1].type != tokenize.ENDMARKER:
603 if tokens_by_line[-1][-1].type != tokenize.ENDMARKER:
595 # We're in a multiline string or expression
604 # We're in a multiline string or expression
596 return 'incomplete', find_last_indent(lines)
605 return 'incomplete', find_last_indent(lines)
597
606 if len(tokens_by_line) == 1:
607 return 'incomplete', find_last_indent(lines)
598 # Find the last token on the previous line that's not NEWLINE or COMMENT
608 # Find the last token on the previous line that's not NEWLINE or COMMENT
599 toks_last_line = tokens_by_line[-2]
609 toks_last_line = tokens_by_line[-2]
600 ix = len(toks_last_line) - 1
610 ix = len(toks_last_line) - 1
General Comments 0
You need to be logged in to leave comments. Login now