Skip to content

[Bug] Diffview flashes current window's open buffer when showing file diff or history #509

@charbelnicolas

Description

@charbelnicolas

Description

I don't think I had noticed this in the previous months but now it's really hard to unsee. When opening a Diffview window (either DiffviewOpen or DiffviewFileHistory), unless it's the very first time opening it (it is possible then to fix and not flash a buffer!), it will flash the current focused window buffer on both Diffview editor windows.

Let's assume I have this window open:

ss_2024_06_07_10_47_17

After opening a Diffview window once, If I open Diffview again, every consequent DiffviewOpen will flash the current focused buffer first instead of showing the right contents.

ss_2024_06_07_10_46_35

And it is then that the correct buffer will show:

ss_2024_06_07_10_46_54

Here's a video:

https://drive.google.com/file/d/11-etwvc3RU5f5bLy2_YVllcG0jYz5CY3/view?usp=sharing

Expected behavior

I expect to transition correctly into the desired Diffview output instead of seeing a flash of my current focused window buffer.

Actual behavior

I see a flash of buffer content that is not correct.

Steps to reproduce

  1. nvim --clean -u mini.lua
  2. Open a file in a git repository
  3. Do DiffviewOpen at least twice (first always comes clean)

Health check

diffview: require("diffview.health").check()

Checking plugin dependencies ~
- WARNING Optional dependency 'nvim-web-devicons' not found.

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.45.2)
- WARNING Configured `hg_cmd` is not executable: 'hg'

Log info

Relevant info from :DiffviewLog
############################
### PUT LOG CONTENT HERE ###
############################

Neovim version

NVIM v0.11.0-dev-196+g2ce4a4d91e
Build type: Release
LuaJIT 2.1.1716656478

Operating system and version

Linux 6.9.3-arch1-1 x86_64 GNU/Linux

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!")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions