about summary refs log tree commit diff stats
path: root/run.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-06-08 01:02:54 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-06-08 01:02:54 -0700
commit14c08f9bd9a45d2f05727ea47b128afdbdff1d24 (patch)
tree3e146695f66458990d2c07602a728faf0e3aa46c /run.lua
parent68eaba7d3db72dda06c4504ec744f1d2f47f994c (diff)
downloadlines.love-14c08f9bd9a45d2f05727ea47b128afdbdff1d24.tar.gz
several bugfixes in saving/loading cursor position
Diffstat (limited to 'run.lua')
-rw-r--r--run.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/run.lua b/run.lua
index 5f35a0b..f0482e0 100644
--- a/run.lua
+++ b/run.lua
@@ -19,7 +19,7 @@ function run.initialize(arg)
     run.initialize_default_settings()
   end
 
-  if #arg > 0 then
+  if #arg > 0 and Editor_state.filename ~= absolutize(arg[1]) then
     Editor_state.filename = arg[1]
     load_from_disk(Editor_state)
     Text.redraw_all(Editor_state)
@@ -154,19 +154,22 @@ function run.settings()
   if Current_app == 'run' then
     Settings.x, Settings.y, Settings.displayindex = App.screen.position()
   end
-  local filename = Editor_state.filename
-  if is_relative_path(filename) then
-    filename = love.filesystem.getWorkingDirectory()..'/'..filename  -- '/' should work even on Windows
-  end
   return {
     x=Settings.x, y=Settings.y, displayindex=Settings.displayindex,
     width=App.screen.width, height=App.screen.height,
     font_height=Editor_state.font_height,
-    filename=filename,
+    filename=absolutize(Editor_state.filename),
     screen_top=Editor_state.screen_top1, cursor=Editor_state.cursor1
   }
 end
 
+function absolutize(path)
+  if is_relative_path(path) then
+    return love.filesystem.getWorkingDirectory()..'/'..path  -- '/' should work even on Windows
+  end
+  return path
+end
+
 function run.mouse_press(x,y, mouse_button)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
   return edit.mouse_press(Editor_state, x,y, mouse_button)