Add SearchForwardRelativeToCursor, SearchBackwardRelativeToCursor keyassignments to CopyMode
When in CopyMode, when we want to search for a pattern, it is useful to activate the first result before or after the current cursor position. This is similar to the behavior in vim. Resolves:
- Point 3 mentioned in https://github.com/wezterm/wezterm/issues/5952#issue-246440134
- https://github.com/wezterm/wezterm/issues/5236
Hello!
What do you think about having a single SearchRelativeToCursor with parameter for direction, or even merge all into the existing Search action with new parameters?
@bew I have updated the PR. Can you check? I have used a separate KeyAssignment ExtendedSearch because the Search KeyAssignment currently accepts only one parameter
I've built and tested this patch locally and it works very nicely. I'm not 100% sure about the API (I'd probably prefer to have this as a new mode for the existing act.Search) but it's a big improvement from the current state.
I have merged all the new parameters into the existing Search action
Now, the Search action takes one more pattern called Extended where we can
specify the match position to activate and all options previously
specified against Search
The old API introduced in this PR looked like below:
local act = wezterm.action
act.ExtendedSearch {
pattern = { CaseSensitiveString = selection_text },
activate_match = activate_match,
}
The new API is as shown below:
local act = wezterm.action
act.Search {
Extended = {
pattern = 'CurrentSelectionOrEmptyString',
activate_match = 'AfterCursor',
}
}
Hello! Could you describe what this Extended 'mode' (?) does is for? When should I use it compared to normal search?
Now that it's integrated in Search, would it be possible to merge the 2 instead of making a kind of additional search system in Search?
I had used Extended because I wanted to be able to specify multiple parameters like pattern and match to activate. Can you suggest an example of how the API might look like if they are merged?