@xterm/addon-search 0.16.0-beta.115 → 0.16.0-beta.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/addon-search.js +1 -1
- package/lib/addon-search.js.map +1 -1
- package/lib/addon-search.mjs +2 -2
- package/lib/addon-search.mjs.map +3 -3
- package/package.json +3 -3
- package/src/SearchAddon.ts +8 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xterm/addon-search",
|
|
3
|
-
"version": "0.16.0-beta.
|
|
3
|
+
"version": "0.16.0-beta.117",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "The xterm.js authors",
|
|
6
6
|
"url": "https://xtermjs.org/"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"start": "node ../../demo/start"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@xterm/xterm": "^5.6.0-beta.
|
|
25
|
+
"@xterm/xterm": "^5.6.0-beta.117"
|
|
26
26
|
},
|
|
27
|
-
"commit": "
|
|
27
|
+
"commit": "e969832946a97791efbc3ad520e827b65729c0ba"
|
|
28
28
|
}
|
package/src/SearchAddon.ts
CHANGED
|
@@ -72,6 +72,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA
|
|
|
72
72
|
private _cachedSearchTerm: string | undefined;
|
|
73
73
|
private _highlightedLines: Set<number> = new Set();
|
|
74
74
|
private _highlightDecorations: IHighlight[] = [];
|
|
75
|
+
private _searchResultsWithHighlight: ISearchResult[] = [];
|
|
75
76
|
private _selectedDecoration: MutableDisposable<IMultiHighlight> = this._register(new MutableDisposable());
|
|
76
77
|
private _highlightLimit: number;
|
|
77
78
|
private _lastSearchOptions: ISearchOptions | undefined;
|
|
@@ -118,6 +119,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA
|
|
|
118
119
|
this._selectedDecoration.clear();
|
|
119
120
|
dispose(this._highlightDecorations);
|
|
120
121
|
this._highlightDecorations = [];
|
|
122
|
+
this._searchResultsWithHighlight = [];
|
|
121
123
|
this._highlightedLines.clear();
|
|
122
124
|
if (!retainCachedSearchTerm) {
|
|
123
125
|
this._cachedSearchTerm = undefined;
|
|
@@ -167,15 +169,14 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA
|
|
|
167
169
|
// new search, clear out the old decorations
|
|
168
170
|
this.clearDecorations(true);
|
|
169
171
|
|
|
170
|
-
const searchResultsWithHighlight: ISearchResult[] = [];
|
|
171
172
|
let prevResult: ISearchResult | undefined = undefined;
|
|
172
173
|
let result = this._find(term, 0, 0, searchOptions);
|
|
173
174
|
while (result && (prevResult?.row !== result.row || prevResult?.col !== result.col)) {
|
|
174
|
-
if (
|
|
175
|
+
if (this._searchResultsWithHighlight.length >= this._highlightLimit) {
|
|
175
176
|
break;
|
|
176
177
|
}
|
|
177
178
|
prevResult = result;
|
|
178
|
-
|
|
179
|
+
this._searchResultsWithHighlight.push(prevResult);
|
|
179
180
|
result = this._find(
|
|
180
181
|
term,
|
|
181
182
|
prevResult.col + prevResult.term.length >= this._terminal.cols ? prevResult.row + 1 : prevResult.row,
|
|
@@ -183,7 +184,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA
|
|
|
183
184
|
searchOptions
|
|
184
185
|
);
|
|
185
186
|
}
|
|
186
|
-
for (const match of
|
|
187
|
+
for (const match of this._searchResultsWithHighlight) {
|
|
187
188
|
const decorations = this._createResultDecorations(match, searchOptions.decorations!, false);
|
|
188
189
|
if (decorations) {
|
|
189
190
|
for (const decoration of decorations) {
|
|
@@ -350,15 +351,15 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA
|
|
|
350
351
|
let resultIndex = -1;
|
|
351
352
|
if (this._selectedDecoration.value) {
|
|
352
353
|
const selectedMatch = this._selectedDecoration.value.match;
|
|
353
|
-
for (let i = 0; i < this.
|
|
354
|
-
const match = this.
|
|
354
|
+
for (let i = 0; i < this._searchResultsWithHighlight.length; i++) {
|
|
355
|
+
const match = this._searchResultsWithHighlight[i];
|
|
355
356
|
if (match.row === selectedMatch.row && match.col === selectedMatch.col && match.size === selectedMatch.size) {
|
|
356
357
|
resultIndex = i;
|
|
357
358
|
break;
|
|
358
359
|
}
|
|
359
360
|
}
|
|
360
361
|
}
|
|
361
|
-
this._onDidChangeResults.fire({ resultIndex, resultCount: this.
|
|
362
|
+
this._onDidChangeResults.fire({ resultIndex, resultCount: this._searchResultsWithHighlight.length });
|
|
362
363
|
}
|
|
363
364
|
}
|
|
364
365
|
|