MagicDuck / grug-far.nvim

Find And Replace plugin for neovim
MIT License
713 stars 20 forks source link

`with_visual_selection()` cannot detect current visual word #212

Closed Jaehaks closed 1 month ago

Jaehaks commented 1 month ago

Thank you for your efforts,

I tried to call with_visual_selection() but it detect the word next function call.

the keymap setting is

vim.keymap.set('x', '<leader>sw', function ()
  grugfar.with_visual_selection({
    prefills = {
      paths = vim.fn.expand('%')
    }
  })
end, { desc = "Search on current file" })

process is like this 1) visualize some word 2) call grugfar.with_visual_selection() with shortcut => there are no word in search field 3) quit the window 4) visualize some other word second time 5) call grugfar.with_visual_selection() with shortcut => search field is filled with the word is visualized at 1)

MagicDuck commented 1 month ago

Thanks for reporting! It's one of the visual selection mode quirks. Should be fixed now! 😄 Pls reopen if you still see problems.

MagicDuck commented 1 month ago

Btw, also calling just grugfar.grug_far() will handle visual selection correctly for you in visual mode. with_visual_selection() was added more as a workaround for command mode bindings since some people like to do:

:lua require('grug-far').with_visual_selection()

But in any case, they should both work correctly now 😄