Anonymous avatar Anonymous committed 3c2ccdf

fixing finding from imported names in a multi-line parens

Comments (0)

Files changed (2)

rope/base/codeanalyze.py

         if offset >= len(self.source):
             return len(self.source)
         current_offset = offset
-        while current_offset < len(self.source) and\
-              self.source[current_offset] in ' \t\n':
-            while current_offset < len(self.source) and \
-                  self.source[current_offset] in ' \t\n':
-                current_offset += 1
+        while current_offset < len(self.source):
             if current_offset + 1 < len(self.source) and \
                self.source[current_offset] == '\\':
                 current_offset += 2
+            elif self.source[current_offset] in ' \t\n':
+                current_offset += 1
+            else:
+                break
         return current_offset
 
     def is_a_function_being_called(self, offset):
             from_names = from_import + 8
         except ValueError:
             return False
+        from_names = self._find_first_non_space_char(from_names)
         return self._find_import_pair_end(from_names) >= offset
 
     def is_from_statement_module(self, offset):

ropetest/codeanalyzetest.py

         word_finder = WordRangeFinder(code)
         self.assertTrue(word_finder.is_assigned_here(0))
 
+    def test_renaming_functions_with_from_import_and_parens2(self):
+        code = 'from mod import \\\n  (f,\n  g, h)\n'
+        word_finder = WordRangeFinder(code)
+        self.assertTrue(word_finder.is_from_statement(code.rindex('g')))
+
 
 class ScopeNameFinderTest(unittest.TestCase):
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.