diff options
author | cukmekerb <cukmekerb+git@gmail.com> | 2021-04-08 21:59:02 -0700 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2021-04-09 12:45:36 +0200 |
commit | e54842961ec017bb60a3da5cf2aa746e0d29e6ca (patch) | |
tree | a3adad023e39e83749ee1a33203c53d459ccf819 /plugins | |
parent | b812cd913c94685411acfab7ddb07dfd10077d44 (diff) | |
download | lite-xl-plugins-e54842961ec017bb60a3da5cf2aa746e0d29e6ca.tar.gz lite-xl-plugins-e54842961ec017bb60a3da5cf2aa746e0d29e6ca.zip |
fixed autosave coroutine issue
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/autosave.lua | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/plugins/autosave.lua b/plugins/autosave.lua index 11337f7..4c39612 100644 --- a/plugins/autosave.lua +++ b/plugins/autosave.lua @@ -13,18 +13,15 @@ config.autosave_timeout = 1 local function loop_for_save() - if not looping then - looping = true while looping do if os.difftime(os.time(), last_keypress) >= config.autosave_timeout then command.perform "doc:save" -- stop loop looping = false end - -- dividing by five is completely arbitrary but it seemed to work well so idc + -- wait the timeout. may cause timeout to be slightly imprescise coroutine.yield(config.autosave_timeout) end - end end @@ -32,7 +29,10 @@ local function updatepress() -- set last keypress time to now last_keypress = os.time() -- put loop in coroutine so it doesn't lag out this script - core.add_thread(loop_for_save) + if not looping then + looping = true + core.add_thread(loop_for_save) + end end |