Search refactor proposal
See original GitHub issueSo I’ve been thinking about this over sleep 😴. There are a number of search related issues:
- multiple finds on same line #1763
- search as you type #1660 - PR #1826
- return number of results i.e 1 of 24 (how vscode editor search behaves) #1659
- show all search ranges and introduce new selection type #1653
#1826 introduces the concept of a lineCache with a ttl, that the search creates when findNext/findPrevious are called. Even with 10,000 lines in buffer, it’s quite fast to scan the entire buffer for search results.
I propose we refactor search to fix multiple issues and yet make it elegant.
implement a getRangesForSearchTerm(term:string, searchOptions: ISearchOptions): IRange[]
for the same search term, findNext/findPrevious goes to the adjacent IRange and highlights the selection.
if the term is not the same as last one, then we call getRangesForSearchTerm(…) and move the highlight to the adjacent range depending on whether search was incremental or not.
VSCode / other clients can also use the IRange results to show scrollbar decorations of where search matched.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:7 (6 by maintainers)
Top GitHub Comments
Forked that discussion to https://github.com/xtermjs/xterm.js/issues/1836
We can consider this while doing https://github.com/xtermjs/xterm.js/issues/1653, merging