Skip to content

Commit 064811a

Browse files
committed
Format copied errors with ``` for discord/github
1 parent 6496d98 commit 064811a

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/ErrorContext.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ export const ErrorProvider: React.FC<{ children: React.ReactNode }> = ({
5757
<button
5858
onClick={() => {
5959
navigator.clipboard.writeText(
60-
error?.replace(/^\n+/, "") ?? t("common.no_error"),
60+
"```\n" +
61+
(error?.replace(/^\n+/, "") ?? t("common.no_error")) +
62+
"\n```",
6163
);
6264
toast.success(t("common.copied_success"));
6365
}}

src/components/OperationView.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default ({
2424
const done =
2525
(opFailed &&
2626
operationState.started.length ==
27-
operationState.completed.length + operationState.failed.length) ||
27+
operationState.completed.length + operationState.failed.length) ||
2828
operationState.completed.length == operation.steps.length;
2929

3030
const [moreDetailsOpen, setMoreDetailsOpen] = useState(false);
@@ -115,7 +115,9 @@ export default ({
115115
</div>
116116
</div>
117117
{done && !opFailed && operation.successMessageKey && (
118-
<p className="operation-success-message">{t(operation.successMessageKey!)}</p>
118+
<p className="operation-success-message">
119+
{t(operation.successMessageKey!)}
120+
</p>
119121
)}
120122
{done && !(!opFailed && operation.successMessageKey) && <p></p>}
121123
{opFailed && done && (
@@ -148,8 +150,12 @@ export default ({
148150
className="action-button primary"
149151
onClick={() => {
150152
navigator.clipboard.writeText(
151-
operationState.failed[0]?.extraDetails?.replace(/^\n+/, "") ??
152-
t("common.no_error"),
153+
"```\n" +
154+
(operationState.failed[0]?.extraDetails?.replace(
155+
/^\n+/,
156+
"",
157+
) ?? t("common.no_error")) +
158+
"\n```",
153159
);
154160
toast.success(t("common.copied_success"));
155161
}}

src/pages/Settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export const Settings = ({ showHeading = true }: SettingsProps) => {
143143
`[${log.timestamp}] [${LogLevel[log.level]}] ${log.target ? `<${log.target}>` : ""} ${log.message}`,
144144
)
145145
.join("\n");
146-
navigator.clipboard.writeText(logText);
146+
navigator.clipboard.writeText("```\n" + logText + "\n```");
147147
toast.success(t("common.copied_success"));
148148
}}
149149
>

0 commit comments

Comments
 (0)