From 2f7b08fb8b63ce704b99f49fcaaab9a59fb591d8 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 19 Sep 2022 00:41:37 -0700 Subject: [PATCH] handle missing cursors in settings --- source.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source.lua b/source.lua index 605f999..14730df 100644 --- a/source.lua +++ b/source.lua @@ -129,9 +129,15 @@ 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 - File_navigation.cursors = settings.cursors - Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1 - Editor_state.cursor1 = File_navigation.cursors[Editor_state.filename].cursor1 + if settings.cursors then + File_navigation.cursors = settings.cursors + Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1 + Editor_state.cursor1 = File_navigation.cursors[Editor_state.filename].cursor1 + else + -- migrate old settings + Editor_state.screen_top1 = {line=1, pos=1} + Editor_state.cursor1 = {line=1, pos=1} + end end function source.set_window_position_from_settings(settings)