diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2023-11-24 19:36:26 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2023-11-24 19:36:26 -0800 |
commit | 5561ebf06f70acbb553fdee750364a6cba4baf95 (patch) | |
tree | 5bd7a40d96745f88ab2d78cf504b714a97104bfd | |
parent | 096f9bf720c7fb717e65348f4f88508c3daaf14e (diff) | |
parent | c1f7f17f9caa70ffc4857f64db59ff41741b0caf (diff) | |
download | view.love-5561ebf06f70acbb553fdee750364a6cba4baf95.tar.gz |
Merge lines.love
-rw-r--r-- | source_text.lua | 10 | ||||
-rw-r--r-- | text.lua | 10 |
2 files changed, 18 insertions, 2 deletions
diff --git a/source_text.lua b/source_text.lua index 8b34d52..f60123e 100644 --- a/source_text.lua +++ b/source_text.lua @@ -128,7 +128,9 @@ function Text.populate_screen_line_starting_pos(State, line_index) -- long word; chop it at some letter -- We're not going to reimplement TeX here. local bpos = Text.nearest_pos_less_than(frag, State.width - x) - -- everything works if bpos == 0, but is a little inefficient + 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 pos = pos + bpos local boffset = Text.offset(frag, bpos+1) -- byte _after_ bpos frag = string.sub(frag, boffset) @@ -1035,6 +1037,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 f25e232..9a3d8a8 100644 --- a/text.lua +++ b/text.lua @@ -102,7 +102,9 @@ function Text.populate_screen_line_starting_pos(State, line_index) -- long word; chop it at some letter -- We're not going to reimplement TeX here. local bpos = Text.nearest_pos_less_than(frag, State.width - x) - -- everything works if bpos == 0, but is a little inefficient + 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 pos = pos + bpos local boffset = Text.offset(frag, bpos+1) -- byte _after_ bpos frag = string.sub(frag, boffset) @@ -894,6 +896,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] = {} |