mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix off by one error when finding closest line number for an element
This commit is contained in:
parent
c344aaca7e
commit
d5096c09b6
@ -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):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user