Skip to content

Conversation

@davidot
Copy link

@davidot davidot commented Jan 12, 2026

Content:

This PR fixes one small bug in highlighting and adds two new features.

  • Fixes a case where highlighting does not match actual search.
    How to reproduce: Have a word with capital letters and one all lower case, use * on the capitalized word to search for that one. The search correctly ignores case, but if smartcase is enabled the highlighting incorrectly does not highlight the lower case word.
    Maybe related: VIM-3459 Regression: 'smartcase' should not affect star command

  • Add an option to disable highlighting many matches during incsearch
    This otherwise can massively slow down searching as the IDE tries to highlight all 0s in a csv for example.
    This is protected behind an option ``, but for now I have set the default to 100, WOULD BE CHANGE IN DEFAULT BEHAVIOR (setting it to -1 gets old behavior)
    Related:

    • VIM-3581 Disable search highlight outside editor to avoid search slowdown highlighted in other tool window (e.g. run/debug tool window)
    • VIM-3093 hlsearch+incsearch slow in large files
  • Add option to show matches to search in file showmatchcount this will display a counter and index into the matches while searching, e.g. [13/159] means 159 matches and your at or before match 13.
    Related:

    • VIM-2544 [Feature Request]Show match count after searching

Example:
image
Notice here that I'm searching for "0" in the left editor, the left file show matches because there are only 8 (see right part of command bar). The right file has 1000+ matches so shows nothing, meaning no hiccups while typing "01" for example.
Also visible in the middle bottom is the counter for matches in the files and the current index in the matches for that file.

Once you press enter the "protection" is gone, meaning to only a single slowdown in this case
image

After that I clicked on the right side and you can see what the search counter looks like when the entry is not active (maybe it should have a border on the left side?)

Review

Please feel free to school me on anything Kotlin, this is my first time using the languages, just tried to match the patterns I saw in other files.

Also I really tried adding tests for option 2 & 3 but I had to mock so much I gave up, if there is a good/easy way to do it would love to hear it.

This manifests in the highlighting of search results, when * on a word with capitals
smartcase was (correctly) ignored for the actual search but the highlights did use
smartcase.
This can otherwise lead to great slowdown particularly during initial typed letters.
Because with incsearch highlighting is triggered and block, this means starting your
search will highlight up to thousands of the same character only refined later.
With this new setting this skips highlighting (during incsearch only) when above
threshold, or keeps old behavior if set to -1.
Controlled by new option `showmatchcount`.
If enabled shows current/total matches in the main file being edited.
For example [2/10] means 10 totals matches and your past match 1 and in or before
match 2 in the file.
The count is follows the active focussed editor around.
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.

1 participant