Adjust limits used for at_current() loop

This commit is contained in:
Kovid Goyal 2020-08-13 13:54:48 +05:30
parent bca1ef5767
commit 603b9b70ff
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -821,20 +821,16 @@ def at_point(x, y): # {{{
# }}}
def at_current(): # {{{
wini, winb = scroll_viewport.inline_size(), scroll_viewport.block_size()
# We subtract one because the the actual position query for CFI elements is relative to the
# We subtract one because the actual position query for CFI elements is relative to the
# viewport, and the viewport coordinates actually go from 0 to the size - 1.
# If we don't do this, the first line of queries will always fail in those cases where we
# start at the right of the viewport because they'll be outside the viewport
wini -= 1
winb -= 1
wini, winb = scroll_viewport.inline_size() - 1, scroll_viewport.block_size() - 1
# Don't let the deltas go below 10 or above 30, to prevent perverse cases where
# Don't let the deltas go too small or too large, to prevent perverse cases where
# we don't loop at all, loop too many times, or skip elements because we're
# looping too fast.
deltai = min(max(Math.ceil(rem_size() / 2), 5), 30)
deltab = min(max(Math.ceil(rem_size() / 2), 5), 30)
deltai = deltab = max(8, min(Math.ceil(rem_size() / 2), 32))
# i.e. English, Hebrew:
if scroll_viewport.horizontal_writing_mode: