sindrets / diffview.nvim

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

[Bug] Do not show changes for a supposedly removed BOM #416

Closed kmoschcau closed 10 months ago

kmoschcau commented 10 months ago

Description

I already filed a similar issue with the gitsigns plugin over here: https://github.com/lewis6991/gitsigns.nvim/issues/875

Basically diffview.nvim has a similar thing going on and almost the same repro steps. You only need to replace step 9 with changing the file in any way without committing, doing a :DiffviewOpen and observing the change in the first line. Though here we can see that the buffer for the previous file version shows an <feff> Unicode code-point, which is likely causing the change in the first line. Otherwise vim's diff algo would not mark this as changed.

We can run :%!xxd in both buffers and see that they both start with the UTF-8 bytes for a BOM (EF BB BF), only that the old state buffer even has two of them, Causing the code-point to show up.

Expected behavior

The old buffer should not have two BOMs.

Actual behavior

The old buffer has two BOMs.

Steps to reproduce

Please see https://github.com/lewis6991/gitsigns.nvim/issues/875 and the description above.

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

Log info

Relevant info from :DiffviewLog ``` [INFO 2023-09-09 13:20:55.466 +0200] .../Local/nvim-data/lazy/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen [INFO 2023-09-09 13:20:56.180 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 1 files successfully (331.835 ms) ```

Neovim version

NVIM v0.10.0-dev-798+g72e619ca9
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Operating system and version

MS Win 22H2 (OS Build 22621.2134)

Minimal config

for name, url in pairs{
  diffview = "https://github.com/sindrets/diffview.nvim",
} do
  local install_path = vim.fn.fnamemodify('issue/'..name, ':p')
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
  end
  vim.opt.runtimepath:append(install_path)
end

require("diffview").setup({
})

vim.opt.bomb = true;
vim.opt.fileformat = "dos";
vim.opt.endofline = false;
vim.opt.fixendofline = false;
sindrets commented 10 months ago

Seems like an upstream issue. We have no file format, or encoding detection yet, but I see that the BOM character is still rendered even when these options are set correctly for the diff buffer. We only use the file bytes exactly as they are given to us from Git (we do strip carriage return chars though).

sindrets commented 10 months ago

As far as I understand there's nothing I should do about this here in a plugin. You should discuss this upstream. Closing.

kmoschcau commented 10 months ago

@sindrets Who do you mean by upstream in this case? Git or Neovim?