Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] DiffviewClose E784 error when executed after opening local version of file #501

Closed
robbienohra opened this issue May 23, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@robbienohra
Copy link

robbienohra commented May 23, 2024

Description

  • start neovim
  • execute DiffviewOpen
  • execute gf (Open the local version of the file)
  • close the local version of the file
  • execute DiffviewClose
  • below E784 error thrown
:DiffviewClose
Error executing Lua callback: vim/_editor.lua:0: nvim_exec2(): Vim(tabclose):E784: Cannot close last tab page
stack traceback:
        [C]: in function 'nvim_exec2'
        vim/_editor.lua: in function 'cmd'
        ...nvim/lua/diffview/scene/views/standard/standard_view.lua:54: in function 'close'
        ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:186: in function 'close'
        ...ocal/share/nvim/lazy/diffview.nvim/lua/diffview/init.lua:155: in function 'close'
        ....local/share/nvim/lazy/diffview.nvim/plugin/diffview.lua:38: in function <....local/share/nvim/lazy/diffview.nvim/plugin/diffview.lua:37>

Note that the error still occurs even if multiple tabs are open. Also note that the error does not occur if DiffviewClose is executed without having first executed gf

Expected behavior

DiffviewClose should behave the same way after running gf and closing the local file as it does without doing so.

Actual behavior

DiffviewClose throws an E784 when run after executing gf and closing the local file. See attached recording:

Screen.Recording.2024-05-23.at.1.28.18.AM.mov

The below recording shows the close behaviour without having first executed gf:

Screen.Recording.2024-05-23.at.1.33.45.AM.mov

Steps to reproduce

  • start neovim
  • execute DiffviewOpen
  • execute gf (Open the local version of the file)
  • close the local version of the file
  • execute DiffviewClose
  • below E784 error thrown

Health check

Output of :checkhealth diffview
diffview: require("diffview.health").check()

Checking plugin dependencies ~
- OK nvim-web-devicons installed.

Checking VCS tools ~
- The plugin requires at least one of the supported VCS tools to be valid.
- OK Git found.
- OK Git is up-to-date. (2.43.0)
- WARNING Configured `hg_cmd` is not executable: 'hg'

Log info

Relevant info from :DiffviewLog
Error executing Lua callback: vim/_editor.lua:0: nvim_exec2(): Vim(tabclose):E784: Cannot close last tab page
stack traceback:
        [C]: in function 'nvim_exec2'
        vim/_editor.lua: in function 'cmd'
        ...nvim/lua/diffview/scene/views/standard/standard_view.lua:54: in function 'close'
        ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:186: in function 'close'
        ...ocal/share/nvim/lazy/diffview.nvim/lua/diffview/init.lua:155: in function 'close'
        ....local/share/nvim/lazy/diffview.nvim/plugin/diffview.lua:38: in function <....local/share/nvim/lazy/diffview.nvim/plugin/diffview.lua:37>

Neovim version

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1703358377

Operating system and version

macOS 14.4.1 (23E224)

Minimal config

-- #######################################
-- ### USAGE: nvim --clean -u mini.lua ###
-- #######################################

local root = vim.fn.stdpath("run") .. "/nvim/diffview.nvim"
local plugin_dir = root .. "/plugins"
vim.fn.mkdir(plugin_dir, "p")

for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

local plugins = {
  { "nvim-web-devicons", url = "https://github.com/nvim-tree/nvim-web-devicons.git" },
  { "diffview.nvim", url = "https://github.com/sindrets/diffview.nvim.git" },
  -- ##################################################################
  -- ### ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE ###
  -- ##################################################################
}

for _, spec in ipairs(plugins) do
  local install_path = plugin_dir .. "/" .. spec[1]
  if vim.fn.isdirectory(install_path) ~= 1 then
    if spec.url then
      print(string.format("Installing '%s'...", spec[1]))
      vim.fn.system({ "git", "clone", "--depth=1", spec.url, install_path })
    end
  end
  vim.opt.runtimepath:append(spec.path or install_path)
end

require("diffview").setup({
  -- ##############################################################################
  -- ### ADD DIFFVIEW.NVIM CONFIG THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE ###
  -- ##############################################################################
})

vim.opt.termguicolors = true
vim.cmd("colorscheme " .. (vim.fn.has("nvim-0.8") == 1 and "habamax" or "slate"))

-- ############################################################################
-- ### ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE ###
-- ############################################################################

print("Ready!")
@robbienohra robbienohra added the bug Something isn't working label May 23, 2024
@robbienohra
Copy link
Author

Thanks, @sindrets! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant