Ensure ending newline is displayed

This commit is contained in:
David Corbitt
2023-08-17 03:37:32 -07:00
parent edac8da4a8
commit acf74909c9

View File

@@ -10,6 +10,7 @@ const CopiableCode = ({ code, ...rest }: { code: string } & StackProps) => {
await navigator.clipboard.writeText(code); await navigator.clipboard.writeText(code);
setCopied(true); setCopied(true);
}, [code]); }, [code]);
return ( return (
<HStack <HStack
backgroundColor="blackAlpha.800" backgroundColor="blackAlpha.800"
@@ -29,6 +30,8 @@ const CopiableCode = ({ code, ...rest }: { code: string } & StackProps) => {
whiteSpace="pre-wrap" whiteSpace="pre-wrap"
> >
{code} {code}
{/* Necessary for trailing newline to actually be displayed */}
{code.endsWith("\n") ? "\n" : ""}
</Text> </Text>
<Tooltip closeOnClick={false} label={copied ? "Copied!" : "Copy to clipboard"}> <Tooltip closeOnClick={false} label={copied ? "Copied!" : "Copy to clipboard"}>
<IconButton <IconButton