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

fix(filetype): match on <afile> rather than <abuf> #16943

Merged
merged 1 commit into from Jan 5, 2022

Conversation

gpanders
Copy link
Member

@gpanders gpanders commented Jan 5, 2022

Filetype detection runs on BufRead and BufNewFile autocommands, both of
which can fire without an underlying buffer, so it's incorrect to use
<abuf> to determine the file path. Instead, match on <afile> and assume
that the buffer we're operating on is the current buffer. This is the
same assumption that filetype.vim makes, so it should be safe.

Closes #16939.

Filetype detection runs on BufRead and BufNewFile autocommands, both of
which can fire without an underlying buffer, so it's incorrect to use
<abuf> to determine the file path. Instead, match on <afile> and assume
that the buffer we're operating on is the current buffer. This is the
same assumption that filetype.vim makes, so it should be safe.
@github-actions github-actions bot added the lua stdlib label Jan 5, 2022
@gpanders
Copy link
Member Author

gpanders commented Jan 5, 2022

@kevinhwang91 This works for me using your reproduction steps, can you please verify that this solves your issue?

@kevinhwang91
Copy link
Contributor

The issue has gone!

@gpanders gpanders merged commit f40ce34 into neovim:master Jan 5, 2022
@gpanders gpanders deleted the filetype-afile branch January 5, 2022 16:50
dmitmel pushed a commit to dmitmel/neovim that referenced this pull request Apr 16, 2022
Filetype detection runs on BufRead and BufNewFile autocommands, both of
which can fire without an underlying buffer, so it's incorrect to use
<abuf> to determine the file path. Instead, match on <afile> and assume
that the buffer we're operating on is the current buffer. This is the
same assumption that filetype.vim makes, so it should be safe.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lua stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

do filetypedetect BufRead filename doesn't work if using filetype.lua
2 participants