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 <./test/functional/lua/thread_spec.lua:217>
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 <./test/functional/lua/thread_spec.lua:372>
Solution:
Use `vim._diff` in the test, until a root cause is found.
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.
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.
Specifically, functions that are run in the context of the test runner
are put in module `test/testutil.lua` while the functions that are run
in the context of the test session are put in
`test/functional/testnvim.lua`.
Closes https://github.com/neovim/neovim/issues/27004.
This is the command invoked repeatedly to make the changes:
:%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g