aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2022-01-05 09:50:54 -0700
committerGitHub <noreply@github.com>2022-01-05 09:50:54 -0700
commitf40ce3456313138f2e0f822da9676ed3bc51f608 (patch)
treefe255279c898902a601e182e97092dc540f80736 /test/functional/lua
parent55a59e56eda98f17448a1c318a346ae12d30fc05 (diff)
downloadrneovim-f40ce3456313138f2e0f822da9676ed3bc51f608.tar.gz
rneovim-f40ce3456313138f2e0f822da9676ed3bc51f608.tar.bz2
rneovim-f40ce3456313138f2e0f822da9676ed3bc51f608.zip
fix(filetype): match on <afile> rather than <abuf> (#16943)
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.
Diffstat (limited to 'test/functional/lua')
-rw-r--r--test/functional/lua/filetype_spec.lua18
1 files changed, 6 insertions, 12 deletions
diff --git a/test/functional/lua/filetype_spec.lua b/test/functional/lua/filetype_spec.lua
index d96e7b8a85..20f91ce0f6 100644
--- a/test/functional/lua/filetype_spec.lua
+++ b/test/functional/lua/filetype_spec.lua
@@ -24,8 +24,7 @@ describe('vim.filetype', function()
rs = 'radicalscript',
},
})
- vim.api.nvim_buf_set_name(0, 'main.rs')
- vim.filetype.match(0)
+ vim.filetype.match('main.rs')
return vim.bo.filetype
]])
end)
@@ -40,8 +39,7 @@ describe('vim.filetype', function()
['main.rs'] = 'somethingelse',
},
})
- vim.api.nvim_buf_set_name(0, 'main.rs')
- vim.filetype.match(0)
+ vim.filetype.match('main.rs')
return vim.bo.filetype
]])
end)
@@ -53,8 +51,7 @@ describe('vim.filetype', function()
['s_O_m_e_F_i_l_e'] = 'nim',
},
})
- vim.api.nvim_buf_set_name(0, 's_O_m_e_F_i_l_e')
- vim.filetype.match(0)
+ vim.filetype.match('s_O_m_e_F_i_l_e')
return vim.bo.filetype
]])
@@ -66,8 +63,7 @@ describe('vim.filetype', function()
[root .. '/.config/fun/config'] = 'dosini',
},
})
- vim.api.nvim_buf_set_name(0, root .. '/.config/fun/config')
- vim.filetype.match(0)
+ vim.filetype.match(root .. '/.config/fun/config')
return vim.bo.filetype
]], root))
end)
@@ -80,8 +76,7 @@ describe('vim.filetype', function()
[root .. '/blog/.*%.txt'] = 'markdown',
}
})
- vim.api.nvim_buf_set_name(0, root .. '/blog/why_neovim_is_awesome.txt')
- vim.filetype.match(0)
+ vim.filetype.match(root .. '/blog/why_neovim_is_awesome.txt')
return vim.bo.filetype
]], root))
end)
@@ -97,8 +92,7 @@ describe('vim.filetype', function()
end,
}
})
- vim.api.nvim_buf_set_name(0, 'relevant_to_me')
- vim.filetype.match(0)
+ vim.filetype.match('relevant_to_me')
return vim.bo.filetype
]])
end)