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

Add a count argument to seek.seek #305

Open
haberdashPI opened this issue Jul 20, 2023 · 1 comment · May be fixed by #308
Open

Add a count argument to seek.seek #305

haberdashPI opened this issue Jul 20, 2023 · 1 comment · May be fixed by #308

Comments

@haberdashPI
Copy link

I miss vim-sneak. I know that leap is supposed to be an improvement on it, but I personally find it to be worse. I like the minimal number of keys I need to hit (e.g. sab to jump to the first instance of ab), and using ; to advance to the exact pair I want is often faster than reviewing the set of keys I need to hit when using leap.

I think implementing sneak would be pretty easy (much easier than leap): API wise it would involve allowing seek.seek to accept count number of characters (defaulting to 1).

Implementation wise I think it would involve something along the lines of:

export async function seek(
  _: Context,
  inputOr: InputOr<"input", string>,

  repetitions: number,
  direction = Direction.Forward,
  shift = Shift.Select,
  include: Argument<boolean> = false,
  count = 1
) {
  const input = inputOr(() => {
     let keys = ""
     while(count > 0)
        keys += await keypress(_)
        count--
     }
     return result
  })

Happy to take a stab at adding this feature.

@71
Copy link
Owner

71 commented Jul 22, 2023

Sounds good to me! Alternatively I wonder if the handling of "accept multiple keypresses" should be moved into keypress (to avoid disabling and re-enabling input mode), but if the direct approach with keypress in a loop has good UX it's good enough.

@haberdashPI haberdashPI linked a pull request Jul 27, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants