diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2023-11-24 19:16:33 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2023-11-24 19:16:33 -0800 |
commit | 0751b389321cde6db5528704fc3613910f30ccbb (patch) | |
tree | 539445be317387f4dcba5a3f9548a585543c40f9 | |
parent | 48c05aa77a6a06329f4764ab511e39611262c23f (diff) | |
download | view.love-0751b389321cde6db5528704fc3613910f30ccbb.tar.gz |
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.
-rw-r--r-- | source_text.lua | 6 | ||||
-rw-r--r-- | text.lua | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/source_text.lua b/source_text.lua index 8b34d52..f93e859 100644 --- a/source_text.lua +++ b/source_text.lua @@ -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] = {} diff --git a/text.lua b/text.lua index cd80464..db51ac4 100644 --- a/text.lua +++ b/text.lua @@ -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] = {} |