From cd30f591e40d5286fdabaa9f688f3c6066fbffff Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Mon, 30 May 2022 18:04:13 +0200 Subject: [PATCH] fix: Do not render selected word markers for the same range multiple times (#4727) * fix: Do not render selected word markers for the same range multiple times * use map instead of set --- lib/ace/search_highlight.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ace/search_highlight.js b/lib/ace/search_highlight.js index 11defd9cdc1..58da750ce95 100644 --- a/lib/ace/search_highlight.js +++ b/lib/ace/search_highlight.js @@ -56,6 +56,7 @@ var SearchHighlight = function(regExp, clazz, type) { if (!this.regExp) return; var start = config.firstRow, end = config.lastRow; + var renderedMarkerRanges = {}; for (var i = start; i <= end; i++) { var ranges = this.cache[i]; @@ -70,8 +71,13 @@ var SearchHighlight = function(regExp, clazz, type) { } for (var j = ranges.length; j --; ) { + var rangeToAddMarkerTo = ranges[j].toScreenRange(session); + var rangeAsString = rangeToAddMarkerTo.toString(); + if (renderedMarkerRanges[rangeAsString]) continue; + + renderedMarkerRanges[rangeAsString] = true; markerLayer.drawSingleLineMarker( - html, ranges[j].toScreenRange(session), this.clazz, config); + html, rangeToAddMarkerTo, this.clazz, config); } } };