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

extmarks wont get restored with {right_gravity=true,invalidate=true,undo_restore=true} opts #29509

Open
haolian9 opened this issue Jun 28, 2024 · 1 comment · May be fixed by #29523
Open

extmarks wont get restored with {right_gravity=true,invalidate=true,undo_restore=true} opts #29509

haolian9 opened this issue Jun 28, 2024 · 1 comment · May be fixed by #29523
Labels
bug issues reporting wrong behavior marks marks, extmarks, decorations, virtual text, namespaces

Comments

@haolian9
Copy link

Problem

the extmark remains .invalid=true and no highlighting, after undo.

Steps to reproduce

  • test.lua
local api = vim.api

local ns = api.nvim_create_namespace("xxx")
local bufnr = api.nvim_get_current_buf()

api.nvim_buf_set_lines(bufnr, 0, -1, false, { "abcdefgh" })

local lnum = 0

local ids = {}
for i, col in ipairs({ 2, 5 }) do
  --stylua: ignore start
  local id = api.nvim_buf_set_extmark(bufnr, ns, lnum, col, {
    end_row = lnum, end_col = col + 2,
    hl_group = "Search", hl_mode = "replace", --to spot the problem easily
    right_gravity = false,
    invalidate = true, undo_restore = true,
  })
  --stylua: ignore start
  ids[i] = id
end
print("ns", ns, "ids", table.concat(ids, ","))
  • nvim --clean -u NONE +'so test.lua' # it happend to be 'ns=1, ids=1,2' on my side
  • :lua =vim.api.nvim_buf_get_extmark_by_id(0, 1, 1, {details=true}
{ 0, 2, {
    end_col = 4,
    end_right_gravity = false,
    end_row = 0,
    hl_eol = false,
    hl_group = "Search",
    invalidate = true,
    ns_id = 1,
    priority = 4096,
    right_gravity = false
  } }
  • xxxx, `:lua =vim.api.nvim_buf_get_extmark_by_id(0, 1, 1, {details=true})
{ 0, 0, {
    end_col = 0,
    end_right_gravity = false,
    end_row = 0,
    hl_eol = false,
    hl_group = "Search",
    invalid = true,
    invalidate = true,
    ns_id = 1,
    priority = 4096,
    right_gravity = false
  } }
  • 4u, :lua =vim.api.nvim_buf_get_extmark_by_id(0, 1, 1, {details=true})
{ 0, 2, {
    end_col = 4,
    end_right_gravity = false,
    end_row = 0,
    hl_eol = false,
    hl_group = "Search",
    invalid = true,
    invalidate = true,
    ns_id = 1,
    priority = 4096,
    right_gravity = false
  } }

Expected behavior

after 4u, the extmark is valid and gets highlight back.

Neovim version (nvim -v)

nvim 0.10

Vim (not Nvim) behaves the same?

N/A

Operating system/version

archlinux

Terminal name/version

st 0.9

$TERM environment variable

tmux-256color

Installation

pacman

@haolian9 haolian9 added the bug issues reporting wrong behavior label Jun 28, 2024
@zeertzjq zeertzjq added the marks marks, extmarks, decorations, virtual text, namespaces label Jun 28, 2024
@luukvbaal
Copy link
Contributor

luukvbaal commented Jun 29, 2024

Looks like we need to handle this case #28961 (comment), this repro hits the assert:

neovim/src/nvim/extmark.c

Lines 120 to 121 in aa6b9c6

// Does this hold? If it doesn't, we should still revalidate.
assert(!invalid || !mt_invalid(key));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior marks marks, extmarks, decorations, virtual text, namespaces
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
-