mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
TextBoxWidget: fix crash on hold after end of text (#5689)
This commit is contained in:
@@ -1744,6 +1744,15 @@ function TextBoxWidget:onHoldReleaseText(callback, ges)
|
||||
if sel_start_idx > sel_end_idx then -- re-order if needed
|
||||
sel_start_idx, sel_end_idx = sel_end_idx, sel_start_idx
|
||||
end
|
||||
-- We get cursor positions, which can be after last char,
|
||||
-- and that we need to correct. But if both positions are
|
||||
-- after last char, the full selection is out of text.
|
||||
if sel_start_idx > #self._xtext then -- Both are after last char
|
||||
return true
|
||||
end
|
||||
if sel_end_idx > #self._xtext then -- Only end is after last char
|
||||
sel_end_idx = #self._xtext
|
||||
end
|
||||
-- Delegate word boundaries search to xtext.cpp, which can
|
||||
-- use libunibreak's wordbreak features.
|
||||
-- (50 is the nb of chars backward and ahead of selection indices
|
||||
|
||||
Reference in New Issue
Block a user