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

Next match #2279

Merged
merged 12 commits into from Jul 29, 2018
Merged

Next match #2279

merged 12 commits into from Jul 29, 2018

Conversation

ricksladkey
Copy link
Collaborator

@ricksladkey ricksladkey commented Jul 26, 2018

Changes

  • Add the capability for the search service to include the start point in the search
  • Add the gn and gN family of key bindings
  • Implement 'next match' motion for operators in normal mode
  • Implement 'select next match' operation from normal mode
  • Implement 'extend selection to next match' from visual mode

Issues

let isForward = path = SearchPath.Forward
MotionResult.Create(span, motionKind, isForward) |> Some

_vimData.ResumeDisplayPattern()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed here? I didn't see anything obvious in this function that would kill the display pattern here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unable to leverage x.SearchCore because the semantics were so different, but I did use it as a reference as if I were using it. In this case, ResumeDisplayPattern is the second to last line of x.SearchCore.

My assumption is that if the user has manually disabled hlsearch that any kind of search continuation should reenable it. In other words, gn has the same semantics relative to hlsearch as n does.

let checkOptions = findData.FindOptions &&& (~~~FindOptions.SearchReverse)
let checkFindData = FindData(findData.SearchString, snapshot, checkOptions, findData.TextStructureNavigator)
match x.FindNextRaw checkFindData position with
| Some matchSpan ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using when here. I think it makes it a bit more concise. I've actually becoming a bigger fan of when after reviewing your PRs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of my goal for contributing to VsVim is to get more real-world experience programming F#. One of the side effects of writing a lot of code is gradually learning about language features and formulating opinions about them.

The nuance I now understand about when with `match is that it subverts "exhaustive matching". That is fine when you are trying to do a match for one thing with an additional condition. But it always has to be weighed against the security of exhaustive matching.

In this case, Some/None matching will never be expanded to include a third option and so it is a good candidate for match/when.

@jaredpar
Copy link
Collaborator

Really excited about this motion. It's something I've wanted for a while now.

@jaredpar jaredpar merged commit 598a453 into VsVim:master Jul 29, 2018
@ricksladkey ricksladkey deleted the next-match branch July 30, 2018 01:48
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 this pull request may close these issues.

None yet

2 participants