Add overflowWrap anywhere to force wrap long words (file paths) to avoid overflowing container

This commit is contained in:
Saoud Rizwan
2024-07-31 14:24:04 -04:00
parent dc97689836
commit c70e14c298
3 changed files with 105 additions and 72 deletions

View File

@@ -383,6 +383,7 @@ export class ClaudeDev {
}) })
.join("") .join("")
vscode.window.showTextDocument(vscode.Uri.file(filePath), { preview: false })
const { response, text } = await this.ask( const { response, text } = await this.ask(
"tool", "tool",
JSON.stringify({ JSON.stringify({
@@ -415,6 +416,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 })
return `New file created and content written to ${filePath}` return `New file created and content written to ${filePath}`
} }
} catch (error) { } catch (error) {

View File

@@ -123,6 +123,7 @@ 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.
return ( return (
<div style={{ wordBreak: "break-word", overflowWrap: "anywhere" }}>
<Markdown <Markdown
children={markdown} children={markdown}
components={{ components={{
@@ -137,6 +138,7 @@ const ChatRow: React.FC<ChatRowProps> = ({
marginBottom: 0, marginBottom: 0,
whiteSpace: "pre-wrap", whiteSpace: "pre-wrap",
wordBreak: "break-word", wordBreak: "break-word",
overflowWrap: "anywhere",
}} }}
{...rest} {...rest}
/> />
@@ -144,11 +146,33 @@ const ChatRow: React.FC<ChatRowProps> = ({
}, },
ol(props) { ol(props) {
const { style, ...rest } = props const { style, ...rest } = props
return <ol style={{ ...style, padding: "0 0 0 20px", margin: "10px 0" }} {...rest} /> return (
<ol
style={{
...style,
padding: "0 0 0 20px",
margin: "10px 0",
wordBreak: "break-word",
overflowWrap: "anywhere",
}}
{...rest}
/>
)
}, },
ul(props) { ul(props) {
const { style, ...rest } = props const { style, ...rest } = props
return <ul style={{ ...style, padding: "0 0 0 20px", margin: "10px 0" }} {...rest} /> return (
<ul
style={{
...style,
padding: "0 0 0 20px",
margin: "10px 0",
wordBreak: "break-word",
overflowWrap: "anywhere",
}}
{...rest}
/>
)
}, },
// https://github.com/remarkjs/react-markdown?tab=readme-ov-file#use-custom-components-syntax-highlight // https://github.com/remarkjs/react-markdown?tab=readme-ov-file#use-custom-components-syntax-highlight
code(props) { code(props) {
@@ -187,13 +211,18 @@ const ChatRow: React.FC<ChatRowProps> = ({
<code <code
{...rest} {...rest}
className={className} className={className}
style={{ whiteSpace: "pre-line", wordBreak: "break-word" }}> style={{
whiteSpace: "pre-line",
wordBreak: "break-word",
overflowWrap: "anywhere",
}}>
{children} {children}
</code> </code>
) )
}, },
}} }}
/> />
</div>
) )
} }
@@ -209,8 +238,9 @@ const ChatRow: React.FC<ChatRowProps> = ({
const pStyle: React.CSSProperties = { const pStyle: React.CSSProperties = {
margin: 0, margin: 0,
whiteSpace: "pre-line", whiteSpace: "pre-wrap",
wordBreak: "break-word", wordBreak: "break-word",
overflowWrap: "anywhere",
} }
switch (message.type) { switch (message.type) {

View File

@@ -109,6 +109,7 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({ taskText, tokensIn, tokensOut,
fontSize: "var(--vscode-font-size)", fontSize: "var(--vscode-font-size)",
overflowY: isExpanded ? "auto" : "hidden", overflowY: isExpanded ? "auto" : "hidden",
wordBreak: "break-word", wordBreak: "break-word",
overflowWrap: "anywhere",
}}> }}>
<TextTruncate <TextTruncate
key={textTruncateKey} key={textTruncateKey}