wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

Add SearchForwardRelativeToCursor, SearchBackwardRelativeToCursor keyassignments to CopyMode

Open mgpinf opened this issue 7 months ago • 6 comments

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

mgpinf avatar Jun 01 '25 14:06 mgpinf

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 avatar Jun 01 '25 15:06 bew

@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

mgpinf avatar Jun 02 '25 13:06 mgpinf

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.

9999years avatar Nov 18 '25 23:11 9999years

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',
  }
}

mgpinf avatar Nov 20 '25 10:11 mgpinf

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?

bew avatar Nov 20 '25 11:11 bew

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?

mgpinf avatar Nov 20 '25 16:11 mgpinf