establish a fairly fundamental invariant

This commit doesn't guarantee we'll always catch it. But if this
invariant is violated, things can get quite difficult to debug. I found
in the Lua Carousel fork that all the xpcalls I keep around were
actively hindering my ability to notice this invariant being violated.
This commit is contained in:
Kartik K. Agaram 2023-11-24 19:16:33 -08:00
parent 48c05aa77a
commit 0751b38932
2 changed files with 12 additions and 0 deletions

View File

@ -1035,6 +1035,12 @@ end
function Text.redraw_all(State)
--? print('clearing fragments')
-- 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] = {}

View File

@ -973,6 +973,12 @@ end
function Text.redraw_all(State)
--? print('clearing fragments')
-- 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] = {}