gitsigns.nvim icon indicating copy to clipboard operation
gitsigns.nvim copied to clipboard

linehl does not show first added line in hunk whenever linehl is manually enabled (also affects numhl)

Open unphased opened this issue 1 year ago • 0 comments

Description

the first line isnt highlighted by the linehl properly. Seems to only be happening if :Gitsigns toggle_linehl is used to turn linehl on. When linehl is enabled in config, behavior seems to be correct!

Neovim version

NVIM v0.9.0-dev-964+g1539f7136

Operating system and version

Ubuntu 20.04.5 LTS

Expected behavior

No response

Actual behavior

With my buffer and git state like this: image If I add another empty line in this particular situation it does look right: image

Minimal config

vim.o.packpath = '/tmp/nvim/site'

local plugins = {
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
  -- ADD OTHER PLUGINS _NECESSARY_ TO REPRODUCE THE ISSUE
}

for name, url in pairs(plugins) do
  local install_path = '/tmp/nvim/site/pack/test/start/'..name
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
  end
end

require('gitsigns').setup{
  debug_mode = true, -- You must add this to enable debug messages
  -- ADD GITSIGNS CONFIG THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE
  diff_opts = {
    internal = true,
    -- linematch = 1
  },
  signs = {
    add          = { text = '+', show_count = true },
    change       = { text = '│', show_count = true },
    delete       = { text = '_', show_count = true },
    topdelete    = { text = '‾', show_count = true },
    changedelete = { text = '~', show_count = true },
    untracked    = { text = '┆' },
  },
  count_chars = {
    [1]   = '₁',
    [2]   = '₂',
    [3]   = '₃',
    [4]   = '₄',
    [5]   = '₅',
    [6]   = '₆',
    [7]   = '₇',
    [8]   = '₈',
    [9]   = '₉',
    ['+'] = '₊',
  },
  show_deleted = true,
  numhl      = true, -- Toggle with `:Gitsigns toggle_numhl`
  linehl     = false, -- Toggle with `:Gitsigns toggle_linehl`
  word_diff  = true, -- Toggle with `:Gitsigns toggle_word_diff`
  current_line_blame = true, -- Toggle with `:Gitsigns toggle_current_line_blame`
  current_line_blame_opts = {
    virt_text = true,
    virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
    delay = 400,
    ignore_whitespace = true,
  },
}

Steps to reproduce

  1. Have a state where you're adding a clean hunk
  2. nvim --clean -u minimal.lua <above file> <-- note this config listed above has linehl turned off
  3. :Gitsigns toggle_linehl
  4. Notice first line of added hunk is not properly highlighted
  5. (may be a separate issue, but seems highly related!) notice if :set number is on that after toggling numhl will cause this bugged first line to also leave numhl enabled even when numhl is in the off state.
  6. In accordance with what's described in (5), if linehl is enabled in config, then the state is flipped: manually toggling linehl off at this point will cause the first line of this added hunk to stay highlighted

Gitsigns debug messages

