nvim-pack / nvim-spectre

Find the enemy and replace them with dark power.
MIT License
1.91k stars 67 forks source link

[Bug]The search is for the last selection when search selected strings in the current file #200

Closed DreamMaoMao closed 6 months ago

DreamMaoMao commented 6 months ago

keymap:

vim.keymap.set("v", "<leader>ro", '<cmd>lua require("spectre").open_file_search()<CR>', {
  desc = "Search selected str in current file",
})

https://github.com/nvim-pack/nvim-spectre/assets/30348075/9dfc32ad-c1a8-4b82-91cb-e71d67c54f32

in the video,you can see:

  1. when I select apple string to toggle search current file, it will search nothing first time.
  2. when I select orange string to toggle search current file,it will searh apple string.
  3. when i select apple string to toggle search current file again.it will search orange string.

    It always searches for the last selected string instead of the current selected string.

DreamMaoMao commented 6 months ago

have resolved by add <esc>

vim.keymap.set("v", "<leader>ro", '<esc><cmd>lua require("spectre").open_file_search()<CR>', {
  desc = "Search selected str in current file",
})