fix(editor): make workspace refactoring previews easier to scan (#5183)

Separate the filename from its directory in workspace refactoring previews. This gives same-named files distinct locations and frees space for rename targets and occurrence counts. Hovering a file or a rename target shows its full path.
This commit is contained in:
l0ng-ai
2026-11-22 20:32:47 +08:00
committed by GitHub
parent 40e5f9b7b3
commit c5824771c1
3 changed files with 118 additions and 37 deletions
+27 -18
View File
@@ -532,20 +532,6 @@
.renamePreview .previewList {
overflow: visible;
}
.renamePreview .previewName {
min-width: 0;
max-width: 55%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.renamePreview .previewOp {
flex: 0 1 auto;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.renamePreview .previewWarning {
overflow-wrap: anywhere;
}
@@ -571,23 +557,46 @@
padding: 0 14px;
font-size: var(--fs-ui);
}
.previewName {
color: var(--fg-emphasis);
.previewFile {
flex: 1 1 auto;
display: flex;
align-items: baseline;
gap: var(--space-2);
min-width: 0;
}
.previewPath {
.previewName,
.previewDirectory,
.previewOp {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.previewName {
flex: none;
max-inline-size: 100%;
color: var(--fg-emphasis);
}
.previewFile:has(.previewDirectory) .previewName {
max-inline-size: 70%;
}
.previewDirectory {
color: var(--fg-subtle);
font-size: var(--fs-small);
direction: rtl;
}
.previewOp,
.previewCount {
flex: none;
font-size: var(--fs-small);
color: var(--fg-muted);
}
.previewOp {
max-inline-size: 55%;
}
.previewCount {
flex: none;
font-variant-numeric: tabular-nums;
}
.previewWarning {
flex: none;
+28 -19
View File
@@ -22,7 +22,7 @@ import {
selectableText,
T,
} from "@/ui";
import { basename, relativePath, useProject } from "@/platform/project";
import { basename, relativeDir, relativePath, useProject } from "@/platform/project";
import {
closePopup,
updatePopup,
@@ -761,25 +761,34 @@ function PreviewDialog({ popup }: { popup: Extract<LspPopup, { kind: "preview" }
</ul>
) : (
<ul data-testid="refactor-preview" className={styles.previewList} aria-label={tx("Changes")}>
{summary.entries.map((e) => (
<li key={e.path} className={styles.previewRow}>
<Icon name={fileIconName(basename(e.path), e.path)} size={14} className={styles.itemIcon} />
<span className={styles.previewName} title={relativePath(root, e.path)}>
{basename(e.path)}
</span>
<span className={styles.previewPath} title={relativePath(root, e.path)}>
{relativePath(root, e.path)}
</span>
<span className={styles.spacer} />
{e.operation === "rename" && e.to && <span className={styles.previewOp}>→ {basename(e.to)}</span>}
{e.operation && e.operation !== "rename" && <span className={styles.previewOp}>{e.operation}</span>}
{e.edits > 0 && (
<span className={styles.previewCount}>
{e.edits} {e.edits === 1 ? "occurrence" : "occurrences"}
{summary.entries.map((e) => {
const name = basename(e.path);
const directory = relativeDir(root, e.path);
return (
<li key={e.path} className={styles.previewRow}>
<Icon name={fileIconName(name, e.path)} size={14} className={styles.itemIcon} />
<span className={styles.previewFile} title={relativePath(root, e.path)}>
<span className={styles.previewName}>{name}</span>
{directory && (
<span className={styles.previewDirectory}>
<bdi>{directory}</bdi>
</span>
)}
</span>
)}
</li>
))}
{e.operation === "rename" && e.to && (
<span className={styles.previewOp} title={relativePath(root, e.to)}>
→ {basename(e.to)}
</span>
)}
{e.operation && e.operation !== "rename" && <span className={styles.previewOp}>{e.operation}</span>}
{e.edits > 0 && (
<span className={styles.previewCount}>
{e.edits} {e.edits === 1 ? "occurrence" : "occurrences"}
</span>
)}
</li>
);
})}
</ul>
)}
</Dialog>