:Gitsigns debug_messages
signs.init: Using vimfn signs
run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --version
derive: Deriving GitSignsAdd from DiffAdd
derive: Deriving GitSignsChange from DiffChange
derive: Deriving GitSignsDelete from DiffDelete
derive: Deriving GitSignsChangedelete from GitSignsChange
derive: Deriving GitSignsTopdelete from GitSignsDelete
derive: Deriving GitSignsUntracked from GitSignsAdd
derive: Deriving GitSignsAddNr from GitSignsAdd
derive: Deriving GitSignsChangeNr from GitSignsChange
derive: Deriving GitSignsDeleteNr from GitSignsDelete
derive: Deriving GitSignsChangedeleteNr from GitSignsChangeNr
derive: Deriving GitSignsTopdeleteNr from GitSignsDeleteNr
derive: Deriving GitSignsUntrackedNr from GitSignsAddNr
derive: Deriving GitSignsAddLn from DiffAdd
derive: Deriving GitSignsChangeLn from DiffChange
derive: Deriving GitSignsChangedeleteLn from GitSignsChangeLn
derive: Deriving GitSignsUntrackedLn from GitSignsAddLn
derive: Deriving GitSignsStagedAdd from GitSignsAdd
derive: Deriving GitSignsStagedChange from GitSignsChange
derive: Deriving GitSignsStagedDelete from GitSignsDelete
derive: Deriving GitSignsStagedChangedelete from GitSignsChangedelete
derive: Deriving GitSignsStagedTopdelete from GitSignsTopdelete
derive: Deriving GitSignsStagedAddNr from GitSignsAddNr
derive: Deriving GitSignsStagedChangeNr from GitSignsChangeNr
derive: Deriving GitSignsStagedDeleteNr from GitSignsDeleteNr
derive: Deriving GitSignsStagedChangedeleteNr from GitSignsChangedeleteNr
derive: Deriving GitSignsStagedTopdeleteNr from GitSignsTopdeleteNr
derive: Deriving GitSignsStagedAddLn from GitSignsAddLn
derive: Deriving GitSignsStagedChangeLn from GitSignsChangeLn
derive: Could not derive GitSignsStagedDeleteLn
derive: Deriving GitSignsStagedChangedeleteLn from GitSignsChangedeleteLn
derive: Could not derive GitSignsStagedTopdeleteLn
derive: Deriving GitSignsAddPreview from DiffAdd
derive: Deriving GitSignsDeletePreview from DiffDelete
derive: Deriving GitSignsCurrentLineBlame from NonText
derive: Deriving GitSignsAddInline from TermCursor
derive: Deriving GitSignsDeleteInline from TermCursor

:Gitsigns dump_cache
{ {
    compare_text = { "...",
      head = "stages:",
      length = 136
    },
    file = "/home/slu/project/.gitlab-ci.yml",
    force_next_update = false,
    git_obj = {
      encoding = "utf-8",
      file = "/home/slu/project/.gitlab-ci.yml",
      i_crlf = false,
      mode_bits = "100644",
      object_name = "6cd6ccbc95d3d0a9a75ccb32724a9c96c4472d99",
      relpath = ".gitlab-ci.yml",
      repo = {
        abbrev_head = "ticket-num/ticket-desc",
        detached = false,
        gitdir = "/home/slu/project/.git",
        toplevel = "/home/slu/project",
        username = "Steven Lu"
      },
      w_crlf = false
    },
    gitdir_watcher = <userdata 1>,
    hunks = { {
        added = {
          count = 1,
          lines = { "Build & Release:" },
          start = 31
        },
        head = "@@ -31,1 +31,1 @@",
        removed = {
          count = 1,
          lines = { "Build and Release rev:" },
          start = 31
        },
        type = "change",
        vend = 31
      }, {
        added = {
          count = 1,
          lines = { "Build & Release rev with ccache:" },
          start = 36
        },
        head = "@@ -36,1 +36,1 @@",
        removed = {
          count = 1,
          lines = { "Build with ccache:" },
          start = 36
        },
        type = "change",
        vend = 36
      }, {
        added = {
          count = 1,
          lines = { "Build & Release rev2:" },
          start = 43
        },
        head = "@@ -43,1 +43,1 @@",
        removed = {
          count = 1,
          lines = { "Build and Release rev2:" },
          start = 43
        },
        type = "change",
        vend = 43
      }, {
        added = {
          count = 7,
          lines = { "Build & Release rev2 with ccache:", "  <<: *OTA", "  when: manual", "  before_script:", "    - ", "  needs: [] # Do not place a dependency on test stage", "" },
          start = 52
        },
        head = "@@ -51 +52,7 @@",
        removed = {
          count = 0,
          lines = {},
          start = 51
        },
        type = "add",
        vend = 58
      } },
    staged_diffs = {}
  } }

unphased avatar Feb 21 '23 00:02 unphased