Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Flash remains active after {action}{motion — 't'/'T', 'f/F'} is completed #6

Closed
3 tasks done
svranesevic opened this issue Jun 21, 2023 · 11 comments · Fixed by #86
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@svranesevic
Copy link

Did you check docs and existing issues?

  • I have read all the flash.nvim docs
  • I have searched the existing issues of flash.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.9.1

Operating system/version

MacOS 12.2.1

Describe the bug

When using {action}{motion — 't'/'T', 'f/F'} — eg. yank until opening parentheses yt(, flash.nvim remains active after motion is completed.

Steps To Reproduce

  1. Open new buffer and paste:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
  1. Go to first character
  2. Execute {action}{motion}: yt,
  3. "Lorem ipsum dolor sit amet" is yanked to register
  4. 🐛 flash.nvim remains "active" like when it is invoked with 't'/'T', 'f/F' alone

Expected Behavior

When using {action}{motion — 't'/'T', 'f/F'}, flash.nvim is not active after motion is completed.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  { "folke/flash.nvim", opts = {} },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
vim.cmd.set("clipboard=unnamedplus")
@svranesevic svranesevic added the bug Something isn't working label Jun 21, 2023
@folke
Copy link
Owner

folke commented Jun 21, 2023

That's on purpose. When moving, changing buffers, pressing <esc> or doing anything else, the highlights will clear.

@folke folke closed this as not planned Won't fix, can't repro, duplicate, stale Jun 21, 2023
@svranesevic svranesevic changed the title bug: bug: Flash remains active after {action}{motion — 't'/'T', 'f/F'} is completed Jun 21, 2023
@ranebrown
Copy link

Is there any way this could be made a configurable option? I frequently use yt<char> and yf<char> and it is confusing when the backdrop and labels remain and it is an extra step to hit escape or intentionally move the cursor.

@folke folke reopened this Jun 27, 2023
@triorph
Copy link

triorph commented Jun 27, 2023

Also found this a bit annoying. For example if you do something like dt( it remains in jump mode, but if you continue to move with ; etc then it will move, not work on the delete. I assume this can just be disabled by having the 'f'/'F'/'t'/'T' keys not using flash in operator pending mode?

edit: also it appears that ESC does not clear the highlights from 'f' highlight mode, which definitely doesn't help

@folke
Copy link
Owner

folke commented Jun 28, 2023

I'll make it configurable.

To repeat a delete, use . instead of ;.

@triorph highlights should clear on <esc> did you map <esc> in your install by any chance? What does :map <esc> say?

@folke folke closed this as completed in feda1d5 Jun 28, 2023
@folke
Copy link
Owner

folke commented Jun 28, 2023

Flash now hides when yanking with an ftFT motion

@rasulomaroff
Copy link

@folke as far as I can see that feature only applies to "yank" operation. Is it possible to make it work with "delete" as well?

@triorph
Copy link

triorph commented Jun 28, 2023

🤦 yeah I was mapping to something else. My bad. I think I agree with rasulomaroff though that it'd be nice to change this behaviour for d as well as y. In fact I think its only really helpful for v so that'd be my preference. Even just as a configurable option would be good.

@folke
Copy link
Owner

folke commented Jun 29, 2023

This is now configurable.
Check the docs for opts.modes.char.autohide.

While you're at it, I also invite everyone to try the new ftFT smart label mode :)

 opts = {
      modes = {
        char = {
          jump_labels = function(motion)
            -- never show jump labels by default
            -- return false
            -- Always show jump labels for ftFT
            return vim.v.count == 0 and motion:find("[ftFT]")
            -- Show jump labels for ftFT in operator-pending mode
            -- return vim.v.count == 0 and motion:find("[ftFT]") and vim.fn.mode(true):find("o")
          end,
        },
      },
    },

It combines ftFT searches with labels. You can still navigate clever-f style or use ;, , as well. A lot of labels are also excluded, so you can continue from the new position with any key like hjklia...

It pretty much combines the best of both worlds :)
you can also only enable it for operator pending mode or any other conditions.

Let me know what you think!

@rasulomaroff
Copy link

@folke I think I'm gonna need to take some days off to configure flash for me 🤣

This gets it work as expected:

autohide = function(motion)
  -- autohide flash when the operator is `y` or `d`
  return vim.fn.mode(true):find 'no' and (vim.v.operator == 'y' or vim.v.operator == 'd')
end

About jump_labels - I've tried and I like it! But I wonder why label.after not working there :) I would like to put a label right after the symbol I'm searching for. Here's my config for the char mode:

char = {
  autohide = function(motion)
    -- autohide flash when the operator is `y` or `d`
    return vim.fn.mode(true):find 'no' and (vim.v.operator == 'y' or vim.v.operator == 'd')
  end,
  jump_labels = function(motion)
    return vim.v.count == 0 and motion:find '[ftFT]' and vim.fn.mode(true):find 'o'
  end,
  label = { exclude = 'iardc', after = { 0, 1 } },
}

@dpetka2001
Copy link

Hi @rasulomaroff did you find a solution about the labels being shown after the symbol that you're searching for?

@rasulomaroff
Copy link

@dpetka2001 not really. Just checked it, still not applied. But should it at all? I'm not sure about that, but would be nice to have 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants