lite-xl/data
Guldoman 4d649ba92d
fix: avoid iterating over a changing table in `run_threads` (#1794)
* fix: avoid iterating over a changing table in `run_threads`

This is done to avoid iterating over a table that can change in the meantime.
More precisely the issue appears if a thread is removed from the table, we yield early from `run_threads` because we reached the end of the frame, and a new thread is added before the next iteration.

For example:
```lua
local lost_time = false
core.add_thread(function()
  -- force early yield
  local t0 = system.get_time()
  while system.get_time() - t0 < .1 do end
  lost_time = true
end, "a")

local step = core.step
function core.step()
  if lost_time then
    -- add a new thread while run_threads hasn't finished iterating
    core.add_thread(function()end, "a1")
    lost_time = false
  end
  return step()
end
```
would crash with `invalid key to 'next'`.

* fix: only run coroutine if it wasn't removed

* fix: don't handle `core.threads` table as an array

This caused some entries to be skipped or even removed erroneously.
2024-06-05 08:58:19 -04:00
..
colors style: move default colors to its own style file 2022-06-02 19:20:54 -04:00
core fix: avoid iterating over a changing table in `run_threads` (#1794) 2024-06-05 08:58:19 -04:00
fonts draw lite-xl icon in TitleView (#1143) 2022-10-10 11:05:30 -04:00
plugins Change co_wait to co_await in language_cpp (#1800) 2024-06-05 12:25:33 +02:00