chrisgrieser / nvim-rip-substitute

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

Bug: No match found #8

Closed c30ra closed 1 month ago

c30ra commented 1 month ago

Make sure you have done the following

Bug Description

When type in the popup the regex no matches are found

Relevant Screenshot

Schermata_20240629_135212

To Reproduce

ripgrep is present with pcre2 and jit

❯ rg --pcre2-version
PCRE2 10.42 is available (JIT is available)

neovim version

0.10
chrisgrieser commented 1 month ago

Hmm, the only potential cause for this I can think of is that you haven't saved your buffer to the file (:w).

If that is not the case, could you try a reproducible config? (Save as repro.lua and run with nvim -u repro.lua.)

local spec = {
    {
        "chrisgrieser/nvim-rip-substitute",
        opts = {}, -- insert config here
        keys = {
            {
                "gs",
                function() require("rip-substitute").sub() end,
                mode = { "n", "x" },
                desc = "rip substitute",
            },
        },
    },
}
--------------------------------------------------------------------------------
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 }
c30ra commented 1 month ago

that's it... i tried it in a non saved buffer to see if everything is working. On saved buffers it work. Thanks for the quick reply!!

chrisgrieser commented 1 month ago

no problem! Nonetheless, this bug report was still helpful. I made a small update that ensures the buffer is being written when rip-substitute is called, so that this issue should not occur again.

c30ra commented 1 month ago

It's not possible to pass directly the buffer content to rg? Maybe using echo? if i do: echo some string | rg --column --line-number --only-matching some it gets the results.

chrisgrieser commented 1 month ago

yeah, passing the buffer content as stdin is possible. But simply writing the buffer is a bit simpler code-wise. (And it's also better performance-wise, since this plugins calls rg a lot, and iirc, rg has a caching mechanism for when repeatedly reading from the same file)