microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.63k stars 29.04k forks source link

Not fully clear why `export type TextSearchResultNew = TextSearchMatchNew | TextSearchContextNew;` #226713

Open bpasero opened 1 month ago

bpasero commented 1 month ago

Testing #226671

A search result can be either of the 2 types, but I find that a bit strange to operate with. Why wouldn't the context not be referenced from the match? What is the order? Would I first get a context for the line above, then a match and then the line below?

andreamah commented 1 month ago

This is because a single context line can belong to multiple text search match. Therefore, there isn't really a good way to match context lines to matches without repeating info.

To add to this, providers like ripgrep just stream context lines and text results into stdout without matching them to their respective match(es). So It would be the fastest to offer the results as how we do today.

@jrieken also had similar concerns. Perhaps we can use this thread to discuss this.

jrieken commented 1 month ago

providers like ripgrep just stream context lines and text results into stdout without matching them to their respective match(es). So It would be the fastest to offer the results as how we do today.

Unsure if its other providers than ripgrep but generally this is only faster/simpler for them but consumers will pay the price because afaik we have no place in the UI/API where present these bits separated

vs-code-engineering[bot] commented 1 month ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!