Close current diff view when showing new edit right after; fix thinking tags rendering

This commit is contained in:
Saoud Rizwan
2024-07-31 19:25:26 -04:00
parent 624a4e4ed6
commit 31d8472f59
2 changed files with 7 additions and 3 deletions

View File

@@ -418,7 +418,7 @@ export class ClaudeDev {
await fs.writeFile(filePath, newContent) await fs.writeFile(filePath, newContent)
// Finish by opening the edited file in the editor // Finish by opening the edited file in the editor
vscode.window.showTextDocument(vscode.Uri.file(filePath), { preview: false }) await vscode.window.showTextDocument(vscode.Uri.file(filePath), { preview: false })
return `Changes applied to ${filePath}:\n${diffResult}` return `Changes applied to ${filePath}:\n${diffResult}`
} else { } else {
const fileName = path.basename(filePath) const fileName = path.basename(filePath)
@@ -449,7 +449,7 @@ export class ClaudeDev {
} }
await fs.mkdir(path.dirname(filePath), { recursive: true }) await fs.mkdir(path.dirname(filePath), { recursive: true })
await fs.writeFile(filePath, newContent) await fs.writeFile(filePath, newContent)
vscode.window.showTextDocument(vscode.Uri.file(filePath), { preview: false }) await vscode.window.showTextDocument(vscode.Uri.file(filePath), { preview: false })
return `New file created and content written to ${filePath}` return `New file created and content written to ${filePath}`
} }
} catch (error) { } catch (error) {

View File

@@ -122,10 +122,14 @@ const ChatRow: React.FC<ChatRowProps> = ({
const renderMarkdown = (markdown: string = "") => { const renderMarkdown = (markdown: string = "") => {
// react-markdown lets us customize elements, so here we're using their example of replacing code blocks with SyntaxHighlighter. However when there are no language matches (` or ``` without a language specifier) then we default to a normal code element for inline code. Code blocks without a language specifier shouldn't be a common occurrence as we prompt Claude to always use a language specifier. // react-markdown lets us customize elements, so here we're using their example of replacing code blocks with SyntaxHighlighter. However when there are no language matches (` or ``` without a language specifier) then we default to a normal code element for inline code. Code blocks without a language specifier shouldn't be a common occurrence as we prompt Claude to always use a language specifier.
// when claude wraps text in thinking tags, he doesnt use line breaks so we need to insert those ourselves to render markdown correctly
const parsed = markdown.replace(/<thinking>([\s\S]*?)<\/thinking>/g, (match, content) => {
return `_<thinking>_\n\n${content}\n\n_</thinking>_`
})
return ( return (
<div style={{ wordBreak: "break-word", overflowWrap: "anywhere" }}> <div style={{ wordBreak: "break-word", overflowWrap: "anywhere" }}>
<Markdown <Markdown
children={markdown} children={parsed}
components={{ components={{
p(props) { p(props) {
const { style, ...rest } = props const { style, ...rest } = props