From 4f311f439b75bfd228d8ed7ee71af88eda9e8e79 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 1 Sep 2021 19:07:09 -0700 Subject: [PATCH] Fix. --- components/Snippet.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/Snippet.tsx b/components/Snippet.tsx index dbd54bb..e89682e 100644 --- a/components/Snippet.tsx +++ b/components/Snippet.tsx @@ -44,7 +44,8 @@ import { ContentSize } from 'azure-devops-ui/Callout' // Search/Filter hilighting is active so bypass snippet highlighting and return plain text. if (term) return crst - let lines = crst.split('\n') + // Carriage returns (\n) causing hljs colorization off-by-one errors, thus stripping them here. + let lines = crst.replace(/\r/g, '').split('\n') const minLeadingWhitespace = Math.min( ...lines .filter(line => line.trimLeft().length) // Blank lines often have indent 0, so throwing these out.