lite-xl/data/core
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
..
commands reorder nagview options on doc:save error to be more consistent with other nagview confirmations (#1696) 2024-01-20 01:19:12 +01:00
doc Use `\r\n` for new files on Windows (#1596) 2023-11-30 10:51:10 -05:00
bit.lua Assert for negative `field` in bit32 polyfill 2022-01-12 19:56:09 +01:00
command.lua Documentation for core.command (#1564) 2023-07-27 13:04:44 +02:00
commandview.lua Improve `CommandView` and `autocomplete` scroll behavior (#1732) 2024-03-05 22:56:01 -05:00
common.lua Fix `dirmonitor` sorting issues (#1599) 2023-11-29 09:55:38 -05:00
config.lua Improve `CommandView` and `autocomplete` scroll behavior (#1732) 2024-03-05 22:56:01 -05:00
contextmenu.lua docs(core.contextmenu): add documentation for contextmenu (#1567) 2023-08-24 22:32:07 -04:00
dirwatch.lua Fix comment typos in data/core/{init.lua,dirwatch.lua} (#1549) 2024-01-21 22:30:59 +01:00
docview.lua Reverted cursor API to something more compatible with old API. (#1674) 2023-11-29 21:29:37 +01:00
emptyview.lua fix: center title and version in emptyview (#1311) 2023-01-06 15:27:05 -04:00
ime.lua Improve IME location updates (#1170) 2022-12-20 20:11:13 -04:00
init.lua fix: avoid iterating over a changing table in `run_threads` (#1794) 2024-06-05 08:58:19 -04:00
keymap-macos.lua Make tab scrolling more flexible (#1384) 2023-02-09 12:51:41 -04:00
keymap.lua Text overwriting (#1495) 2023-11-29 14:12:43 -05:00
logview.lua Fix #1538 log scrolls automatically (the real PR) (#1546) 2023-06-28 03:05:03 +02:00
modkeys-generic.lua Adds super as a modkey. (#1590) 2023-08-25 14:34:51 -04:00
modkeys-macos.lua Normalize strokes in fixed order (#1572) 2023-08-25 14:03:23 -04:00
nagview.lua ease transparency of nagbar dim (#1658) 2023-10-31 16:24:36 -04:00
node.lua Sanitize tab index in `Node:add_view` (#1651) 2023-10-23 17:58:02 -04:00
object.lua comment typo in object.lua (#1541) 2023-06-25 04:09:27 +02:00
regex.lua core: ported regex.gsub to faster native version (#1233) 2022-12-20 17:46:37 -04:00
rootview.lua Fixed issue with set_target_size passing the wrong value to plugins (#1657) 2023-11-29 07:34:44 +08:00
scrollbar.lua Fix `Scrollbar.{expanded,contracted}_size` documentation 2023-09-07 04:07:52 +02:00
start.lua Remove DPI detection for default `SCALE` 2023-09-30 16:48:38 +02:00
statusview.lua Text overwriting (#1495) 2023-11-29 14:12:43 -05:00
strict.lua Initial commit 2019-12-28 11:17:56 +00:00
style.lua Add top tab margins (#1479) 2023-06-09 09:44:20 -04:00
syntax.lua Expose plaintext syntax (#1652) 2023-11-30 10:53:01 -05:00
titleview.lua Add mouse grab (#1501) 2023-05-20 13:54:58 -04:00
tokenizer.lua Skip patterns matching nothing in `tokenizer` (#1743) 2024-04-15 09:00:03 +08:00
utf8string.lua c core: fix extra utf8 build conflict on windows 2022-05-11 00:22:01 -04:00
view.lua Add `NaN` guard to `View:update_scrollbar` 2023-08-26 05:11:33 +02:00