mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Linkify all rows at once to prevent multiple timeout restarts
This commit is contained in:
@@ -47,6 +47,7 @@ export class Linkifier {
|
||||
private _document: Document;
|
||||
private _rows: HTMLElement[];
|
||||
private _rowTimeoutIds: number[];
|
||||
private _rowsTimeoutId: number;
|
||||
private _nextLinkMatcherId = HYPERTEXT_LINK_MATCHER_ID;
|
||||
|
||||
constructor() {
|
||||
@@ -65,6 +66,29 @@ export class Linkifier {
|
||||
this._rows = rows;
|
||||
}
|
||||
|
||||
public linkifyRows(start: number, end: number): void {
|
||||
// for (let i = start; i <= end; i++) {
|
||||
// this.linkifyRow(i);
|
||||
// }
|
||||
|
||||
|
||||
// Don't attempt linkify if not yet attached to DOM
|
||||
if (!this._document) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._rowsTimeoutId) {
|
||||
clearTimeout(this._rowsTimeoutId);
|
||||
}
|
||||
this._rowsTimeoutId = setTimeout(this._linkifyRows.bind(this, start, end), Linkifier.TIME_BEFORE_LINKIFY);
|
||||
}
|
||||
|
||||
private _linkifyRows(start: number, end: number): void {
|
||||
for (let i = start; i <= end; i++) {
|
||||
this._linkifyRow(i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Queues a row for linkification.
|
||||
* @param {number} rowIndex The index of the row to linkify.
|
||||
|
||||
+4
-3
@@ -1146,9 +1146,10 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
||||
*/
|
||||
private queueLinkification(start: number, end: number): void {
|
||||
if (this.linkifier) {
|
||||
for (let i = start; i <= end; i++) {
|
||||
this.linkifier.linkifyRow(i);
|
||||
}
|
||||
this.linkifier.linkifyRows(0, this.rows);
|
||||
// for (let i = start; i <= end; i++) {
|
||||
// this.linkifier.linkifyRow(i);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user