Show diffs side by side in a wide conversation
Split view with synced scrolling from 140 columns, unified below that, with the gutter and line colours from theme tokens. Toggle split diff in the palette overrides the choice for the session.
This commit is contained in:
1 parent
4e3717d171
commit
d87026a66b
5 files changed
+80
-7
No files matched your search
+11
-5
@@ -18,8 +18,8 @@ export interface DiffState {
|
||||
readonly error?: string;
|
||||
}
|
||||
|
||||
/** Working-tree or checkpoint changes through the same unified diff renderer. */
|
||||
export function DiffView(props: { readonly diff: DiffState; readonly scrollRef: RefObject<ScrollBoxRenderable | null>; readonly selected: number; readonly expanded: Readonly<Record<string, { patch?: string; error?: string }>>; readonly onFile: (index: number) => void }) {
|
||||
/** Working-tree or checkpoint changes through the same diff renderer: side by side when `split`, else unified. */
|
||||
export function DiffView(props: { readonly diff: DiffState; readonly split: boolean; readonly scrollRef: RefObject<ScrollBoxRenderable | null>; readonly selected: number; readonly expanded: Readonly<Record<string, { patch?: string; error?: string }>>; readonly onFile: (index: number) => void }) {
|
||||
const { diff } = props;
|
||||
const markdownStyle = useMarkdownStyle();
|
||||
const files = diff.patch ? splitPatch(diff.patch) : [];
|
||||
@@ -44,7 +44,8 @@ export function DiffView(props: { readonly diff: DiffState; readonly scrollRef:
|
||||
{props.expanded[file.path] && !props.expanded[file.path]?.patch ? <text fg={props.expanded[file.path]?.error ? colors.bad : colors.muted}>{props.expanded[file.path]?.error ?? "Loading full file…"}</text> : null}
|
||||
<diff
|
||||
diff={props.expanded[file.path]?.patch ?? file.patch}
|
||||
view="unified"
|
||||
view={props.split ? "split" : "unified"}
|
||||
syncScroll
|
||||
{...(filetypeOf(file.path) ? { filetype: filetypeOf(file.path)! } : {})}
|
||||
syntaxStyle={markdownStyle}
|
||||
showLineNumbers
|
||||
@@ -52,11 +53,16 @@ export function DiffView(props: { readonly diff: DiffState; readonly scrollRef:
|
||||
fg={colors.text}
|
||||
addedBg={colors.diffAddedBg}
|
||||
removedBg={colors.diffRemovedBg}
|
||||
contextBg={colors.bg}
|
||||
addedContentBg={colors.diffAddedBg}
|
||||
removedContentBg={colors.diffRemovedBg}
|
||||
addedSignColor={colors.good}
|
||||
removedSignColor={colors.bad}
|
||||
contextContentBg={colors.bg}
|
||||
addedSignColor={colors.diffAddedSign}
|
||||
removedSignColor={colors.diffRemovedSign}
|
||||
lineNumberFg={colors.faint}
|
||||
lineNumberBg={colors.diffGutterBg}
|
||||
addedLineNumberBg={colors.diffAddedGutterBg}
|
||||
removedLineNumberBg={colors.diffRemovedGutterBg}
|
||||
/>
|
||||
</box>
|
||||
))}
|
||||
|
||||
Reference in new issue
Block a user