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

Prevent tree-sitter error on buffers that don't yet have a filetype #73

Merged
merged 1 commit into from Mar 3, 2024

Conversation

dansalvato
Copy link
Contributor

Some debug adapters occasionally create a stack frame in a brand new buffer, e.g. if jumping into memory that requires disassembly. For some reason, there are rare cases where nvim-dap fires listener events on the new frame before Neovim has had the chance to determine the filetype. Since the filetype is empty, tree-sitter throws an error on get_parser().

This fix manually calls vim.filetype.match() on the buffer if the filetype is empty. If still empty, the function exits early.

So, this fixes the rare edge case I was experiencing, as well as any potential case where Neovim cannot determine the filetype of the file being stepped into.

Copy link
Owner

@theHamsta theHamsta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thank you!

@theHamsta theHamsta enabled auto-merge (rebase) March 3, 2024 20:45
@theHamsta theHamsta merged commit 6dc308b into theHamsta:master Mar 3, 2024
2 checks passed
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.

None yet

2 participants