TextBoxWidget: fix crash on hold after end of text (#5689)

pull/5691/head
poire-z 4 years ago committed by Frans de Jonge
parent 7d231acad0
commit ea67b9be77

@ -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

Loading…
Cancel
Save