-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Finding multiple instances on the same line #1763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/addons/search/Interfaces.ts
Outdated
| regex?: boolean; | ||
| wholeWord?: boolean; | ||
| caseSensitive?: boolean; | ||
| matchMultiple?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should just maybe always be on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, removing from ISearchOptions.
src/addons/search/SearchHelper.ts
Outdated
| * @param searchOptions search options, | ||
| * @return An array of matches or first match. | ||
| */ | ||
| private _getNextMatch(term: string, searchString: string, row: number, searchOptions: ISearchOptions): ISearchResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of reimplementing a bunch of the search stuff, could we start the search at the end of the current selection? Instead of the current master behavior which is to start the search on the line following the selection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not so sure about this one.
Instead of the current master behavior which is to start the search on the line following the selection
The part that starts the search is this -
xterm.js/src/addons/search/SearchHelper.ts
Lines 41 to 43 in fc8640a
| // Search from ydisp + 1 to end | |
| for (let y = startRow + 1; y < this._terminal._core.buffer.ybase + this._terminal.rows; y++) { | |
| result = this._findInLine(term, y, searchOptions); |
I think i'll start by changing this part. then I'll have to somehow ignore the prefix of the line (what comes before the current selection).
@Tyriar , Is this the right direction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the huge delay, I was on vacation. Yes this is the right approach 👍
src/addons/search/search.test.ts
Outdated
| const find4 = term.searchHelper.findInLine('aa', 1, searchOptions); | ||
| const find5 = term.searchHelper.findInLine('aa', 1, searchOptions); | ||
| expect(find0).eql({col: 0, row: 0, term: 'aa'}); | ||
| expect(find1).eql({col: 1, row: 0, term: 'aa'}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My expectation is for the second search to give col: 9. Another example:
Searching aaaa first would highlight the first two, searching again would highlight the last 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, removing the "overlapping term" implementation.
start search from current selection. add unit tests.
7cd6e8a to
376c790
Compare
|
Hi @Tyriar . I'll appreciate if you can review my PR. some concerns:
Thanks |
|
@noamyogev84 btw it's much easier to review with GitHub when you don't rebase as I can't review just the new changes now. |
src/addons/search/Interfaces.ts
Outdated
| regex?: boolean; | ||
| wholeWord?: boolean; | ||
| caseSensitive?: boolean; | ||
| reverseSearch?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this being added? Seems to be complicating the changes an awful lot and there isn't a request for such a feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tyriar Hi...
I removed the reverseSearch option from ISearchOptions. but I have to somehow provide this option to findInLine. don't you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused, we don't want to do any "reverse" searching afaict, say the selection is at (5,5), we want to:
- Do a search from (5,5) to the end of the line
- Search all following lines until the end
- Search each line from the start to (0,5)
- Search from (0,5) to (4,5)
When a result is hit, we want to do a forward search on the same line from the end of the result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly what i do when findNext is called. but what about findPrevious?
What is your expectation if let's say there's a selection on (5,5) and the user is clicking on the find previous button?
I guess what i'm saying is that now, I need to be able to find multiple matches in the same line going backwards, and that logic is within findInLine.
Sorry for the confusion here.... :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you're totally right, I agree wholeheartedly with this now 😄:
I removed the reverseSearch option from ISearchOptions. but I have to somehow provide this option to findInLine. don't you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad to hear that!
So assuming you prefer the option where ISearchOptions doesn't contain reverseSearch, and we pass it separatly to findInLine, Are there any more changes required? I'll appreciate your review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tyriar pinging you once more. :)
Do you think we can move forward with this? any changes required?
add isReverseSearch argument to findInLine modify unit tests
Tyriar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience with this, finally got around to looking at it again and merging in the latest changes (some big conflicts with incremental search being added).
src/addons/search/SearchHelper.ts
Outdated
| if (result) { | ||
| break; | ||
| // Search startRow | ||
| result = this._findInLine(term, { row: startRow, col: startCol }, searchOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make a change to remove the ISearchIndex object and just pass in the raw values. The reason being that a search over 10000 lines would create 10000 objects that basically immediately get discarded, so it's not worth the added niceness of named params.
|
@noamyogev84 thanks again 😃, pulling into VS Code here microsoft/vscode#65711 |
|
@Tyriar it was a great experience! Thanks. |
Fixes #1654
Description of change
ISearchIndexto support search from specific row and column infindInLinesearch.test.ts