<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rneovim.git/test/functional/lua/thread_spec.lua, branch master</title>
<subtitle>Neovim fork with Rahm's personal hacks.</subtitle>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/'/>
<entry>
<title>test(harness): migrate away from magic globals</title>
<updated>2026-07-21T11:22:39+00:00</updated>
<author>
<name>Justin M. Keyes</name>
<email>justinkz@gmail.com</email>
</author>
<published>2026-07-20T15:16:51+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=6d8c8b18d551d0be0490640c00fabb816727ec10'/>
<id>6d8c8b18d551d0be0490640c00fabb816727ec10</id>
<content type='text'>
Problem:
The magic globals `it`, `describe`, etc., are more trouble than they are
worth.

- Hooking into `after_each` requires `getfenv()` hacks.
- They confuse luals/emmylua, because the top-level `.luarc.json` isn't
  merged with `test/.luarc.json` (apparently a luals limitation?)
- They totally defeat discoverability because the user just has to
  "know" about the various magic symbols.

So they harm DX, which means they serve no purpose at all.

Solution:
- Expose the test API from `testutil`, so tests can call `t.it()`,
  `t.describe()`, etc., in the conventional way.
- Drop `getfenv()` hacks.
- Drop the `setfenv()` injection in `load_chunk`.
- Drop `test/_meta.lua`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Problem:
The magic globals `it`, `describe`, etc., are more trouble than they are
worth.

- Hooking into `after_each` requires `getfenv()` hacks.
- They confuse luals/emmylua, because the top-level `.luarc.json` isn't
  merged with `test/.luarc.json` (apparently a luals limitation?)
- They totally defeat discoverability because the user just has to
  "know" about the various magic symbols.

So they harm DX, which means they serve no purpose at all.

Solution:
- Expose the test API from `testutil`, so tests can call `t.it()`,
  `t.describe()`, etc., in the conventional way.
- Drop `getfenv()` hacks.
- Drop the `setfenv()` injection in `load_chunk`.
- Drop `test/_meta.lua`.
</pre>
</div>
</content>
</entry>
<entry>
<title>fix(lua): use even safer and even better error() message conversion</title>
<updated>2026-05-25T09:06:02+00:00</updated>
<author>
<name>bfredl</name>
<email>bjorn.linse@gmail.com</email>
</author>
<published>2026-05-20T19:02:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=24e23de721bb8ddc042e0f11f44f4ff2ff7ebb0b'/>
<id>24e23de721bb8ddc042e0f11f44f4ff2ff7ebb0b</id>
<content type='text'>
problem:
this crashes neovim:

ondska = setmetatable({}, {__tostring = error})
error(ondska)

solution:

make it not crash neovim
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
problem:
this crashes neovim:

ondska = setmetatable({}, {__tostring = error})
error(ondska)

solution:

make it not crash neovim
</pre>
</div>
</content>
</entry>
<entry>
<title>fix(lua): vim.diff is nil in uv.new_work() thread #34909</title>
<updated>2025-07-13T03:54:22+00:00</updated>
<author>
<name>Justin M. Keyes</name>
<email>justinkz@gmail.com</email>
</author>
<published>2025-07-13T03:54:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=89b946aa87d2414bd268f0766d5354cedc5702ff'/>
<id>89b946aa87d2414bd268f0766d5354cedc5702ff</id>
<content type='text'>
Problem:
The "gitsigns" plugin runs `vim.diff` in a thread (`uv.new_work`), but
`vim.diff` is nil in that context:

    Lua callback:
    …/gitsigns.nvim/lua/gitsigns/diff_int.lua:30: bad argument #1 to 'decode' (string expected, got nil)
    stack traceback:
      [C]: in function 'decode'
      …/gitsigns.nvim/lua/gitsigns/diff_int.lua:30: in function &lt;…/gitsigns.nvim/lua/gitsigns/diff_int.lua:29&gt;
    Luv thread:
    …/gitsigns.nvim/lua/gitsigns/diff_int.lua:63: attempt to call field 'diff' (a nil value)

Solution:
Revert the `stdlib.c` change (set `vim.diff` instead of `vim._diff`).</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Problem:
The "gitsigns" plugin runs `vim.diff` in a thread (`uv.new_work`), but
`vim.diff` is nil in that context:

    Lua callback:
    …/gitsigns.nvim/lua/gitsigns/diff_int.lua:30: bad argument #1 to 'decode' (string expected, got nil)
    stack traceback:
      [C]: in function 'decode'
      …/gitsigns.nvim/lua/gitsigns/diff_int.lua:30: in function &lt;…/gitsigns.nvim/lua/gitsigns/diff_int.lua:29&gt;
    Luv thread:
    …/gitsigns.nvim/lua/gitsigns/diff_int.lua:63: attempt to call field 'diff' (a nil value)

