sindrets / diffview.nvim

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

[Bug] CTRL-W_T does not move focus to new tab #462

Closed jakubbortlik closed 4 months ago

jakubbortlik commented 7 months ago

Description

In the first place, thank you for your amazing plugin! Either on its own or utilized by my other favourite plugin gitlab.nvim, diffview.nvim is of enormous help in reviewing code history.

Quite frequently, while inspecting a diff with diffview, I open a file in a new split, e.g,. a help page, and then I decide to move that window to another tab page. This can be achieved with the <c-w>T normal mode command (see :h CTRL-W_T). This command first moves the window to a new tab page and then moves focus to that tab. However, when in a diffview tab, focus stays in this tab while the screen flickers as the view is switched several times between the newly created tab page and the diffview tab.

Expected behavior

CTRL-W_T moves current window to a new tab page and switches focus to that tab

Actual behavior

CTRL-W_T moves current window to a new tab page and switches focus to that tab and back to the diffview tab several times.

Steps to reproduce

  1. nvim --clean -u mini.lua
  2. :DiffviewOpen
  3. :help CTRL-W_T
  4. <c-w>T

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

No response

Neovim version

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1702233742

Operating system and version

Linux 6.1.71-1-MANJARO x86_64 GNU/Linux

Minimal config

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

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

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

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    "sindrets/diffview.nvim",
    dependencies = { "nvim-tree/nvim-web-devicons" },
    config = function()
      require("diffview").setup({
        -- ##############################################################################
        -- ### ADD DIFFVIEW.NVIM CONFIG THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE ###
        -- ##############################################################################
      })
    end,
  },
  -- ##################################################################
  -- ### ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE ###
  -- ##################################################################
}
require("lazy").setup(plugins, { root = root .. "/plugins" })
require("lazy").sync({ show = false, wait = true })

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 ###
-- ############################################################################
sindrets commented 4 months ago

This actually seems to be an upstream bug. I can't get this mapping to work at all, even when running nvim with no config at all. Can you?

jakubbortlik commented 4 months ago

Hei, hvordan gar det? Thanks for your amazing plugin and thanks for looking at this. I'm still experiencing this issue the CTRL-W_T mapping works in general, but when run in a Diffview tab the cursor stays in the tab and does not follow the window that was moved to another tab.

But I've found that PR #472 fixes the issue for me, so you may consider merging that and #462 will probably be fixed by it as well.

sindrets commented 4 months ago

Ah, I see now. I think I'll hijack that PR to get this fixed right now.