Skip to content

Check buffer validity before loading Treesitter parser - #2169

Open
TyceHerrman wants to merge 1 commit into
nvim-lua:masterfrom
TyceHerrman:fix/treesitter-buffer-validity
Open

TyceHerrman wants to merge 1 commit into
nvim-lua:masterfrom
TyceHerrman:fix/treesitter-buffer-validity

Conversation

@TyceHerrman

Copy link
Copy Markdown
Contributor

If a buffer is wiped before asynchronous parser installation finishes, the attachment callback receives an invalid buffer number. Check validity before loading the parser (i.e., calling vim.treesitter.language.add() ) so the attachment callback returns without loading a parser for an invalid buffer, avoiding unnecessary work.

This change moves the existing guard earlier. Valid buffer attachment behavior stays the same.

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

Successfully merging this pull request may close these issues.

1 participant