mirror of
https://github.com/neovim/neovim.git
synced 2026-07-12 04:19:45 +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:
@@ -158,8 +158,7 @@ end
|
||||
|
||||
---@param buf integer
|
||||
local function open_parent(buf)
|
||||
local path = api.nvim_buf_get_name(buf)
|
||||
-- TODO(barrettruth): simplify after #40552
|
||||
local path = fs.normalize(api.nvim_buf_get_name(buf))
|
||||
local name = encode_name(fs.basename(path)) .. (vim.fn.isdirectory(path) == 1 and '/' or '')
|
||||
navigate(fs.dirname(path))
|
||||
vim.fn.search([[\C\m^\V]] .. vim.fn.escape(name, [[\]]) .. [[\m$]], 'cw')
|
||||
|
||||
Reference in New Issue
Block a user