Skip to content

Commit

Permalink
fix: re-work output dom to remove whitespace when copying (#524)
Browse files Browse the repository at this point in the history
Co-authored-by: Issac Gerges <gergesim@gmail.com>
  • Loading branch information
issacgerges and Issac Gerges authored Nov 11, 2020
1 parent 00808c4 commit fc25926
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 25 deletions.
7 changes: 2 additions & 5 deletions src/less/components/output.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "../variables.less";
@import '../variables.less';

.output {
font-size: 12px;
Expand All @@ -16,10 +16,7 @@
overflow-y: scroll;
-webkit-app-region: no-drag;

p {
margin-bottom: 0;
.output-message {
white-space: pre;
padding-left: 5.6em;
text-indent: -5.6em;
}
}
10 changes: 6 additions & 4 deletions src/renderer/components/output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ export class Output extends React.Component<CommandsProps> {
: {};

return lines.map((text, lineIndex) => (
<p style={style} key={`${entry.timestamp}--${index}--${lineIndex}`}>
{timestamp}
{text}
</p>
<div key={`${entry.timestamp}--${index}--${lineIndex}`}>
<span style={style} className="output-message">
{timestamp}
{text}
</span>
</div>
));
}

Expand Down
40 changes: 24 additions & 16 deletions tests/renderer/components/__snapshots__/output-spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,39 @@ exports[`Output component renders with output 1`] = `
<div
className="output"
>
<p
<div
key="1532704073130--0--0"
style={Object {}}
>
<span
className="timestamp"
className="output-message"
style={Object {}}
>
1532704073130
<span
className="timestamp"
>
1532704073130
</span>
Hi!
</span>
Hi!
</p>
<p
</div>
<div
key="1532704073130--1--0"
style={
Object {
"whiteSpace": "initial",
}
}
>
<span
className="timestamp"
className="output-message"
style={
Object {
"whiteSpace": "initial",
}
}
>
1532704073130
<span
className="timestamp"
>
1532704073130
</span>
Hi!
</span>
Hi!
</p>
</div>
</div>
`;

0 comments on commit fc25926

Please sign in to comment.