equal
deleted
inserted
replaced
323 |
323 |
324 def findlines(self, l, linenum): |
324 def findlines(self, l, linenum): |
325 # looks through the hash and finds candidate lines. The |
325 # looks through the hash and finds candidate lines. The |
326 # result is a list of line numbers sorted based on distance |
326 # result is a list of line numbers sorted based on distance |
327 # from linenum |
327 # from linenum |
328 def sorter(a, b): |
|
329 vala = abs(a - linenum) |
|
330 valb = abs(b - linenum) |
|
331 return cmp(vala, valb) |
|
332 |
328 |
333 try: |
329 try: |
334 cand = self.hash[l] |
330 cand = self.hash[l] |
335 except: |
331 except: |
336 return [] |
332 return [] |
337 |
333 |
338 if len(cand) > 1: |
334 if len(cand) > 1: |
339 # resort our list of potentials forward then back. |
335 # resort our list of potentials forward then back. |
340 cand.sort(sorter) |
336 cand.sort(key=lambda x: abs(x - linenum)) |
341 return cand |
337 return cand |
342 |
338 |
343 def hashlines(self): |
339 def hashlines(self): |
344 self.hash = {} |
340 self.hash = {} |
345 for x, s in enumerate(self.lines): |
341 for x, s in enumerate(self.lines): |