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}`); } }