if x == 0 and bpos == 0 then
assert(false, ("Infinite loop while line-wrapping. Editor is %dpx wide; window is %dpx wide"):format(State.width, App.screen.width))
end
-- Perform some early sanity checking here, in hopes that we correctly call
-- this whenever we change editor state.
if State.right <= State.left then
assert(false, ('Right margin %d must be to the right of the left margin %d'):format(State.right, State.left))
end
State.line_cache = {}
for i=1,#State.lines do
State.line_cache[i] = {}
end
pos = pos + bpos
local boffset = Text.offset(frag, bpos+1) -- byte _after_ bpos
frag = string.sub(frag, boffset)
--? if bpos > 0 then
--? print('after chop:', frag)
--? end
frag_width = App.width(frag)
end
--? print('screen line:', pos)