From ed6771ff9de4d808a2442c762b90b1694a58e9cc Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Wed, 15 Nov 2023 15:18:25 +0100 Subject: [PATCH] Make ctrl-f more usable on submissions --- .../javascripts/components/annotations/line_of_code.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/components/annotations/line_of_code.ts b/app/assets/javascripts/components/annotations/line_of_code.ts index a3751eb12d..5e1909fde8 100644 --- a/app/assets/javascripts/components/annotations/line_of_code.ts +++ b/app/assets/javascripts/components/annotations/line_of_code.ts @@ -156,12 +156,14 @@ export class LineOfCode extends ShadowlessLitElement { for (const range of this.ranges) { const substring = this.code.substring(range.start, range.start + range.length); + // replace every non-whitespace character with a non-breaking space + const nonSearchableSubstring = substring.replace(/\S/g, "\u00a0"); if (!range.annotations.length) { - backgroundLayer.push(substring); - tooltipLayer.push(substring); + backgroundLayer.push(nonSearchableSubstring); + tooltipLayer.push(nonSearchableSubstring); } else { - backgroundLayer.push(html`${substring}`); - tooltipLayer.push(html`${substring}`); + backgroundLayer.push(html`${nonSearchableSubstring}`); + tooltipLayer.push(html`${nonSearchableSubstring}`); } }