nvim-neotest / neotest

An extensible framework for interacting with tests within NeoVim.
MIT License
2.44k stars 123 forks source link

[BUG] lib.treesitter.parse_positions causes crash in nvim 0.11.0 nightly #452

Closed fredrikaverpil closed 2 months ago

fredrikaverpil commented 2 months ago

NeoVim Version NVIM v0.11.0-dev-734+g8a2aec997

Describe the bug

The neotest.lib.treesitter.parse_positions works just fine in Neovim 0.10.1 but crashes in nightly. I noticed this as I'm running tests in my CI for neotest-golang for both stable and nightly neovim: https://github.com/fredrikaverpil/neotest-golang/actions/runs/10776208100/job/29882411561?pr=173

.tests/all/site/pack/deps/start/nvim-nio/lua/nio/tests.lua:48: Test task failed with message:
The coroutine failed with this message: 
...r/nvim-nightly/share/nvim/runtime/lua/vim/treesitter.lua:222: attempt to call method 'start' (a nil value)
stack traceback:
    ...r/nvim-nightly/share/nvim/runtime/lua/vim/treesitter.lua: in function 'get_node_text'
    ...k/deps/start/neotest/lua/neotest/lib/treesitter/init.lua:29: in function 'build_position'
    ...k/deps/start/neotest/lua/neotest/lib/treesitter/init.lua:64: in function 'collect'
    ...k/deps/start/neotest/lua/neotest/lib/treesitter/init.lua:162: in function 'parse_positions_from_string'
    ...k/deps/start/neotest/lua/neotest/lib/treesitter/init.lua:207: in function 'parse_positions'
    ./lua/neotest-golang/query.lua:138: in function <./lua/neotest-golang/query.lua:126>

stack traceback:
    .tests/all/site/pack/deps/start/nvim-nio/lua/nio/tests.lua:48: in function <.tests/all/site/pack/deps/start/nvim-nio/lua/nio/tests.lua:31>
    .tests/all/site/pack/deps/start/nvim-nio/lua/nio/tests.lua:89: in function 'with_async_context'
    ...eotest-golang/neotest-golang/tests/go/positions_spec.lua:264: in function <...eotest-golang/neotest-golang/tests/go/positions_spec.lua:23>

Invoked through here: https://github.com/fredrikaverpil/neotest-golang/blob/a7704cd2c9674783517cd84e46d6b1db2942e5be/lua/neotest-golang/query.lua#L138

Expected behavior

I would've expected this not to crash.

Logs

I can try and install the nightly locally and extract the logs, if you wish.

fredrikaverpil commented 2 months ago

I have no idea what originally caused this but I just tried this again with Neovim 0.11.0 nightly and now there are no errors, so I'm closing this.