nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects
Cursor position outside buffer error selecting custom text object in markdown files on branch `main`
Nobody has claimed this yet.
- Dominant language
- Tree-sitter Query
- Stars
- 2.8k
- Forks
- 271
- Avg merge
- 8d 8h
- Merged PRs (30d)
- 1
Description
Describe the bug
Selecting around @block.outer with custom textobjects in queries/markdown/textobjects.scm makes nvim throw the following error:
E5108: Error executing lua: ...r-textobjects/lua/nvim-treesitter-textobjects/select.lua:32:
Cursor position outside buffer
stack traceback:
[C]: in function 'nvim_win_set_cursor'
...r-textobjects/lua/nvim-treesitter-textobjects/select.lua:32: in function 'update_
selection'
...r-textobjects/lua/nvim-treesitter-textobjects/select.lua:174: in function 'sel'
....config/nvim/lua/configs/nvim-treesitter-textobjects.lua:34: in function <....con
fig/nvim/lua/configs/nvim-treesitter-textobjects.lua:34>
Put the following in queries/markdown/textobjects.scm in neovim config dir:
(fenced_code_block
(code_fence_content) @block.inner) @block.outer
To Reproduce
Steps to reproduce the behavior:
- Add keymap
vim.keymap.set({ 'x', 'o' }, 'a.', function() require('nvim-treesitter-textobjects.select').select_textobject('@block.outer') end) - Create markdown file with a single non-empty code block:
``` echo ``` - Open the markdown file with neovim
- Select around block with
va. - See the error
Expected behavior
Should not throw error. The custom query works fine on master branch.
Output of :checkhealth nvim-treesitter
==============================================================================
nvim-treesitter: ✅
Requirements ~
- ✅ OK Neovim was compiled with tree-sitter runtime ABI version 15 (required >=13).
- ✅ OK tree-sitter 0.25.6 (/opt/homebrew/bin/tree-sitter)
- ✅ OK node 24.4.1 (/opt/homebrew/bin/node)
- ✅ OK tar 3.5.3 (/usr/bin/tar)
- ✅ OK curl 8.7.1 (/usr/bin/curl)
curl 8.7.1 (x86_64-apple-darwin24.0) libcurl/8.7.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.64.0
Release-Date: 2024-03-27
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM SPNEGO SSL threadsafe UnixSockets
OS Info ~
- version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000
- sysname: Darwin
- machine: arm64
- release: 24.6.0
Install directory for parsers and queries ~
- /Users/shihua.zeng/.local/share/nvim/site/
- ✅ OK is writable.
- ✅ OK is in runtimepath.
Installed languages H L F I J ~
-
bash ✓ ✓ ✓ . ✓
-
c ✓ ✓ ✓ ✓ ✓
-
go ✓ ✓ ✓ ✓ ✓
-
lua ✓ ✓ ✓ ✓ ✓
-
markdown ✓ . ✓ ✓ ✓
-
markdown_inline ✓ . . . ✓
-
python ✓ ✓ ✓ ✓ ✓
-
query ✓ ✓ ✓ ✓ ✓
-
vim ✓ ✓ ✓ . ✓
-
vimdoc ✓ . . . ✓
Legend: H[ighlights], L[ocals], F[olds], I[ndents], In[J]ections ~
Output of nvim --version
NVIM v0.11.2
Build type: Release
LuaJIT 2.1.1748459687
Additional context
The custom query works without error on branch master.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the custom query in queries/markdown/textobjects.scm and the selection entry point reported at lua/nvim-treesitter-textobjects/select.lua:32. Use the provided markdown code block and va. reproduction steps, then compare behavior with the master branch. Done means selecting @block.outer no longer raises the cursor-outside-buffer error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, markdown, neovim
- Domain
- devtools, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100