diff --git a/src/components/code/code_block_copy.tsx b/src/components/code/code_block_copy.tsx index 3469810cc70f..00f74a3f6c43 100644 --- a/src/components/code/code_block_copy.tsx +++ b/src/components/code/code_block_copy.tsx @@ -28,11 +28,8 @@ export const useCopy = ({ const [innerTextRef, _innerText] = useInnerText(''); const innerText = useMemo( () => - _innerText - // Normalize line terminations to match native JS format - ?.replace(NEW_LINE_REGEX_GLOBAL, '\n') - // Reduce two or more consecutive new line characters to a single one - .replace(/\n{2,}/g, '\n') || '', + // Normalize line terminations to match native JS format + _innerText?.replace(NEW_LINE_REGEX_GLOBAL, '\n') || '', [_innerText] ); const textToCopy = isVirtualized ? `${children}` : innerText; // Virtualized code blocks do not have inner text