Skip to content

Commit

Permalink
fix: :DiffviewClose when the view is the last tab page (fixes #501)
Browse files Browse the repository at this point in the history
  • Loading branch information
sindrets committed May 23, 2024
1 parent 72c6983 commit d758a00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
4 changes: 4 additions & 0 deletions lua/diffview/scene/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ function View:close()
if self.tabpage and api.nvim_tabpage_is_valid(self.tabpage) then
DiffviewGlobal.emitter:emit("view_leave", self)

if #api.nvim_list_tabpages() == 1 then
vim.cmd("tabnew")
end

local pagenr = api.nvim_tabpage_get_number(self.tabpage)
vim.cmd("tabclose " .. pagenr)
end
Expand Down
11 changes: 1 addition & 10 deletions lua/diffview/scene/views/standard/standard_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,8 @@ end

---@override
function StandardView:close()
self.closing:send()
self.panel:destroy()

if self.tabpage and api.nvim_tabpage_is_valid(self.tabpage) then
DiffviewGlobal.emitter:emit("view_leave", self)

local pagenr = api.nvim_tabpage_get_number(self.tabpage)
vim.cmd("tabclose " .. pagenr)
end

DiffviewGlobal.emitter:emit("view_closed", self)
View.close(self)
end

---@override
Expand Down

0 comments on commit d758a00

Please sign in to comment.