fix(tui): highlight written lines
This commit is contained in:
parent
d0aae842a1
commit
a8d2e8fa81
1 changed files with 25 additions and 6 deletions
|
|
@ -61,6 +61,7 @@ import parsers from "../../parsers-config"
|
||||||
import { errorMessage } from "../../util/error"
|
import { errorMessage } from "../../util/error"
|
||||||
import { useToast } from "../../ui/toast"
|
import { useToast } from "../../ui/toast"
|
||||||
import stripAnsi from "strip-ansi"
|
import stripAnsi from "strip-ansi"
|
||||||
|
import { createTwoFilesPatch } from "diff"
|
||||||
import { usePromptRef } from "../../context/prompt"
|
import { usePromptRef } from "../../context/prompt"
|
||||||
import { projectedPromptInput } from "../../prompt/codec"
|
import { projectedPromptInput } from "../../prompt/codec"
|
||||||
import { useEpilogue } from "../../context/epilogue"
|
import { useEpilogue } from "../../context/epilogue"
|
||||||
|
|
@ -2647,12 +2648,18 @@ function Shell(props: ToolProps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function Write(props: ToolProps) {
|
function Write(props: ToolProps) {
|
||||||
|
const ctx = use()
|
||||||
const { themeV2, syntax } = useTheme()
|
const { themeV2, syntax } = useTheme()
|
||||||
const pathFormatter = usePathFormatter()
|
const pathFormatter = usePathFormatter()
|
||||||
const code = createMemo(() => {
|
const code = createMemo(() => {
|
||||||
return stringValue(props.input.content) ?? ""
|
return stringValue(props.input.content) ?? ""
|
||||||
})
|
})
|
||||||
const complete = createMemo(() => props.part.state.status === "completed")
|
const complete = createMemo(() => props.part.state.status === "completed")
|
||||||
|
const view = createMemo(() => {
|
||||||
|
if (ctx.config.diffs?.view === "unified") return "unified"
|
||||||
|
if (ctx.config.diffs?.view === "split") return "split"
|
||||||
|
return ctx.width > 120 ? "split" : "unified"
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Switch>
|
<Switch>
|
||||||
|
|
@ -2665,15 +2672,27 @@ function Write(props: ToolProps) {
|
||||||
part={props.part}
|
part={props.part}
|
||||||
>
|
>
|
||||||
<Show when={code()}>
|
<Show when={code()}>
|
||||||
<line_number fg={themeV2.text.subdued} minWidth={3} paddingRight={1}>
|
<box paddingLeft={1}>
|
||||||
<code
|
<diff
|
||||||
conceal={false}
|
diff={createTwoFilesPatch("", stringValue(props.input.path) ?? "", "", code())}
|
||||||
fg={themeV2.text.default}
|
view={view()}
|
||||||
filetype={filetype(stringValue(props.input.path))}
|
filetype={filetype(stringValue(props.input.path))}
|
||||||
syntaxStyle={syntax()}
|
syntaxStyle={syntax()}
|
||||||
content={code()}
|
showLineNumbers={true}
|
||||||
|
width="100%"
|
||||||
|
wrapMode={ctx.diffWrapMode()}
|
||||||
|
fg={themeV2.text.default}
|
||||||
|
addedBg={themeV2.diff.background.added}
|
||||||
|
removedBg={themeV2.diff.background.removed}
|
||||||
|
contextBg={themeV2.diff.background.context}
|
||||||
|
addedSignColor={themeV2.diff.highlight.added}
|
||||||
|
removedSignColor={themeV2.diff.highlight.removed}
|
||||||
|
lineNumberFg={themeV2.diff.lineNumber.text}
|
||||||
|
lineNumberBg={themeV2.diff.background.context}
|
||||||
|
addedLineNumberBg={themeV2.diff.lineNumber.background.added}
|
||||||
|
removedLineNumberBg={themeV2.diff.lineNumber.background.removed}
|
||||||
/>
|
/>
|
||||||
</line_number>
|
</box>
|
||||||
</Show>
|
</Show>
|
||||||
<Diagnostics diagnostics={props.metadata.diagnostics} filePath={stringValue(props.input.path) ?? ""} />
|
<Diagnostics diagnostics={props.metadata.diagnostics} filePath={stringValue(props.input.path) ?? ""} />
|
||||||
</BlockTool>
|
</BlockTool>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue