Check option changes
This commit is contained in:
@@ -134,9 +134,10 @@ export class SearchAddon extends Disposable implements ITerminalAddon {
|
|||||||
if (!this._terminal) {
|
if (!this._terminal) {
|
||||||
throw new Error('Cannot use addon until it has been loaded');
|
throw new Error('Cannot use addon until it has been loaded');
|
||||||
}
|
}
|
||||||
|
const isOptionsChanged = this._lastSearchOptions ? this._isOptionsChange(this._lastSearchOptions, searchOptions) : true;
|
||||||
this._lastSearchOptions = searchOptions;
|
this._lastSearchOptions = searchOptions;
|
||||||
if (searchOptions?.decorations) {
|
if (searchOptions?.decorations) {
|
||||||
if (this._cachedSearchTerm === undefined || term !== this._cachedSearchTerm) {
|
if (this._cachedSearchTerm === undefined || term !== this._cachedSearchTerm || isOptionsChanged) {
|
||||||
this._highlightAllMatches(term, searchOptions);
|
this._highlightAllMatches(term, searchOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -302,9 +303,10 @@ export class SearchAddon extends Disposable implements ITerminalAddon {
|
|||||||
if (!this._terminal) {
|
if (!this._terminal) {
|
||||||
throw new Error('Cannot use addon until it has been loaded');
|
throw new Error('Cannot use addon until it has been loaded');
|
||||||
}
|
}
|
||||||
|
const isOptionsChanged = this._lastSearchOptions ? this._isOptionsChange(this._lastSearchOptions, searchOptions) : true;
|
||||||
this._lastSearchOptions = searchOptions;
|
this._lastSearchOptions = searchOptions;
|
||||||
if (searchOptions?.decorations) {
|
if (searchOptions?.decorations) {
|
||||||
if (this._cachedSearchTerm === undefined || term !== this._cachedSearchTerm) {
|
if (this._cachedSearchTerm === undefined || term !== this._cachedSearchTerm || isOptionsChanged) {
|
||||||
this._highlightAllMatches(term, searchOptions);
|
this._highlightAllMatches(term, searchOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,6 +318,22 @@ export class SearchAddon extends Disposable implements ITerminalAddon {
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _isOptionsChange(lastSearchOptions: ISearchOptions, searchOptions?: ISearchOptions): boolean {
|
||||||
|
if (!searchOptions) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (lastSearchOptions.caseSensitive !== searchOptions.caseSensitive) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (lastSearchOptions.regex !== searchOptions.regex) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (lastSearchOptions.wholeWord !== searchOptions.wholeWord) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private _fireResults(searchOptions?: ISearchOptions): void {
|
private _fireResults(searchOptions?: ISearchOptions): void {
|
||||||
if (searchOptions?.decorations) {
|
if (searchOptions?.decorations) {
|
||||||
let resultIndex = -1;
|
let resultIndex = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user