Fix off by one error when finding closest line number for an element

This commit is contained in:
Kovid Goyal 2013-12-04 17:52:38 +05:30
parent c344aaca7e
commit d5096c09b6

View File

@ -266,10 +266,10 @@ def uniq(vals):
def find_le(a, x): def find_le(a, x):
'Find rightmost value in a less than or equal to x' 'Find rightmost value in a less than or equal to x'
i = bisect_right(a, x) try:
if i: return a[bisect_right(a, x)]
return a[i-1] except IndexError:
raise ValueError return a[-1]
class WebPage(QWebPage): class WebPage(QWebPage):