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):
'Find rightmost value in a less than or equal to x'
i = bisect_right(a, x)
if i:
return a[i-1]
raise ValueError
try:
return a[bisect_right(a, x)]
except IndexError:
return a[-1]
class WebPage(QWebPage):