NeogitOrg / neogit

An interactive and powerful Git interface for Neovim, inspired by Magit
MIT License
4.1k stars 242 forks source link

Cannot close last window #1423

Closed strash closed 4 months ago

strash commented 4 months ago

Description

I'm getting this error after trying to close neogit buffer with "q". This error started to pop out again a month ago or so. But it was fixed a year ago in #480.

Error executing vim.schedule lua callback: vim/_editor.lua:0: Vim:E444: Cannot close last window                                                                                 
stack traceback:                                                                                                                                                                 
        [C]: in function ''                                                                                                                                                      
        vim/_editor.lua: in function <vim/_editor.lua:0> 

Neovim version

NVIM v0.10.0 Build type: Release LuaJIT 2.1.1720049189

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.10.0/share/nvim"

Operating system and version

macOS 14.5

Steps to reproduce

  1. nvim -nu minimal.lua
  2. open any file or don't
  3. run :Neogit kind=split
  4. run :only or press
  5. press "q"

Expected behavior

Open last buffer or empty buffer and don't show error.

Actual behavior

Shows error.

Minimal config

vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/site]])
local package_root = "/tmp/nvim/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
  require("packer").startup({
    {
      "wbthomason/packer.nvim",
      {
        "TimUntersberger/neogit",
        requires = {
          { "nvim-lua/plenary.nvim" },
          { "sindrets/diffview.nvim" },
        },
        config = function()
          print("loaded neogit")
          require("neogit").setup()
        end,
      },
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. "/plugin/packer_compiled.lua",
      display = { non_interactive = true },
    },
  })
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing neogit and dependencies.")
  vim.fn.system({ "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path })
end
load_plugins()
require("packer").sync()
AlexanderArvidsson commented 4 months ago

Created a PR to fix the regression introduced by wrapping the nvim_win_close by schedule_wrap in https://github.com/NeogitOrg/neogit/commit/e69c1b01b4cf0803cad5d7e49430af16760be55c.