Commits

Anonymous committed 47ea9a7

codeanalyze: using get_primary_range() in get_primary_at()

  • Participants
  • Parent commits 5649f02

Comments (0)

Files changed (1)

File rope/base/codeanalyze.py

 
     def get_primary_at(self, offset):
         offset = self._get_fixed_offset(offset)
-        return self.source[self._find_primary_start(offset):
-                           self._find_word_end(offset) + 1].strip()
+        start, end = self.get_primary_range(offset)
+        return self.source[start:end].strip()
 
     def get_splitted_primary_before(self, offset):
         """returns expression, starting, starting_offset
         return operation
 
     def get_primary_range(self, offset):
-        offset = max(0, offset)
         start = self._find_primary_start(offset)
         end = self._find_word_end(offset) + 1
         return (start, end)