about summary refs log tree commit diff stats
path: root/run.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-03-17 09:36:38 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-03-17 10:28:10 -0700
commite2c1bbe4e53bb0369471296caedf81ff6a059ae0 (patch)
treeadd8700c3d57ca09ad6dc4d37a164dff868ef8f4 /run.lua
parent224e8fe85a55671139527b1e77c88a1f0d629313 (diff)
downloadlines.love-e2c1bbe4e53bb0369471296caedf81ff6a059ae0.tar.gz
more robust state validation
Diffstat (limited to 'run.lua')
-rw-r--r--run.lua7
1 files changed, 2 insertions, 5 deletions
diff --git a/run.lua b/run.lua
index ec6a509..4c29860 100644
--- a/run.lua
+++ b/run.lua
@@ -28,14 +28,11 @@ function run.initialize(arg)
     Text.redraw_all(Editor_state)
     Editor_state.screen_top1 = {line=1, pos=1}
     Editor_state.cursor1 = {line=1, pos=1}
-    edit.fixup_cursor(Editor_state)
   else
     load_from_disk(Editor_state)
     Text.redraw_all(Editor_state)
-    if Editor_state.cursor1.line > #Editor_state.lines or Editor_state.lines[Editor_state.cursor1.line].mode ~= 'text' then
-      edit.fixup_cursor(Editor_state)
-    end
   end
+  edit.check_locs(Editor_state)
   love.window.setTitle('lines.love - '..Editor_state.filename)
 
   if #arg > 1 then
@@ -112,7 +109,7 @@ function run.file_drop(file)
   Editor_state.lines = load_from_file(file)
   file:close()
   Text.redraw_all(Editor_state)
-  edit.fixup_cursor(Editor_state)
+  edit.check_locs(Editor_state)
   love.window.setTitle('lines.love - '..Editor_state.filename)
 end