Skip to content

Commit

Permalink
Merge pull request #2025 from thebradbain/fix-terminal-resize
Browse files Browse the repository at this point in the history
Clear line cache on terminal resize
  • Loading branch information
Tyriar committed Apr 27, 2019
2 parents c6f785f + 736bd53 commit 6237eaa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/addons/search/SearchHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class SearchHelper implements ISearchHelper {
private _linesCache: string[] = null;
private _linesCacheTimeoutId = 0;
private _cursorMoveListener: IDisposable | undefined;
private _resizeListener: IDisposable | undefined;

constructor(private _terminal: ISearchAddonTerminal) {
this._destroyLinesCache = this._destroyLinesCache.bind(this);
Expand Down Expand Up @@ -185,6 +186,7 @@ export class SearchHelper implements ISearchHelper {
if (!this._linesCache) {
this._linesCache = new Array(this._terminal._core.buffer.length);
this._cursorMoveListener = this._terminal.onCursorMove(() => this._destroyLinesCache());
this._resizeListener = this._terminal.onResize(() => this._destroyLinesCache());
}

window.clearTimeout(this._linesCacheTimeoutId);
Expand All @@ -197,6 +199,10 @@ export class SearchHelper implements ISearchHelper {
this._cursorMoveListener.dispose();
this._cursorMoveListener = undefined;
}
if (this._resizeListener) {
this._resizeListener.dispose();
this._resizeListener = undefined;
}
if (this._linesCacheTimeoutId) {
window.clearTimeout(this._linesCacheTimeoutId);
this._linesCacheTimeoutId = 0;
Expand Down

0 comments on commit 6237eaa

Please sign in to comment.