chrisgrieser / nvim-rip-substitute

Perform search and replace operations in the current buffer using a modern user interface and contemporary regex syntax.
MIT License
160 stars 7 forks source link

Bug: Crashes on `nt` mode with filetype `toggleterm` #22

Closed sharpchen closed 3 hours ago

sharpchen commented 4 hours ago

Make sure you have done the following

Bug Description

Crashes on nt mode with filetype toggleterm for accidental hit

EDIT: can be solved by autocmd though, I am not sure does it make any sense to subsitute on nt mode?

Relevant Screenshot

image

To Reproduce

  1. open a toggleterm
  2. scroll to enter nt mode
  3. hit the keymap of raise rip-substitute
  4. see error

Sample Text

No response

neovim version

NVIM v0.10.0

ripgrep version

ripgrep 14.1.0

Minimal reproducible config

local spec = {
  {
    'chrisgrieser/nvim-rip-substitute',
    cmd = 'RipSubstitute',
    keys = {
      {
        '\\',
        function()
          require('rip-substitute').sub()
        end,
        mode = { 'n', 'x' },
        desc = ' rip substitute',
      },
    },
    opts = {
      popupWin = {
        matchCountHlGroup = '@variable.parameter',
        noMatchHlGroup = '@variable.member',
        position = 'top',
        hideSearchReplaceLabels = true,
        border = 'rounded',
      },
      keymaps = { -- normal & visual mode, if not stated otherwise
        prevSubst = '<C-p>',
        nextSubst = '<C-n>',
      },
    },
  },
  {
    'akinsho/toggleterm.nvim',
    version = '*',
    init = function() end,
    config = function()
      require('toggleterm').setup({
        start_in_insert = true,
        direction = 'float',
        float_opts = {
          border = 'rounded',
        },
      })
    end,
  },
}

--------------------------------------------------------------------------------
vim.env.LAZY_STDPATH = "./nvim-repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro { spec = spec }
chrisgrieser commented 3 hours ago

Weird, the popup works for me, but it fails only later on, cause a terminal buffer is simply not writable.

Anyway, I added a check to prevent rip-substitute from running in non-modifiable buffers, so this should be fixed.