Skip to content

Commit

Permalink
escape backticks in the output
Browse files Browse the repository at this point in the history
  • Loading branch information
adred committed May 16, 2024
1 parent c51d725 commit 8b78afa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app/sidebar/aichat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,13 @@ class ChatSidebar extends React.Component<{}, {}> {
if (cmd == null || cmd === "") {
return "";
}

// Escape backticks in the output
const escapedOutput = output ? output.replace(/`/g, "\\`") : "";

let chatMessage = `I ran the command: \`${cmd}\` and got the following output:\n\n`;
if (output != null && output !== "") {
chatMessage += `\`\`\`\n${output}\n\`\`\``;
if (escapedOutput !== "") {
chatMessage += `\`\`\`\n${escapedOutput}\n\`\`\``;
}
if (isError) {
chatMessage += "\n\nHow should I fix this?";
Expand Down

0 comments on commit 8b78afa

Please sign in to comment.