fix: failed to rename buffer ()

This commit is contained in:
yetone 2024-10-17 00:36:13 +08:00 committed by GitHub
parent a0d3845bf3
commit 26bf8d67e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,3 +1,5 @@
local Path = require("plenary.path")
local api = vim.api
local fn = vim.fn
local lsp = vim.lsp
@ -662,8 +664,9 @@ function M.get_mentions()
end
local function get_opened_buffer_by_filepath(filepath)
local absolute_path = Path:new(filepath):absolute()
for _, buf in ipairs(api.nvim_list_bufs()) do
if fn.bufname(buf) == filepath then return buf end
if Path:new(fn.bufname(buf)):absolute() == absolute_path then return buf end
end
return nil
end