Skip to content

Some operators are still applied even when no textobject was found #1942

@TheLeoP

Description

@TheLeoP

Contributing guidelines

Module(s)

mini.ai

Neovim version

0.11.x

Description

Some builtin Neovim operators (and some custom operators) do perform an action when executed with a opertor-pending mode keymap that doesn't move the cursor nor visually selects any region. d doesn't delete anything, but empties the content of the " register (just like y). c starts insert mode in current location (just like if i was pressed). Linewise operators like > still indent the whole line, etc.

When mini.ai can't find a textobject, it behaves in the aforementioned way.

Reproduction

  1. Create separate 'nvim-repro' config directory:

    • '~/.config/nvim-repro/' on Unix
    • '~/AppData/Local/nvim-repro/' on Windows
  2. Inside 'nvim-repro' directory create a file named 'init.lua'.
    Populate it with the following content:

    -- Clone latest 'mini.nvim' (requires Git CLI installed)
    vim.cmd('echo "Installing `mini.nvim`" | redraw')
    local mini_path = vim.fn.stdpath('data') .. '/site/pack/deps/start/mini.nvim'
    local clone_cmd = { 'git', 'clone', '--depth=1', 'https://github.com/echasnovski/mini.nvim', mini_path }
    vim.fn.system(clone_cmd)
    vim.cmd('echo "`mini.nvim` is installed" | redraw')
    
    -- Make sure 'mini.nvim' is available
    vim.cmd('packadd mini.nvim')
    require('mini.deps').setup()
    
    -- Add extra setup steps needed to reproduce the behavior
    -- Use `MiniDeps.add('user/repo')` to install another plugin from GitHub
  3. Run NVIM_APPNAME=nvim-repro nvim (i.e. execute nvim with NVIM_APPNAME environment variable set to "nvim-repro"). Wait for all dependencies to install.

  4. i"foo"<esc> to write "foo" in the current buffer

  5. yy and then p to copy "foo" and paste it

  6. yi'. An error message will be displayed explaining that no textobject i' could be found

  7. p to paste. Nothing will be pasted

Note. the same can be tested with the other operators mentioned above, not only y.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions