sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
3.85k stars 105 forks source link

Unable to `DiffviewClose` with noice installed #302

Closed dnguyener closed 1 year ago

dnguyener commented 1 year ago

Hello,

I'm getting the below error when running DiffviewClose with noice installed. To reproduce, first run DiffviewFileHistory and than DiffviewClose.

[Diffview.nvim] nvim-web-devicons is required to use file icons! Set `use_icons = false` in your config to stop seeing this message.
Error executing Lua callback: ...nvim/lua/diffview/scene/views/standard/standard_view.lua:60: Vim(tabclose):E445: Other window contains changes
stack traceback:
[C]: in function 'cmd'
 ...nvim/lua/diffview/scene/views/standard/standard_view.lua:60: in function 'close'
.../diffview/scene/views/file_history/file_history_view.lua:74: in function 'close'
...ocal/share/nvim/lazy/diffview.nvim/lua/diffview/init.lua:138: 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>

Minimal Config:

return {
    {
        'sindrets/diffview.nvim',
        dependencies = {
            "nvim-lua/plenary.nvim",
        }
    },
    {
        "folke/noice.nvim",
        config = function()
            require("noice").setup()
        end,
        dependencies = {
            "MunifTanjim/nui.nvim",
        }
    }
}
bryant-the-coder commented 1 year ago

Set use_icons = false in your config to stop seeing this message. set this in your config

dnguyener commented 1 year ago

The issue still occurs with it set to false.

return {
    {
        'sindrets/diffview.nvim',
        dependencies = {
            "nvim-lua/plenary.nvim",
        },
        config = function()
            require("diffview").setup({
                use_icons = false,
            })
        end
    },
    {
        "folke/noice.nvim",
        config = function()
            require("noice").setup()
        end,
        dependencies = {
            "MunifTanjim/nui.nvim",
        }
    }
}
  1 Error executing Lua callback: ...nvim/lua/diffview/scene/views/standard/standard_view.lua:60: Vim(tabclose):E445: Other window contains changes
  2 stack traceback:
  3     [C]: in function 'cmd'
  4     ...nvim/lua/diffview/scene/views/standard/standard_view.lua:60: in function 'close'
  5     .../diffview/scene/views/file_history/file_history_view.lua:74: in function 'close'
  6     ...ocal/share/nvim/lazy/diffview.nvim/lua/diffview/init.lua:138: in function 'close'
  7     ....local/share/nvim/lazy/diffview.nvim/plugin/diffview.lua:38: in function <....local/share/nvim/lazy/diffview.nvim/plugin/diffview.lua:37>
sindrets commented 1 year ago

You either have:

  1. 'hidden' disabled and you're trying to close a diffview while you have windows containing buffers with unsaved changes in the same tab page.
    • Solution: Either :set hidden or :write all modified buffers before trying to close the tab.
  2. noice uses modifiable buffers combined with bufhidden=delete or bufhidden=wipe and this buffer is considered to be 'modified'.
    • Open an issue in the noice repo.
j-barnak commented 1 year ago

Here's a simple fix to this

return {
  "sindrets/diffview.nvim",
  keys = {
    { "<leader>jj", "<cmd>set hidden<cr><cmd>DiffviewClose<cr><cmd>set nohidden<cr>" },
  },
  opts = {},
}