FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(search): show current and total matches in copy mode search by felix314159 · Pull Request #5399 · tmux/tmux · GitHub

/ tmux Public

feat(search): show current and total matches in copy mode search - #5399

Open
felix314159 wants to merge 3 commits into
tmux:masterfrom
felix314159:master
Open

feat(search): show current and total matches in copy mode search#5399
felix314159 wants to merge 3 commits into
tmux:masterfrom
felix314159:master

Conversation

Copy link
Copy Markdown

The one thing I always disliked about tmux was how when searching it would say e.g. '53 results' and you would not know whether you are looking at result 30/53, 45/53 or 53/53. This PR fixes the behavior to match what you would expect from any popular browser:

  • "Phrase not found" for zero matches
  • "1 of 1 match" for one match
  • "N of M matches" for multiple matches

So this PR tracks the current copy-mode search match and exposes it through the search_count_current format variable. The current match remains accurate across forward and backward navigation, wraparound, cursor movement, resizing, and both vi and emacs copy modes. Partial counts continue to be shown as "N+ matches". I also added regression coverage for the new formatting and navigation behavior.

nicm commented Jul 15, 2026

Copy link
Copy Markdown
Member

Some comments:

I think searchpositions doesn't need to be uint64_t and could probably be u_int (obviously you need to check the positions will fit and in the event they don't, don't track).

I think you should probably shorten all the names to searchpos or matchpos since stuff like searchpositionallocated is very long. You have a fair few lines >80 columns that need to be shortened.

If we do an early stop, searchpositions is set to NULL but a NULL causes us to do a full check if we search again instead of a partial check. This is going to be slower.

nicm moved this from Not Started to Waiting in Open Issues & PRs Jul 15, 2026
Use bounded u_int values for match positions and shorten the tracking names. Preserve a non-NULL marker after partial searches to avoid repeating a full-history scan.

Copy link
Copy Markdown
Author

thanks for the feedback! should be fixed now. lmk if there is anything else to do

nicm commented Jul 16, 2026

Copy link
Copy Markdown
Member

OK works well, but I don't like "Phrase not found", can it just say "0 matches", everyone knows what "0" means, right?

I think a helper function to do the xreallocarray like window_copy_grow_searchpos might be nice because that code is very nested now.

Copy link
Copy Markdown
Author

i agree, '0 matches' is a bit cleaner. i had copied what firefox does so that's where the 'phrase not found' came from in case you were wondering :) helper function is also introduced now

nicm moved this from Waiting to For Review in Open Issues & PRs Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: For Review

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL