smoka7 / multicursors.nvim

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

Multicursor is broken in insert mode in Neovim v0.10.0-dev #67

Closed Andrew15-5 closed 10 months ago

Andrew15-5 commented 10 months ago

Describe the bug I needed to switch to latest Neovim version and now suddenly this plugin only inserts at 1 location instead of all locations. I thought that I broke something, or there is a bug in recent update, or I need to update NvChad or I need to remove some other plugins. After 2 minutes, I finally realized that it has to do with a new dev version of Neovim. I have no idea what causes this bug, but if the non-dev version will still behave the same way, then this plugin won't be compatible with Neovim v0.10.0. You probably should look into this.

To Reproduce You have to have docker and docker compose commands available on your host OS (and possibly just).

  1. cd "$(mktemp -d)"
  2. Download multicursors.zip
  3. unzip multicursors.zip
  4. cd multicursors
  5. just (j alias) or the shell code line inside the justfile
  6. wait until you are in Neovim and already selected 4 words
  7. press ia

Expected behavior a should appear in all selected location instead of just one.

Screenshots End of step 6: image i: image a: image

Nvim version: 0.10.0-dev (v0.10.0-dev-64c2c7c)

Multicursor version: 0.10.1

Additional context This bug also causes an auto-save plugin to stop auto saving. Only nvim re-open will fix this.

smoka7 commented 10 months ago

I can't reproduce this in latest nvim nightly release.

Andrew15-5 commented 10 months ago

@smoka7, try following an updated reproduction instruction.

smoka7 commented 10 months ago

Our test are passing in the nvim nightly and stable https://github.com/smoka7/multicursors.nvim/actions/runs/6957221416 .

Andrew15-5 commented 10 months ago

You know that test don't always represent reality. Try my steps and tell why manual/realistic test fail, but automatic/headless test succeed.

tests/custom.lua ```lua local utils = require 'multicursors.utils' local search = require 'multicursors.search' local insert_mode = require 'multicursors.insert_mode' local config = require 'multicursors.config' local api = vim.api local assert = require 'luassert' local paragraph = { 'word', 'word', 'word', 'word', } describe('inserts mode', function() before_each(function() vim.cmd [[enew]] api.nvim_buf_set_lines(0, 0, -1, false, paragraph) local buffer = api.nvim_buf_get_lines(0, 0, -1, false) search.find_all_matches(buffer, 'word', 0, 0) vim.cmd [[w! before]] end) after_each(function() vim.cmd [[w! after]] vim.cmd.bdelete { bang = true } end) it('inserts text', function() local selections = utils.get_all_selections() assert.equal(#selections, 3) insert_mode.insert(config) vim.cmd 'normal! ia ' insert_mode.exit() local buffer = api.nvim_buf_get_lines(0, 0, -1, false) utils.clear_selections() search.find_all_matches(buffer, 'a word', 0, 0) selections = utils.get_all_selections() assert.equal(#selections, 3) end) end) ```
# Doesn't fail
nvim --headless --noplugin -u tests/minimal_init.lua -c 'PlenaryBustedFile tests/custom.lua'

In Dockerfile I added version argument:

ARG version=nightly # nightly|stable
RUN wget https://github.com/neovim/neovim/releases/download/$version/nvim.appimage \

If I use nightly (v0.10.0) then the test fails, if I use stable (v0.9.4) then the test succeeds. I literally only change the version of Neovim and result changes, therefore your test doesn't represent real UX (even though I like how automatic tests are run/executed).

smoka7 commented 10 months ago

Your test passes on my machine and even on the ci https://github.com/smoka7/multicursors.nvim/pull/71.

Andrew15-5 commented 10 months ago

Your test passes on my machine and even on the ci #71.

Of course it passes, I said so myself:

# Doesn't fail
nvim --headless --noplugin -u tests/minimal_init.lua -c 'PlenaryBustedFile tests/custom.lua'

This is an automatic test that works on both versions. The only test that doesn't pass is the manual one, source for which is in the multicursors.zip (included in the OP).

smoka7 commented 10 months ago

I meant both tests also. Nothing I can do about this.

Andrew15-5 commented 10 months ago

I meant both tests also

So you are saying that you (just to be 100% clear):

  1. downloaded the zip;
  2. run the shell oneliner that builds Docker image and runs/creates the container;
  3. inside the container and inside the automatically opened Neovim with the simple test case pressed ia;
  4. and in the end all 4 lines were modified (not just one)?

This sounds impossible, since the whole point of creating the Docker image + container is to eliminate all variables. So we both have to have the same experience inside the container. I specifically re-build the image with --no-cache just now, and the issue still persists with version=nightly.

Andrew15-5 commented 9 months ago

I updated the zip archive. Now you can either write just or just nightly (or just n) to open the file in Neovim nightly version. Or you can write just stable (or just s) to open the file in Neovim stable version. With just the plugin does not work as expected. With just stable the plugin does work as expected.

Here is a screen record:

https://github.com/smoka7/multicursors.nvim/assets/37143421/4ec25583-567e-4b17-95f8-e0ec6678b39d

P.S. Now you only have to download both versions of Neovim once and use either nvim-stable or nvim-nightly wrapper. And the control over many things is more granular. You can modify the file and the Neovim command when running just nightly or just stable.

doongjohn commented 9 months ago

I'm having the same issue with the nightly version

smoka7 commented 9 months ago

I reproduced this today, for a fix update hydra to latest commit https://github.com/smoka7/hydra.nvim or disable hints.