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

bug: g prefix makes '[ and '] mark incorrect when mode change from n->no->n->no->n in the same tick #949

Open
4 tasks done
xzbdmw opened this issue Feb 13, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@xzbdmw
Copy link

xzbdmw commented Feb 13, 2025

Did you check docs and existing issues?

  • I have read all the which-key.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of which-key.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.10.3

Operating system/version

macos 14.0

Describe the bug

init.lua:

vim.keymap.set("n", "<d-y>", function()
    vim.o.operatorfunc = "v:lua._G.operator_callback"
    vim.api.nvim_feedkeys(string.format("g@iwg@"), "mi", false)
end)

_G.operator_callback = function(vmode)
    local function getRange(visual)
        local s = vim.api.nvim_buf_get_mark(0, visual and "<" or "[")
        local e = vim.api.nvim_buf_get_mark(0, visual and ">" or "]")
        return { startRow = s[1], startCol = s[2], endRow = e[1], endCol = e[2] }
    end
    print(vim.inspect(getRange()))
end

in line 16, press <d-y>gg, output is

{
  endCol = 8,
  endRow = 16,
  startCol = 4,
  startRow = 16
}
{
  endCol = 3,
  endRow = 16,
  startCol = 4,
  startRow = 16 -- incorrect range
}

without whichkey, output is

{
  endCol = 3,
  endRow = 16,
  startCol = 0,
  startRow = 16
}
{
  endCol = 0,
  endRow = 16,
  startCol = 0,
  startRow = 1 --- This is correct range
}

Steps To Reproduce

see above

Expected Behavior

see above, related to jake-stewart/multicursor.nvim#87 (comment)

Health


Log

on_key: <D-y>
State(start): Mode(n:0) Node(g) { keys = "g" }
  update Mode(n:2)
  continue: g Mode(n:2)
  getchar
  got: @
  suspend: Mode(n:2)
  Trigger(del) Mode(n:2) g` <Space> g [ ] <C-W> " g'
  feedkeys: Mode(n:2) g@
ModeChanged(n:no)
  new Mode(o:2)
  Unsafe(pending "i")
  suspend: Mode(o:2)
ModeChanged(no:n)
  Unsafe(pending "g")
  suspend: Mode(n:2)
ModeChanged(n:no)
  Safe(true)
  State(start): Mode(o:0) Node() { defer = false }
    update Mode(o:2)
    continue:  Mode(o:2)
    getchar
    Trigger(add) Mode(o:2) g ] [
    Trigger(add) Mode(n:2) " g' g` <Space> g [ ] <C-W>
    on_key: g
    got: g
    continue: g Mode(o:2)
    getchar
    on_key: g
    got: g
    suspend: Mode(o:2)
    Trigger(del) Mode(o:2) g ] [
    feedkeys: Mode(o:2) gg
on_key: g
on_key: g
ModeChanged(no:n)
  Safe(true)
Trigger(add) Mode(o:2) g ] [
on_key: <D-e>
BufNew(38)
BufNew(39)
BufNew(40)
BufNew(41)
BufEnter(40)
  new Mode(n:40)
ModeChanged(n:i)
  new Mode(i:40)
  Safe(true)
Trigger(add) Mode(n:40) " g' g` <Space> g [ ] <C-W>
on_key: <CR>
BufEnter(2)
BufNew(42)
BufReadPost(42)

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { "folke/which-key.nvim", opts = {} },
    -- add any other plugins here
  },
})
@xzbdmw xzbdmw added the bug Something isn't working label Feb 13, 2025
@xzbdmw xzbdmw changed the title bug: g prefix makes '[ and '] mark incorrectly when when mode change from n->no->n->no in the same tick bug: g prefix makes '[ and '] mark incorrect when mode change from n->no->n->no in the same tick Feb 13, 2025
@xzbdmw xzbdmw changed the title bug: g prefix makes '[ and '] mark incorrect when mode change from n->no->n->no in the same tick bug: g prefix makes '[ and '] mark incorrect when mode change from n->no->n->no->n in the same tick Feb 13, 2025
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