From c3f31b5f6535130e0d5dc1e63a395dbf775d6a99 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 14 Feb 2017 20:04:51 -0800 Subject: [PATCH] Apply link matchers in reverse This enables consumers to have full control. --- src/Linkifier.ts | 4 ++-- src/xterm.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Linkifier.ts b/src/Linkifier.ts index 9da532dd..a2a5a5da 100644 --- a/src/Linkifier.ts +++ b/src/Linkifier.ts @@ -78,7 +78,7 @@ export class Linkifier { * this searches the textContent of the rows. You will want to use \s to match * a space ' ' character for example. * @param {LinkHandler} handler The callback when the link is called. - * @param {number} matchIndex The index of the link from the regex.match(html) + * @param {number} matchIndex The index of the link from the regex.match(text) * call. This defaults to 0 (for regular expressions without capture groups). * @return {number} The ID of the new matcher, this can be used to deregister. */ @@ -118,7 +118,7 @@ export class Linkifier { */ private _linkifyRow(rowIndex: number): void { const text = this._rows[rowIndex].textContent; - for (let i = 0; i < this._linkMatchers.length; i++) { + for (let i = this._linkMatchers.length - 1; i >= 0; i--) { const matcher = this._linkMatchers[i]; const uri = this._findLinkMatch(text, matcher.regex, matcher.matchIndex); if (uri) { diff --git a/src/xterm.js b/src/xterm.js index 358040a0..a6e756b2 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -1305,7 +1305,7 @@ Terminal.prototype.attachHypertextLinkHandler = function(handler) { * this searches the textContent of the rows. You will want to use \s to match * a space ' ' character for example. * @param {LinkHandler} handler The callback when the link is called. - * @param {number} matchIndex The index of the link from the regex.match(html) + * @param {number} matchIndex The index of the link from the regex.match(text) * call. This defaults to 0 (for regular expressions without capture groups). * @return {number} The ID of the new matcher, this can be used to deregister. */