folke / flash.nvim

Navigate your code with search labels, enhanced character motions and Treesitter integration
Apache License 2.0
2.22k stars 27 forks source link

bug: Cannot disable Enhanced f/t motions when f/t is remapped #329

Open amesaine opened 2 months ago

amesaine commented 2 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.9.4

Operating system/version

Debian 12

Describe the bug

t is remapped to something else. In this case, to flash.jump()

On the very first time of entering a file in neovim, pressing t properly calls flash.jump(). Any subsequent presses of t invokes the enhahced t motions. The enhanced t motions are disabled properly if jump were remapped to anything else like b. These are all true as well when done with f.

{
  "folke/flash.nvim",
  event = "VeryLazy",
  ---@type Flash.Config
  opts = {
       modes = {
          char = { enabled = false },
      },
  },
  keys = {
      { "t", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" },
  },
},

I've also tried to set the keymaps like so but no fixes.

config = function()
    vim.keymap.set({ "n", "x", "o" }, "t", function()
        require("flash").jump()
    end)
end

Steps To Reproduce

  1. Remap t.
  2. Open nvim
  3. Open a file
  4. Press t
  5. flash.jump() is invoked
  6. Exit out of jump mode.
  7. Press t again.
  8. It now acts as enhanced t motions.

Expected Behavior

Pressing t should always invoke flash.jump() and not revert back to enhanced t motions.

Additional

i have modes = { search = { enabled = false } } and it also suffers from this. Once behavior regresses back to enhanced motions, it seems that the plugin options are all reset. This is only triggered when using the remapped t or f.