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: visual mode selection + pressing key 'c' is slow, if pressed twice error shows up #580

Closed
av1155 opened this issue Sep 13, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@av1155
Copy link

av1155 commented Sep 13, 2024

Describe the bug

**E492: Not an editor command: '<,'>AvanteConflictChooseCursor**

Slow behavior:

  1. Create a random test.txt file
  2. Type anything into the file
  3. Highlight a word, or anything in the buffer, in visual mode
  4. Press the 'c' key to "change"
  5. Notice it takes a long time for the word, or selection, to get deleted
  6. Normal functionality resumes

Error shows up if:

  1. Create a random test.txt file
  2. Type anything into the file
  3. Highlight a word, or anything in the buffer, in visual mode
  4. Fast press the 'c' key to "change" more than 1 or 2 times,
  5. Error -> E492: Not an editor command: '<,'>AvanteConflictChooseCursor

To reproduce

E492: Not an editor command: '<,'>AvanteConflictChooseCursor

Slow behavior:

  1. Create a random test.txt file
  2. Type anything into the file
  3. Highlight a word, or anything in the buffer, in visual mode
  4. Press the 'c' key to "change"
  5. Notice it takes a long time for the word, or selection, to get deleted
  6. Normal functionality resumes

Error shows up if:

  1. Create a random test.txt file
  2. Type anything into the file
  3. Highlight a word, or anything in the buffer, in visual mode
  4. Fast press the 'c' key to "change" more than 1 or 2 times,
  5. Error -> E492: Not an editor command: '<,'>AvanteConflictChooseCursor

Expected behavior

No error when pressing 'c' key fast, and fast use of 'c' key in visual mode when Avante is installed.

Environment

NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1725453128
Run "nvim -V1 -v" for more info

Repro

No response

@av1155 av1155 added the bug Something isn't working label Sep 13, 2024
@b0o
Copy link
Collaborator

b0o commented Sep 14, 2024

Hi there, I can't reproduce this. Can you please share your config?

@b0o
Copy link
Collaborator

b0o commented Sep 14, 2024

Also, can you test to see if a similar error appears when you quickly hit ct or co?

@will-lynas
Copy link
Contributor

I have this too. cc is very slow.

@aarnphm
Copy link
Collaborator

aarnphm commented Sep 15, 2024

Are you using which-key by any chance? I can't reproduce this?

would be best if you can also provide a screen recording. Thanks

@will-lynas
Copy link
Contributor

I am

@aarnphm
Copy link
Collaborator

aarnphm commented Sep 15, 2024

can you provide a repro?

@av1155
Copy link
Author

av1155 commented Sep 15, 2024

Screen.Recording.2024-09-15.at.3.28.50.PM.mov

cw is instant, vwc is slow, vwcc produces error (pressing c more than once on a highlighted string).
Visual string highlight can be either with key stroke or mouse double click.

Obviously pressing c more than once on a highlighted string has no use, but sometimes we like to press keys many times, idk y.

I am using AstroNvim but I have had this config for around 1 year and a half now, I moved away from all IDE's. So I can safely say I understand how Neovim configuration works.

