дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 01:57:13 +02:00
fix(vcs): give Local History diffs room in narrow panes (#4613)
Local History gave its revision list a fixed share of the pane, so in narrow panes the diff had little room and long labels were clipped. The list and diff are now a resizable split with sensible minimums, revision rows truncate with full text in tooltips, and the diff keeps room in narrow panes.
Цей коміт міститься в:
1 джерело
1a2adab237
коміт
37044dcd89
3 files changed
+142
-57
No files matched your search
@@ -5,6 +5,9 @@
|
||||
display: flex;
|
||||
background: var(--bg-app);
|
||||
}
|
||||
.resizable {
|
||||
min-width: 0;
|
||||
}
|
||||
.sidebar {
|
||||
flex: none;
|
||||
width: 260px;
|
||||
@@ -18,7 +21,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
padding: 0 8px 0 12px;
|
||||
padding: 0 var(--space-2) 0 var(--space-3);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.title {
|
||||
@@ -26,6 +29,14 @@
|
||||
color: var(--fg-emphasis);
|
||||
font-weight: 500;
|
||||
}
|
||||
.resizable .title {
|
||||
min-width: 0;
|
||||
font-size: var(--fs-ui);
|
||||
font-weight: 600;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.list {
|
||||
flex: 1;
|
||||
}
|
||||
@@ -35,14 +46,36 @@
|
||||
min-width: 0;
|
||||
gap: var(--space-0-5);
|
||||
}
|
||||
.time {
|
||||
color: var(--fg-emphasis);
|
||||
.resizable .entry {
|
||||
width: 100%;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.label {
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-small);
|
||||
.primaryRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
color: var(--fg-strong);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.primary,
|
||||
.meta,
|
||||
.path,
|
||||
.deletedPath {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.meta,
|
||||
.path,
|
||||
.deletedPath {
|
||||
color: var(--fg-muted);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.meta {
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.deletedPath {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
.diff {
|
||||
flex: 1;
|
||||
@@ -51,33 +84,11 @@
|
||||
flex-direction: column;
|
||||
}
|
||||
.message {
|
||||
padding: 16px;
|
||||
padding: var(--space-4);
|
||||
color: var(--fg-faint);
|
||||
text-align: center;
|
||||
}
|
||||
.path,
|
||||
.deletedPath {
|
||||
color: var(--fg);
|
||||
font-size: var(--fs-small);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.deletedPath {
|
||||
color: var(--fg-muted);
|
||||
text-decoration: line-through;
|
||||
}
|
||||
.labelRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
min-width: 0;
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
.labelName {
|
||||
font-size: var(--fs-small);
|
||||
font-weight: 500;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
.resizable .message {
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import type { HistoryEntry } from "@/bindings";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { relativePath, useProject } from "@/platform/project";
|
||||
import { Button, Icon, List, Spinner, T } from "@/ui";
|
||||
import { Button, Icon, List, Spinner, SplitGroup, SplitHandle, SplitPanel, T } from "@/ui";
|
||||
import { notifications, type EditorInput } from "@/workbench/contributions";
|
||||
import { DiffEditor } from "./DiffEditor";
|
||||
import { confirmDialog } from "./dialogs";
|
||||
@@ -70,6 +70,19 @@ export function LocalHistoryEditor({ input }: { input: EditorInput }) {
|
||||
const anchor = useRef(0);
|
||||
const previous = useRef(0);
|
||||
const pointer = useRef(false);
|
||||
const container = useRef<HTMLDivElement>(null);
|
||||
const [stacked, setStacked] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const el = container.current;
|
||||
if (!el || typeof ResizeObserver === "undefined") return;
|
||||
const observer = new ResizeObserver(([entry]) => {
|
||||
const width = entry?.contentRect.width;
|
||||
if (width) setStacked(width < 620);
|
||||
});
|
||||
observer.observe(el);
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
|
||||
const load = useCallback(() => {
|
||||
call(commands.historyListDir(path))
|
||||
@@ -197,9 +210,17 @@ export function LocalHistoryEditor({ input }: { input: EditorInput }) {
|
||||
const revertLabel = current && !isLabel(current) && view?.deleted.has(current.path) ? "Restore" : "Revert";
|
||||
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
<div
|
||||
className={styles.sidebar}
|
||||
<SplitGroup
|
||||
elementRef={container}
|
||||
className={`${styles.root} ${styles.resizable}`}
|
||||
orientation={stacked ? "vertical" : "horizontal"}
|
||||
storageKey="openidea.localHistory.layout"
|
||||
>
|
||||
<SplitPanel
|
||||
id="revisions"
|
||||
defaultSize="28%"
|
||||
minSize={stacked ? "24%" : "160px"}
|
||||
maxSize="52%"
|
||||
onMouseDownCapture={(e) => {
|
||||
pointer.current = e.button === 0 && !!(e.target as Element).closest('[role="option"]');
|
||||
}}
|
||||
@@ -253,7 +274,7 @@ export function LocalHistoryEditor({ input }: { input: EditorInput }) {
|
||||
setExtra(new Set());
|
||||
}
|
||||
}}
|
||||
rowHeight={view.folder ? 52 : 38}
|
||||
rowHeight={view.folder ? 56 : 44}
|
||||
aria-label="Revisions"
|
||||
className={styles.list}
|
||||
empty={
|
||||
@@ -261,33 +282,36 @@ export function LocalHistoryEditor({ input }: { input: EditorInput }) {
|
||||
{view.folder ? tx`No local history for this folder yet` : tx`No local history for this path yet`}
|
||||
</span>
|
||||
}
|
||||
renderItem={(e) =>
|
||||
isLabel(e) ? (
|
||||
renderItem={(e) => {
|
||||
const label = isLabel(e);
|
||||
const pathText = !label && view.folder ? relativePath(root, e.path) || baseName(e.path) : null;
|
||||
return (
|
||||
<span className={styles.entry}>
|
||||
<span className={styles.time}>{formatTime(e.timestampMs)}</span>
|
||||
<span className={styles.labelRow}>
|
||||
<Icon name="bookmark" size={12} />
|
||||
<span className={styles.labelName}>{e.label}</span>
|
||||
<span className={styles.primaryRow}>
|
||||
{label && <Icon name="bookmark" size={12} />}
|
||||
<span className={styles.primary} title={e.label}>
|
||||
{e.label}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
) : (
|
||||
<span className={styles.entry}>
|
||||
<span className={styles.time}>{formatTime(e.timestampMs)}</span>
|
||||
{view.folder && (
|
||||
<span className={view.deleted.has(e.path) ? styles.deletedPath : styles.path}>
|
||||
{relativePath(root, e.path) || baseName(e.path)}
|
||||
{pathText && (
|
||||
<span className={view.deleted.has(e.path) ? styles.deletedPath : styles.path} title={pathText}>
|
||||
{pathText}
|
||||
</span>
|
||||
)}
|
||||
<span className={styles.label}>
|
||||
{e.label} · {formatSize(e.size)}
|
||||
<span className={styles.meta}>
|
||||
{formatTime(e.timestampMs)}
|
||||
{!label && ` · ${formatSize(e.size)}`}
|
||||
</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.diff}>{detail}</div>
|
||||
</div>
|
||||
</SplitPanel>
|
||||
<SplitHandle aria-label={tx("Revisions")} />
|
||||
<SplitPanel id="preview" defaultSize="72%">
|
||||
{detail}
|
||||
</SplitPanel>
|
||||
</SplitGroup>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Заблокувати користувача