Solution:
Revert the `stdlib.c` change (set `vim.diff` instead of `vim._diff`).</pre>
</div>
</content>
</entry>
<entry>
<title>test: zig build thread_spec.lua failure after `vim.text.diff` rename</title>
<updated>2025-07-12T22:58:17+00:00</updated>
<author>
<name>Justin M. Keyes</name>
<email>justinkz@gmail.com</email>
</author>
<published>2025-07-12T22:58:17+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=815916b45005da04838ceee749cec875ddad0f1a'/>
<id>815916b45005da04838ceee749cec875ddad0f1a</id>
<content type='text'>
Problem:
Since renaming `vim.diff` to `vim.text.diff`, `thread_spec.lua` fails in
the zig build. Is `vim.text.diff` not available in the thread context?
Why does it only fail in the zig build?

    FAILED   ./test/functional/lua/thread_spec.lua @ 217: thread vim.* diff
    ./test/functional/lua/thread_spec.lua:229: Expected objects to be the same.
    Passed in:
    (nil)
    Expected:
    (table: 0x7f221d392218) {
      [1] = 'notification'
    E5113: Lua chunk:
      [2] = 'result'
      [3] = {
        [1] = '@@ -1 +1 @@
    -Hello
    +Helli
    ' } }

    stack traceback:
            ./test/functional/lua/thread_spec.lua:229: in function &lt;./test/functional/lua/thread_spec.lua:217&gt;

    FAILED   ./test/functional/lua/thread_spec.lua @ 372: threadpool vim.* work
    ./test/functional/lua/thread_spec.lua:384: Expected objects to be the same.
    Passed in:
    (table: 0x7f2225be2c30) {
      [1] = 'notification'
      [2] = 'result'
     *[3] = {
       *[1] = vim.NIL } }
    Expected:
    (table: 0x7f2225be25c0) {
      [1] = 'notification'
      [2] = 'result'
     *[3] = {
       *[1] = '@@ -1 +1 @@
    -Hello
    +Helli
    ' } }

    stack traceback:
            ./test/functional/lua/thread_spec.lua:384: in function &lt;./test/functional/lua/thread_spec.lua:372&gt;

Solution:
Use `vim._diff` in the test, until a root cause is found.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Problem:
Since renaming `vim.diff` to `vim.text.diff`, `thread_spec.lua` fails in
the zig build. Is `vim.text.diff` not available in the thread context?
Why does it only fail in the zig build?

    FAILED   ./test/functional/lua/thread_spec.lua @ 217: thread vim.* diff
    ./test/functional/lua/thread_spec.lua:229: Expected objects to be the same.
    Passed in:
    (nil)
    Expected:
    (table: 0x7f221d392218) {
      [1] = 'notification'
    E5113: Lua chunk:
      [2] = 'result'
      [3] = {
        [1] = '@@ -1 +1 @@
    -Hello
    +Helli
    ' } }

    stack traceback:
            ./test/functional/lua/thread_spec.lua:229: in function &lt;./test/functional/lua/thread_spec.lua:217&gt;

    FAILED   ./test/functional/lua/thread_spec.lua @ 372: threadpool vim.* work
    ./test/functional/lua/thread_spec.lua:384: Expected objects to be the same.
    Passed in:
    (table: 0x7f2225be2c30) {
      [1] = 'notification'
      [2] = 'result'
     *[3] = {
       *[1] = vim.NIL } }
    Expected:
    (table: 0x7f2225be25c0) {
      [1] = 'notification'
      [2] = 'result'
     *[3] = {
       *[1] = '@@ -1 +1 @@
    -Hello
    +Helli
    ' } }

    stack traceback:
            ./test/functional/lua/thread_spec.lua:384: in function &lt;./test/functional/lua/thread_spec.lua:372&gt;

Solution:
Use `vim._diff` in the test, until a root cause is found.
</pre>
</div>
</content>
</entry>
<entry>
<title>refactor(lua): rename vim.diff =&gt; vim.text.diff #34864</title>
<updated>2025-07-12T22:36:07+00:00</updated>
<author>
<name>Justin M. Keyes</name>
<email>justinkz@gmail.com</email>
</author>
<published>2025-07-12T22:36:07+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=f3a54e7ccfcfa2752eccd7585e2c4b94a4c8c433'/>
<id>f3a54e7ccfcfa2752eccd7585e2c4b94a4c8c433</id>
<content type='text'>
Problem:
`vim.diff()` was introduced before we had the `vim.text` module, where
it obviously belongs.

Solution:
Move it.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Problem:
`vim.diff()` was introduced before we had the `vim.text` module, where
it obviously belongs.

Solution:
Move it.</pre>
</div>
</content>
</entry>
<entry>
<title>feat(messages): cleanup Lua error messages</title>
<updated>2025-05-04T15:22:57+00:00</updated>
<author>
<name>Justin M. Keyes</name>
<email>justinkz@gmail.com</email>
</author>
<published>2021-08-23T09:37:07+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=fc2dee17368d76e7e845872990bb6fdef1c6bf54'/>
<id>fc2dee17368d76e7e845872990bb6fdef1c6bf54</id>
<content type='text'>
"Error" in error messages is redundant. Just provide the context, don't
say "Error ...".
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
"Error" in error messages is redundant. Just provide the context, don't
say "Error ...".
</pre>
</div>
</content>
</entry>
<entry>
<title>docs: misc #31996</title>
<updated>2025-03-02T22:27:52+00:00</updated>
<author>
<name>Justin M. Keyes</name>
<email>justinkz@gmail.com</email>
</author>
<published>2025-03-02T22:27:52+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=c4a0c1d3b02761626ffced32fe74b0df5b665a5f'/>
<id>c4a0c1d3b02761626ffced32fe74b0df5b665a5f</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>fix(lua): prevent SIGSEGV when lua error is NULL in libuv_worker</title>
<updated>2025-01-18T19:08:50+00:00</updated>
<author>
<name>林玮 (Jade Lin)</name>
<email>linw1995@icloud.com</email>
</author>
<published>2025-01-18T08:40:40+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=a5b1b83a2693ffa7a5a0a22b3693d36ea60051be'/>
<id>a5b1b83a2693ffa7a5a0a22b3693d36ea60051be</id>
<content type='text'>
Problem:
Calling `xstrdup` with a NULL pointer causes a SIGSEGV if `lua_tostring` returns
NULL in `nlua_luv_thread_common_cfpcall`.

Crash stack trace:
- `_platform_strlen` → `xstrdup` (memory.c:469)
- `nlua_luv_thread_common_cfpcall` (executor.c:281)

Solution:
Check if `lua_tostring` returns NULL and pass NULL to `event_create` to avoid the crash.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Problem:
Calling `xstrdup` with a NULL pointer causes a SIGSEGV if `lua_tostring` returns
NULL in `nlua_luv_thread_common_cfpcall`.

Crash stack trace:
- `_platform_strlen` → `xstrdup` (memory.c:469)
- `nlua_luv_thread_common_cfpcall` (executor.c:281)

Solution:
Check if `lua_tostring` returns NULL and pass NULL to `event_create` to avoid the crash.
</pre>
</div>
</content>
</entry>
<entry>
<title>fix(tests): needing two calls to setup a screen is cringe</title>
<updated>2024-11-14T11:40:57+00:00</updated>
<author>
<name>bfredl</name>
<email>bjorn.linse@gmail.com</email>
</author>
<published>2024-11-11T21:15:19+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=e61228a214ebda9845db9462dad0a8c362d3963f'/>
<id>e61228a214ebda9845db9462dad0a8c362d3963f</id>
<content type='text'>
Before calling "attach" a screen object is just a dummy container for
(row, col) values whose purpose is to be sent as part of the "attach"
function call anyway.

Just create the screen in an attached state directly. Keep the complete
(row, col, options) config together. It is still completely valid to
later detach and re-attach as needed, including to another session.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Before calling "attach" a screen object is just a dummy container for
(row, col) values whose purpose is to be sent as part of the "attach"
function call anyway.

Just create the screen in an attached state directly. Keep the complete
(row, col, options) config together. It is still completely valid to
later detach and re-attach as needed, including to another session.
</pre>
</div>
</content>
</entry>
<entry>
<title>refactor(tests): again yet more global highlight definitions</title>
<updated>2024-08-14T12:03:34+00:00</updated>
<author>
<name>bfredl</name>
<email>bjorn.linse@gmail.com</email>
</author>
<published>2024-08-14T11:42:05+00:00</published>
<link rel='alternate' type='text/html' href='http://git.josher.dev/rneovim.git/commit/?id=ef4c9b136e0a41ca4a4740688fa0956c2ccbfb2e'/>
<id>ef4c9b136e0a41ca4a4740688fa0956c2ccbfb2e</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
