Skip to content

Commit

Permalink
Fix bug where whitespace was not preserved in result
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarDamkjaer committed Jun 16, 2021
1 parent cb55ab5 commit c67b444
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/browser/components/ClickableUrls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const URL_REGEX = /(?:https?|s?ftp|bolt):\/\/(?:(?:[^\s()<>]+|\((?:[^\s()<>]+|(?

interface ClickableUrlsProps {
text?: string | null
WrappingTag?: keyof JSX.IntrinsicElements
WrappingTag?: keyof JSX.IntrinsicElements | React.ElementType
}

export default function ClickableUrls({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ export const StyledJsonPre = styled.pre`
max-width: 500px;
white-space: pre-wrap;
`

export const StyledPreSpan = styled.span`
white-space: pre;
`
15 changes: 10 additions & 5 deletions src/browser/modules/Stream/CypherFrame/relatable-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ import { stringModifier } from 'services/bolt/cypherTypesFormatting'
import ClickableUrls from '../../../components/ClickableUrls'
import { StyledStatsBar, StyledTruncatedMessage } from '../styled'
import Ellipsis from '../../../components/Ellipsis'
import { RelatableStyleWrapper, StyledJsonPre } from './relatable-view.styled'
import {
RelatableStyleWrapper,
StyledJsonPre,
StyledPreSpan
} from './relatable-view.styled'
import { stringifyMod, unescapeDoubleQuotesForDisplay } from 'services/utils'
import { GlobalState } from 'shared/globalState'

Expand Down Expand Up @@ -93,12 +97,12 @@ function CypherCell({ cell }: any) {
const renderCell = (entry: any) => {
if (Array.isArray(entry)) {
const children = entry.map((item, index) => (
<span key={index}>
<StyledPreSpan key={index}>
{renderCell(item)}
{index === entry.length - 1 ? null : ', '}
</span>
</StyledPreSpan>
))
return <span>[{children}]</span>
return <StyledPreSpan>[{children}]</StyledPreSpan>
} else if (typeof entry === 'object') {
return renderObject(entry)
} else {
Expand All @@ -107,6 +111,7 @@ const renderCell = (entry: any) => {
text={unescapeDoubleQuotesForDisplay(
stringifyMod(entry, stringModifier, true)
)}
WrappingTag={StyledPreSpan}
/>
)
}
Expand All @@ -119,7 +124,7 @@ const renderObject = (entry: any) => {
text={unescapeDoubleQuotesForDisplay(
stringifyMod(entry, stringModifier, true)
)}
WrappingTag={StyledJsonPre as any}
WrappingTag={StyledJsonPre}
/>
)
}
Expand Down

0 comments on commit c67b444

Please sign in to comment.