aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua11
1 files changed, 6 insertions, 5 deletions
diff --git a/init.lua b/init.lua
index 2644eea..398e54e 100644
--- a/init.lua
+++ b/init.lua
@@ -51,12 +51,13 @@ end
local created_locks = {}
vis.events.subscribe(vis.events.FILE_OPEN, function(file)
- if not file.path then
+ if created_locks[file.path] or not file.path then
+ -- either a noname buffer, or already locked by us
return
end
local lfile_path = lockfiles.lock_file_path(get_lock_dir(), file.path)
if lockfiles.create_lock_file(get_lock_dir(), lfile_path) then
- created_locks[lfile_path] = true
+ created_locks[file.path] = lfile_path
elseif not confirm(lfile_path) then
os.exit(1)
end
@@ -66,10 +67,10 @@ vis.events.subscribe(vis.events.FILE_CLOSE, function(file)
if not file.path then
return
end
- local lfile_path = lockfiles.lock_file_path(get_lock_dir(), file.path)
- if created_locks[lfile_path] then
+ local lfile_path = created_locks[file.path]
+ if lfile_path then
lockfiles.delete_lock_file(lfile_path)
- created_locks[lfile_path] = nil
+ created_locks[file.path] = nil
end
end)