fix(#1878): nvim frozen on no name buffer when modified.enable (#1879)

This commit is contained in:
Richard Li 2023-01-03 15:11:14 +13:00 committed by GitHub
parent 951b6e7e55
commit cdbd7daf29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,10 +9,16 @@ function M.reload()
local bufs = vim.fn.getbufinfo { bufmodified = true, buflisted = true } local bufs = vim.fn.getbufinfo { bufmodified = true, buflisted = true }
for _, buf in pairs(bufs) do for _, buf in pairs(bufs) do
local path = buf.name local path = buf.name
M._record[path] = true if path ~= "" then -- not a [No Name] buffer
while path ~= vim.fn.getcwd() and path ~= "/" do -- mark all the parent as modified as well
path = vim.fn.fnamemodify(path, ":h") while
M._record[path] = true M._record[path] ~= true
-- no need to keep going if already recorded
-- This also prevents an infinite loop
do
M._record[path] = true
path = vim.fn.fnamemodify(path, ":h")
end
end end
end end
end end