Speculative fix for NPE

Fixes #1702
This commit is contained in:
Daniel Imms
2018-09-19 19:47:16 -07:00
parent 290c95ad71
commit 4463f8d810
+8 -4
View File
@@ -81,18 +81,22 @@ export class Linkifier extends EventEmitter implements ILinkifier {
*/
private _linkifyRows(): void {
this._rowsTimeoutId = null;
const buffer = this._terminal.buffer;
// Ensure the row exists
const absoluteRowIndexStart = this._terminal.buffer.ydisp + this._rowsToLinkify.start;
if (absoluteRowIndexStart >= this._terminal.buffer.lines.length) {
// Ensure the start row exists
const absoluteRowIndexStart = buffer.ydisp + this._rowsToLinkify.start;
if (absoluteRowIndexStart >= buffer.lines.length) {
return;
}
// Invalidate bad end row values (if a resize happened)
const absoluteRowIndexEnd = Math.min(buffer.ydisp + this._rowsToLinkify.end + 1, buffer.ydisp + this._terminal.rows);
// iterate over the range of unwrapped content strings within start..end (excluding)
// _doLinkifyRow gets full unwrapped lines with the start row as buffer offset for every matcher
// for wrapped content over several rows the iterator might return rows outside the viewport
// we skip those later in _doLinkifyRow
const iterator = this._terminal.buffer.iterator(false, absoluteRowIndexStart, this._terminal.buffer.ydisp + this._rowsToLinkify.end + 1);
const iterator = buffer.iterator(false, absoluteRowIndexStart, absoluteRowIndexEnd);
while (iterator.hasNext()) {
const lineData: IBufferStringIteratorResult = iterator.next();
for (let i = 0; i < this._linkMatchers.length; i++) {