Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toggle_line_hl will shadow those extmarks added by toggle_word_diff #1115

Open
xzbdmw opened this issue Aug 29, 2024 · 1 comment
Open

toggle_line_hl will shadow those extmarks added by toggle_word_diff #1115

xzbdmw opened this issue Aug 29, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@xzbdmw
Copy link
Contributor

xzbdmw commented Aug 29, 2024

Description

As the title says, After running toggle_word_diff and then toggle_line_hl, word_diff highlight get shadowed by line_hl, after running toggle_line_hl again, word_diff highlight reappears.

Neovim version

0.10

Operating system and version

macos 14

Expected behavior

word diff highlight and line_hl exist together, and word diff have higher priority.

Actual behavior

word_diff highlight get cleared.

Minimal config

for name, url in pairs{
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
  -- ADD OTHER PLUGINS _NECESSARY_ TO REPRODUCE THE ISSUE
} do
local install_path = vim.fn.fnamemodify('gitsigns_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('gitsigns').setup{
  debug_mode = true, -- You must add this to enable debug messages
  -- ADD GITSIGNS CONFIG THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE
}

-- ADD INIT.LUA SETTINGS THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE

Steps to reproduce

At first I thought it is a priority problem, but with this simple snippet, result is the same.

keymap = vim.keymap.set
api = vim.api
local function has_namespace(name_space)
    local ns = api.nvim_create_namespace(name_space)
    local extmark = api.nvim_buf_get_extmarks(0, ns, { 0, 0 }, { -1, -1 }, {})
    return extmark ~= nil and #extmark ~= 0
end
keymap("n", "<leader>yY", function()
    local cur_line = api.nvim_win_get_cursor(0)[1]
    if has_namespace("line") then
        api.nvim_buf_clear_namespace(0, api.nvim_create_namespace("line"), 0, -1)
    else
        local ns = vim.api.nvim_create_namespace("line")
        api.nvim_buf_set_extmark(0, ns, cur_line - 1, -1, {
            line_hl_group = "GitSignsAddLnInline",
            priority = 3,
        })
    end
end)
keymap("n", "<leader>yy", function()
    local cur_line, cur_col = unpack(api.nvim_win_get_cursor(0))
    if has_namespace("char") then
        api.nvim_buf_clear_namespace(0, api.nvim_create_namespace("char"), 0, -1)
    else
        local ns = vim.api.nvim_create_namespace("char")
        api.nvim_buf_set_extmark(0, ns, cur_line - 1, cur_col, {
            end_col = cur_col + 5,
            hl_group = "GitSignsDeleteVirtLnInLine",
            priority = 1000,
        })
    end
end)

first type <leader>yy, red color appears, then <leader>yY, entire line get the same color as GitSignsAddLnInline, then <leader>yY again, red color reappears.

Gitsigns debug messages

No response

Gitsigns cache

No response

@xzbdmw xzbdmw added the bug Something isn't working label Aug 29, 2024
@xzbdmw
Copy link
Contributor Author

xzbdmw commented Aug 30, 2024

It seems I can simulate

        api.nvim_buf_set_extmark(0, ns, cur_line - 1, -1, {
            line_hl_group = "GitSignsAddLnInline",
            priority = 3,
        })

with

        api.nvim_buf_set_extmark(0, ns, cur_line - 1, 0, {
            end_line = cur_line,
            hl_group = "GitSignsAddLnInline",
            priority = 3,
            end_col = 0,
            hl_eol = true,
            strict = false,
        })

which does not have above shortcomings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant