about summary refs log tree commit diff stats
path: root/source.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-09-19 00:53:25 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-09-19 00:53:25 -0700
commitd1d05fe5c9a509701aa585e354a1f840074fb6f3 (patch)
tree7b7da128d1aed5ea89feb22b276af9fe55037207 /source.lua
parent6ac45b75b96247c6cc4173f61cb4e2ccc674c1e8 (diff)
downloadlines.love-d1d05fe5c9a509701aa585e354a1f840074fb6f3.tar.gz
migrate old settings, attempt #3
This time we have to handle absolute filenames.
Now lines-polygon-experiment fork should merge successfully, at least.
Diffstat (limited to 'source.lua')
-rw-r--r--source.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/source.lua b/source.lua
index c582953..dbf1640 100644
--- a/source.lua
+++ b/source.lua
@@ -86,8 +86,13 @@ end
 function source.initialize_edit_side()
   load_from_disk(Editor_state)
   Text.redraw_all(Editor_state)
-  Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1
-  Editor_state.cursor1 = File_navigation.cursors[Editor_state.filename].cursor1
+  if File_navigation.cursors[Editor_state.filename] then
+    Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1
+    Editor_state.cursor1 = File_navigation.cursors[Editor_state.filename].cursor1
+  else
+    Editor_state.screen_top1 = {line=1, pos=1}
+    Editor_state.cursor1 = {line=1, pos=1}
+  end
 
   -- We currently start out with side B collapsed.
   -- Other options:
@@ -129,6 +134,7 @@ function source.load_settings()
   end
   Editor_state = edit.initialize_state(Margin_top, Margin_left, right, settings.font_height, math.floor(settings.font_height*1.3))
   Editor_state.filename = settings.filename
+  Editor_state.filename = basename(Editor_state.filename)  -- migrate settings that used full paths; we now support only relative paths within the app
   if settings.cursors then
     File_navigation.cursors = settings.cursors
     Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1