mirror of
https://github.com/neovim/neovim.git
synced 2026-07-16 22:21:30 +00:00
fix(filetype): ensure directory bufname ends w/ slash sep #40552
Problem: `vim.filetype.match()` needs a cheap way to recognize directory buffers without doing filesystem stat work. Solution: Ensure full buffer names for directories end in a trailing slash. Now directory buffers can proceed through the normal 'filetype' path. Note side-effects: session and ShaDa buffer-list restore behavior must be compatible, so those + corresponding tests must be updated.
This commit is contained in:
@@ -37,8 +37,9 @@ local function bufopt(name)
|
||||
end
|
||||
|
||||
local function assert_directory(path)
|
||||
eq(path, api.nvim_buf_get_name(0))
|
||||
eq(path, fn.bufname('%'))
|
||||
local ffname = path:sub(-1) == '/' and path or path .. '/'
|
||||
eq(ffname, api.nvim_buf_get_name(0))
|
||||
eq(path, vim.fs.normalize(fn.bufname('%')))
|
||||
eq('directory', bufopt('filetype'))
|
||||
eq(true, bufopt('buflisted'))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user