question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Search refactor proposal

See original GitHub issue

So I’ve been thinking about this over sleep 😴. There are a number of search related issues:

  1. multiple finds on same line #1763
  2. search as you type #1660 - PR #1826
  3. return number of results i.e 1 of 24 (how vscode editor search behaves) #1659
  4. 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:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Tyriarcommented, Dec 12, 2018
0reactions
Tyriarcommented, Oct 11, 2021

We can consider this while doing https://github.com/xtermjs/xterm.js/issues/1653, merging

Read more comments on GitHub >

github_iconTop Results From Across the Web

Finding and refactoring code | Apple Developer Documentation
Search your code for text, patterns, and symbols that you can refactor quickly ... Click a proposed renaming instance to toggle whether Xcode...
Read more >
Code Refactoring Best Practices: When (and When Not) to Do It
When you don't need refactoring; Best practices for code refactoring. Refactor first before adding any new features; Plan your refactoring ...
Read more >
Model refactoring by Example: A Multi-Objective Search ...
we proposed a by example approach that recommends refactorings to correct models. ... Other optimization goals were considered in search-based refactoring ...
Read more >
A survey of search-based refactoring for software maintenance
This survey reviews published materials related to the specific area of Search-Based Software Engineering that concerns software maintenance ...
Read more >
(PDF) Search-based refactoring: An empirical study
Recently, search-based approaches to automating the task of software refactoring have been. proposed by the authors [26] and Seng et al [29] ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found