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

feature: exclusive operator #49

Closed
1 task done
musjj opened this issue Jun 24, 2023 · 10 comments · Fixed by #48
Closed
1 task done

feature: exclusive operator #49

musjj opened this issue Jun 24, 2023 · 10 comments · Fixed by #48
Labels
enhancement New feature or request

Comments

@musjj
Copy link

musjj commented Jun 24, 2023

Did you check the docs?

  • I have read all the flash.nvim docs

Is your feature request related to a problem? Please describe.

When doing directional jumps in an operator pending mode, like this:

require("flash").jump {
  search = { forward = true, wrap = false, multi_window = false },
}

You sometimes want to exclude the target from the operation, similar to operations like dtw

Describe the solution you'd like

An option to make the jump behave like an exclusive operator.

Describe alternatives you've considered

Currently, I don't think there's an option that can simulate this behavior.

Additional context

No response

@musjj musjj added the enhancement New feature or request label Jun 24, 2023
@folke folke closed this as completed in e71efbf Jun 24, 2023
@folke
Copy link
Owner

folke commented Jun 24, 2023

I added a new option opts.jump.inclusive
By default it is nil meaning it will be automatically set based on the mode you're in.

You can set it to true/false to force inclusive/exclusive

@musjj
Copy link
Author

musjj commented Jun 24, 2023

Thanks, but it seems that the snippet in my original post no longer works (it doesn't seem to do anything). A plain require("flash").jump() still works, though.

@folke
Copy link
Owner

folke commented Jun 24, 2023

Damn, you're right. On it

@folke
Copy link
Owner

folke commented Jun 24, 2023

Fixed now. Sorry about that :)

@musjj
Copy link
Author

musjj commented Jun 24, 2023

Thanks, it's working! But with backward jumps, it seems that it always jumps to the beginning of the match.

For example, using the following config:

require("flash").jump(
    search = { forward = false, wrap = false, multi_window = false },
    jump = { inclusive = false }
)

With the following text, the cursor at ^

The quick brown fox jumped over the lazy dog.
                               ^

While using the d operation, and the candidate ed, you will get:

- The quick brown fox jumped over the lazy dog.
+ The quick brown fox jump the lazy dog.

What I expect:

- The quick brown fox jumped over the lazy dog.
+ The quick brown fox jumped the lazy dog.

@folke folke reopened this Jun 24, 2023
@folke
Copy link
Owner

folke commented Jun 24, 2023

You should add jump.pos = "end"

@folke folke closed this as completed Jun 24, 2023
@musjj
Copy link
Author

musjj commented Jun 24, 2023

Thank you! With this, flash.nvim has reached feature-parity (plus more) with leap.nvim :)

@musjj
Copy link
Author

musjj commented Jun 24, 2023

Sorry for being a party pooper, but it turns out that it's still not working quite right.
The following performed on operator-pending mode:

require("flash").jump { 
  search = { forward = false, wrap = false, multi_window = false },
  jump = { inclusive = false, pos = "end" },
}

Doesn't exclude the last character of the match.

@folke folke reopened this Jun 24, 2023
@folke
Copy link
Owner

folke commented Jun 24, 2023

I added jump.offset, but when using pos="end" and the jump position is before the current position, it will default to 1.

You also probably still want to use inclusive mode.

So you should change it to:

require("flash").jump { 
  search = { forward = false, wrap = false, multi_window = false },
  jump = { pos = "end" },
}

This should now work as expected.

Let me know if it does! :)

@musjj
Copy link
Author

musjj commented Jun 25, 2023

Thanks, it's working perfectly!

@musjj musjj closed this as completed Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants