From 83e49da7f6de328b617b72b53103027ece64a1bc Mon Sep 17 00:00:00 2001 From: n1474335 Date: Tue, 9 Feb 2021 11:37:25 +0000 Subject: [PATCH] Fixed description hiighlighting issue --- src/web/HTMLOperation.mjs | 2 +- src/web/waiters/OperationsWaiter.mjs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/web/HTMLOperation.mjs b/src/web/HTMLOperation.mjs index a8c89922..fe116eae 100755 --- a/src/web/HTMLOperation.mjs +++ b/src/web/HTMLOperation.mjs @@ -111,7 +111,7 @@ class HTMLOperation { this.name = opName; } - if (this.description && descIdxs.length) { + if (this.description && descIdxs.length && descIdxs[0][0] >= 0) { // Find HTML tag offsets const re = /<[^>]+>/g; let match; diff --git a/src/web/waiters/OperationsWaiter.mjs b/src/web/waiters/OperationsWaiter.mjs index 48df86f7..8947b038 100755 --- a/src/web/waiters/OperationsWaiter.mjs +++ b/src/web/waiters/OperationsWaiter.mjs @@ -109,8 +109,6 @@ class OperationsWaiter { const matchedOps = []; const matchedDescs = []; - const searchStr = inStr.toLowerCase(); - for (const opName in this.app.operations) { const op = this.app.operations[opName]; @@ -118,12 +116,12 @@ class OperationsWaiter { const [nameMatch, score, idxs] = fuzzyMatch(inStr, opName); // Match description based on exact match - const descPos = op.description.toLowerCase().indexOf(searchStr); + const descPos = op.description.toLowerCase().indexOf(inStr.toLowerCase()); if (nameMatch || descPos >= 0) { const operation = new HTMLOperation(opName, this.app.operations[opName], this.app, this.manager); if (highlight) { - operation.highlightSearchStrings(calcMatchRanges(idxs) || [], [[descPos, searchStr.length]]); + operation.highlightSearchStrings(calcMatchRanges(idxs) || [], [[descPos, inStr.length]]); } if (nameMatch) {