My avante config is the one provided by astrocommunity (https://github.com/AstroNvim/astrocommunity/tree/main/lua/astrocommunity/completion/avante-nvim), the only reason for me to have that lazy config is in case i want to modify any defaults, which I only modified it so that the side panel uses 40% of screen instead of 30%.

I am using which-key.

init.lua provided by astrocommunity:

return {
  "yetone/avante.nvim",
  build = ":AvanteBuild",
  cmd = {
    "AvanteAsk",
    "AvanteBuild",
    "AvanteConflictChooseAllTheirs",
    "AvanteConflictChooseBase",
    "AvanteConflictChooseBoth",
    "AvanteConflictChooseCursor",
    "AvanteConflictChooseNone",
    "AvanteConflictChooseOurs",
    "AvanteConflictChooseTheirs",
    "AvanteConflictListQf",
    "AvanteConflictNextConflict",
    "AvanteConflictPrevConflict",
    "AvanteEdit",
    "AvanteRefresh",
    "AvanteSwitchProvider",
  },
  dependencies = {
    "stevearc/dressing.nvim",
    "nvim-lua/plenary.nvim",
    "MunifTanjim/nui.nvim",
    {
      "AstroNvim/astrocore",
      opts = function(_, opts)
        local maps = assert(opts.mappings)
        local prefix = "<Leader>a"

        maps.n[prefix] = { desc = "Avante functionalities" }

        maps.n[prefix .. "a"] = { function() require("avante.api").ask() end, desc = "Avante ask" }
        maps.v[prefix .. "a"] = { function() require("avante.api").ask() end, desc = "Avante ask" }

        maps.v[prefix .. "r"] = { function() require("avante.api").refresh() end, desc = "Avante refresh" }

        maps.n[prefix .. "e"] = { function() require("avante.api").edit() end, desc = "Avante edit" }
        maps.v[prefix .. "e"] = { function() require("avante.api").edit() end, desc = "Avante edit" }

        -- the following key bindings do not have an official api implementation
        maps.n.co = { ":AvanteConflictChooseOurs<CR>", desc = "Choose ours" }
        maps.v.co = { ":AvanteConflictChooseOurs<CR>", desc = "Choose ours" }

        maps.n.ct = { ":AvanteConflictChooseTheirs<CR>", desc = "Choose theirs" }
        maps.v.ct = { ":AvanteConflictChooseTheirs<CR>", desc = "Choose theirs" }

        maps.n.ca = { ":AvanteConflictChooseAllTheirs<CR>", desc = "Choose all theirs" }
        maps.v.ca = { ":AvanteConflictChooseAllTheirs<CR>", desc = "Choose all theirs" }

        maps.n.c0 = { ":AvanteConflictChooseNone<CR>", desc = "Choose none" }
        maps.v.c0 = { ":AvanteConflictChooseNone<CR>", desc = "Choose none" }

        maps.n.cb = { ":AvanteConflictChooseBoth<CR>", desc = "Choose both" }
        maps.v.cb = { ":AvanteConflictChooseBoth<CR>", desc = "Choose both" }

        maps.n.cc = { ":AvanteConflictChooseCursor<CR>", desc = "Choose cursor" }
        maps.v.cc = { ":AvanteConflictChooseCursor<CR>", desc = "Choose cursor" }

        maps.n["]x"] = { ":AvanteConflictPrevConflict<CR>", desc = "Move to previous conflict" }
        maps.v["]x"] = { ":AvanteConflictPrevConflict<CR>", desc = "Move to previous conflict" }

        maps.n["[x"] = { ":AvanteConflictNextConflict<CR>", desc = "Move to next conflict" }
        maps.x["[x"] = { ":AvanteConflictNextConflict<CR>", desc = "Move to next conflict" }
      end,
    },
  },
  opts = {},
  specs = { -- configure optional plugins
    { -- if copilot.lua is available, default to copilot provider
      "zbirenbaum/copilot.lua",
      optional = true,
      specs = {
        {
          "yetone/avante.nvim",
          opts = {
            provider = "copilot",
          },
        },
      },
    },
    {
      -- make sure `Avante` is added as a filetype
      "MeanderingProgrammer/render-markdown.nvim",
      optional = true,
      opts = function(_, opts)
        if not opts.file_types then opts.filetypes = { "markdown" } end
        opts.file_types = require("astrocore").list_insert_unique(opts.file_types, { "Avante" })
      end,
    },
    {
      -- make sure `Avante` is added as a filetype
      "OXY2DEV/markview.nvim",
      optional = true,
      opts = function(_, opts)
        if not opts.filetypes then opts.filetypes = { "markdown", "quarto", "rmd" } end
        opts.filetypes = require("astrocore").list_insert_unique(opts.filetypes, { "Avante" })
      end,
    },
  },
}

@aarnphm
Copy link
Collaborator

aarnphm commented Sep 15, 2024

Oh ok these commands don't exist anymore

AvanteConflictChooseAllTheirs",
    "AvanteConflictChooseBase",
    "AvanteConflictChooseBoth",
    "AvanteConflictChooseCursor",
    "AvanteConflictChooseNone",
    "AvanteConflictChooseOurs",
    "AvanteConflictChooseTheirs",
    "AvanteConflictListQf",
    "AvanteConflictNextConflict",
    "AvanteConflictPrevConflict",

We now replaced all of those with <Plug>(Command) instead. Probably should update upstream with astronvim

@aarnphm
Copy link
Collaborator

aarnphm commented Sep 15, 2024

Ok the astronvim config aside, AstroNvim/astrocommunity#1210

@av1155
Copy link
Author

av1155 commented Sep 18, 2024

Thank you!

@av1155 av1155 closed this as completed Sep 18, 2024
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

4 participants