Skip to content

Commit

Permalink
fix(EuiCode): Remove reducing two or more consecutive empty lines to …
Browse files Browse the repository at this point in the history
…a single one when using the Copy button
  • Loading branch information
tkajtoch committed May 23, 2023
1 parent 07d8cdf commit aac77e3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/components/code/code_block_copy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aac77e3

Please sign in to comment.