diff options
author | Erlend Lind Madsen <erlendf80@gmail.com> | 2021-10-04 13:23:45 +0200 |
---|---|---|
committer | Erlend Lind Madsen <erlendf80@gmail.com> | 2021-10-04 13:23:45 +0200 |
commit | 2b24123e83810e6e34c65a308f983e1a4c1c0380 (patch) | |
tree | 2d8d14784ee1beb205327318f32a65c5636497ae | |
parent | 956110a3d443c6d63423f52a5eb2328ed6fee2d9 (diff) | |
download | vis-cursors-2b24123e83810e6e34c65a308f983e1a4c1c0380.tar.gz |
only read cursors at init and at quit | don't overwrite existing cursor positions
-rw-r--r-- | init.lua | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -32,7 +32,6 @@ local file_exists = function(path) end local read_cursors = function() - cursors = {} local f = io.open(M.path) if f == nil then return @@ -50,13 +49,20 @@ local read_cursors = function() local dir = string.match(path, '(.*/)') prev_dir = dir end - cursors[path] = pos + -- only set cursor paths not already set in the current process + if not cursors[path] then + cursors[path] = pos + end end end f:close() end local write_cursors = function() + + -- read cursors file in case other vis processes updated it + read_cursors() + local f = io.open(M.path, 'w+') if f == nil then return end -- sort paths @@ -91,8 +97,6 @@ local set_cursor_pos = function(win) if not file_exists(win.file.path) then return end - -- read cursors file in case other vis processes edited files - read_cursors() -- set cursor pos for current file path cursors[win.file.path] = win.selection.pos end |