Commits

Ali Gholami Rudi  committed 1853630

handling single-line scopes when they contain line breaks

  • Participants
  • Parent commits a87c79a

Comments (0)

Files changed (2)

File rope/base/pyscopes.py

         if not scope.parent:
             return self.lines.length()
         end = scope.pyobject.get_ast().body[-1].lineno
-        if end == scope.start:
+        scope_start = self.pymodule.logical_lines.logical_line_in(scope.start)
+        if scope_start[1] >= end:
             # handling one-liners
             body_indents = self._get_scope_indents(scope) + 4
         else:

File ropetest/codeanalyzetest.py

         pyname = name_finder.get_pyname_at(code.rindex('var'))
         self.assertEquals(pymod.get_attribute('var'), pyname)
 
-    # XXX: one-liners with line breaks
-    def xxx_test_one_liners_with_line_breaks(self):
+    def test_one_liners_with_line_breaks(self):
         code = 'var = 1\ndef f(\n): var = 2\nprint var\n'
         pymod = self.pycore.get_string_module(code)
         name_finder = rope.base.evaluate.ScopeNameFinder(pymod)