From 655fc9f924cd4de4eb0b6993a6ce5488de5e8b1e Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Mon, 30 May 2022 14:05:45 +0200 Subject: [PATCH 1/2] fix: Do not render selected word markers for the same range multiple times --- 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..b6cf54958fc 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 = new Set(); 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.has(rangeAsString)) continue; + + renderedMarkerRanges.add(rangeAsString); markerLayer.drawSingleLineMarker( - html, ranges[j].toScreenRange(session), this.clazz, config); + html, rangeToAddMarkerTo, this.clazz, config); } } }; From cd6ff4c36a4c465d5ea679d6a441fb1e9067bb8a Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Mon, 30 May 2022 14:10:47 +0200 Subject: [PATCH 2/2] use map instead of set --- lib/ace/search_highlight.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ace/search_highlight.js b/lib/ace/search_highlight.js index b6cf54958fc..58da750ce95 100644 --- a/lib/ace/search_highlight.js +++ b/lib/ace/search_highlight.js @@ -56,7 +56,7 @@ var SearchHighlight = function(regExp, clazz, type) { if (!this.regExp) return; var start = config.firstRow, end = config.lastRow; - var renderedMarkerRanges = new Set(); + var renderedMarkerRanges = {}; for (var i = start; i <= end; i++) { var ranges = this.cache[i]; @@ -73,9 +73,9 @@ var SearchHighlight = function(regExp, clazz, type) { for (var j = ranges.length; j --; ) { var rangeToAddMarkerTo = ranges[j].toScreenRange(session); var rangeAsString = rangeToAddMarkerTo.toString(); - if (renderedMarkerRanges.has(rangeAsString)) continue; + if (renderedMarkerRanges[rangeAsString]) continue; - renderedMarkerRanges.add(rangeAsString); + renderedMarkerRanges[rangeAsString] = true; markerLayer.drawSingleLineMarker( html, rangeToAddMarkerTo, this.clazz, config); }