Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TreeSitter error with multiple buffers open #276

Open
snail-with-tea opened this issue Feb 7, 2025 · 0 comments
Open

TreeSitter error with multiple buffers open #276

snail-with-tea opened this issue Feb 7, 2025 · 0 comments

Comments

@snail-with-tea
Copy link

Description

When opening second buffer in a split and switching focus to previous buffer treesitter encounters an error.

Tested integrations

  • Markdown
  • Typst

For reason unknown to me only happens in typst integration

Resulting error

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/treesitter.lua:198: Index out of bounds                            
stack traceback:                                                                                                                              
        [C]: in function 'nvim_buf_get_text'                                                                                                  
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:198: in function 'get_node_text'                                                       
        /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:273: in function 'handler'                                                       
        /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:767: in function 'fn'                                                            
        /usr/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'match_preds'                                                       
        /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:883: in function '(for generator)'                                               
        ...re/nvim/lazy/image.nvim/lua/image/integrations/typst.lua:24: in function 'query_buffer_images'                                     
        .../share/nvim/lazy/image.nvim/lua/image/utils/document.lua:59: in function ''                                                        
        vim/_editor.lua: in function <vim/_editor.lua:0>

Possible fix

Using local buf instead of 0 in query:iter_captures(root, 0) in affected integrations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant