Skip to content

Commit

Permalink
Only try to detach UFO if it is loaded
Browse files Browse the repository at this point in the history
Without this check, it could be that ufo.setup() is not called before
ufo.detach(), which breaks UFO's internal assumptions, and causes an
error.
  • Loading branch information
gilice committed Feb 22, 2025
1 parent 63124cf commit cd793fb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lua/neogit/lib/buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,12 @@ function Buffer:show()
end

-- Workaround UFO getting folds wrong.
local ok, ufo = pcall(require, "ufo")
if ok and type(ufo.detach) == "function" then
logger.debug("[BUFFER:" .. self.handle .. "] Disabling UFO for buffer")
ufo.detach(self.handle)
if package.loaded["nvim-ufo"] then
local ok, ufo = pcall(require, "ufo")
if ok and type(ufo.detach) == "function" then
logger.debug("[BUFFER:" .. self.handle .. "] Disabling UFO for buffer")
ufo.detach(self.handle)
end
end

self.win_handle = win
Expand Down

0 comments on commit cd793fb

Please sign in to comment.