smoka7 / multicursors.nvim

A multi cursor plugin for Neovim.
MIT License
442 stars 15 forks source link

Cursors do not align when moving them with the arrow keys while in insert mode #103

Closed eofferma closed 2 weeks ago

eofferma commented 2 weeks ago

Describe the bug The cursors do not align when moving them with the arrow keys while in insert mode.

To Reproduce Steps to reproduce the behavior:

  1. Enter normal mode of multicursors with <leader>m.
  2. Move the cursor down or up with j or k.
  3. Enter insert mode with i.
  4. Move the cursor with the arrow keys.

Expected behavior

It is expected that the cursors align when moving them with the arrow keys, just as they do when entering insert mode with a.

Screenshots

Peek 2024-08-25 11-21 - do not work

Nvim version:

NVIM v0.10.1 Build type: RelWithDebInfo LuaJIT 2.1.1713484068

NVIM v0.11.0-dev-657+gbb4b6b427 Build type: RelWithDebInfo LuaJIT 2.1.1724232689

NVIM v0.11.0-dev-660+gcf44121f7 Build type: RelWithDebInfo LuaJIT 2.1.1724512491

Multicursor version:

commit 562809a

Additional context

Add any other context about the problem here.

It works with append a:

Peek 2024-08-25 12-05 - works

Tested on minimum configuration:

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  local lazyrepo = "https://github.com/folke/lazy.nvim.git"
  local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
  if vim.v.shell_error ~= 0 then
    vim.api.nvim_echo({
      { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
      { out, "WarningMsg" },
      { "\nPress any key to exit..." },
    }, true, {})
    vim.fn.getchar()
    os.exit(1)
  end
end
require("lazy").setup({
  spec = {
    {
      "smoka7/multicursors.nvim",
      event = "VeryLazy",
      dependencies = {
        "nvimtools/hydra.nvim",
      },
      opts = {},
      cmd = { "MCstart", "MCvisual", "MCclear", "MCpattern", "MCvisualPattern", "MCunderCursor" },
      keys = {
        {
          mode = { "v", "n" },
          "<Leader>m",
          "<cmd>MCstart<cr>",
          desc = "Create a selection for selected text or word under the cursor",
        },
      },
    },
  },
  defaults = {
    lazy = false,
  },
})
eofferma commented 2 weeks ago

I just verified that it works correctly in version 2.0.0. It would be good to consider this regression in the main branch (commit 562809a) for future versions.

smoka7 commented 2 weeks ago

I can't reproduce this. Are you sure that the behavior changed since v2.0.0? Cause there is no change in logic between v2.0.0 and the main.

eofferma commented 2 weeks ago

You're right, I did more testing with version 2.0.0, and the problem persists.

The issue occurs with insert and append when I create the multicursors from anywhere other than the beginning of the word in the case of insert or the end of the word in the case of append.

smoka7 commented 2 weeks ago

The issue occurs with insert and append when I create the multicursors from anywhere other than the beginning of the word in the case of insert or the end of the word in the case of append.

It should move that way cause j and k only create a selection for just a char not the word. If you want to create cursor for the word use the n.