mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-23 08:49:33 -10:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9747bf54cf | ||
|
|
dc0c97c0ae |
No files matched your search
@@ -63,6 +63,44 @@ const result = (page: Page) => page.getByRole("region", { name: "Result" });
|
||||
const text = async (pane: Locator) => (await pane.locator(".cm-content").innerText()).replace(//g, "");
|
||||
const status = (page: Page) => page.locator("#merge-host [class*=status]").first();
|
||||
|
||||
test("merge controls and pane titles fit while resizing the result", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 400, height: 600 });
|
||||
await mountMerge(page);
|
||||
const host = page.locator("#merge-host");
|
||||
for (const name of ["Accept Yours", "Accept Theirs", "Cancel", "Apply"])
|
||||
await expect(host.getByRole("button", { name, exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await expect(status(page)).toHaveText("3 changes left, 2 conflicts");
|
||||
await expect(status(page)).toBeInViewport({ ratio: 1 });
|
||||
|
||||
const ours = page.getByRole("region", { name: "Your version" });
|
||||
await expect(ours.getByText("Your version", { exact: true })).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("region", { name: "Their version" }).getByText("Their version", { exact: true }),
|
||||
).toBeVisible();
|
||||
await ours.locator(".cm-merge-accept").nth(1).focus();
|
||||
await page.keyboard.press("Enter");
|
||||
await expect.poll(() => text(result(page))).toContain("\nmine\n");
|
||||
|
||||
await page.setViewportSize({ width: 980, height: 660 });
|
||||
const resultWidth = async () => (await result(page).boundingBox())!.width;
|
||||
const initial = await resultWidth();
|
||||
const left = host.getByRole("separator", { name: "Resize left merge pane" });
|
||||
await left.press("ArrowLeft");
|
||||
await expect.poll(resultWidth).toBeGreaterThan(initial + 1);
|
||||
|
||||
const right = host.getByRole("separator", { name: "Resize right merge pane" });
|
||||
const grip = (await right.boundingBox())!;
|
||||
const withLeftResized = await resultWidth();
|
||||
await page.mouse.move(grip.x + grip.width / 2, grip.y + grip.height / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(grip.x + grip.width / 2 + 36, grip.y + grip.height / 2, { steps: 4 });
|
||||
await page.mouse.up();
|
||||
await expect.poll(resultWidth).toBeGreaterThan(withLeftResized + 20);
|
||||
await expect(result(page).getByText("Result", { exact: true })).toBeVisible();
|
||||
await expect(ours.getByText("Changes from main", { exact: true })).toBeVisible();
|
||||
await expect.poll(() => text(result(page))).toContain("\nmine\n");
|
||||
});
|
||||
|
||||
/** Capture the save boundary, keeping real editor state, dialogs and Apply behavior. */
|
||||
async function captureWrites(page: Page) {
|
||||
await page.evaluate(async () => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
.root {
|
||||
--merge-band-width: 30px;
|
||||
container: merge-editor / inline-size;
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -9,14 +12,16 @@
|
||||
}
|
||||
.toolbar {
|
||||
flex: none;
|
||||
height: var(--h-header);
|
||||
min-height: var(--h-header);
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
padding: 0 6px;
|
||||
padding: var(--space-0-5) var(--space-1-5);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.sep {
|
||||
flex: none;
|
||||
width: 1px;
|
||||
height: 14px;
|
||||
margin: 0 4px;
|
||||
@@ -24,59 +29,96 @@
|
||||
}
|
||||
.status {
|
||||
margin-left: auto;
|
||||
padding: 0 8px;
|
||||
padding: 0 var(--space-2);
|
||||
max-width: 100%;
|
||||
color: var(--vcs-conflict);
|
||||
font-size: var(--fs-small);
|
||||
text-align: end;
|
||||
}
|
||||
.statusDone {
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
.labels {
|
||||
.paneTitle,
|
||||
.resultTitle {
|
||||
flex: none;
|
||||
height: var(--h-row);
|
||||
display: grid;
|
||||
/* The panes' columns, so each title sits over its pane. */
|
||||
grid-template-columns: 1fr 30px 1fr 30px 1fr;
|
||||
padding: 0 var(--space-2);
|
||||
border-bottom: 1px solid var(--border);
|
||||
color: var(--fg-secondary);
|
||||
font-size: var(--fs-small);
|
||||
line-height: var(--h-row);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.labels > span {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 12px;
|
||||
.resultTitle {
|
||||
color: var(--fg-strong);
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
}
|
||||
.labels > span:nth-child(2) {
|
||||
grid-column: 3;
|
||||
.sideColumn {
|
||||
container: merge-side / inline-size;
|
||||
}
|
||||
.labels > span:nth-child(3) {
|
||||
grid-column: 5;
|
||||
.sideTitle {
|
||||
display: none;
|
||||
}
|
||||
@container merge-side (max-width: 180px) {
|
||||
.branchTitle {
|
||||
display: none;
|
||||
}
|
||||
.sideTitle {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
.panes {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 30px 1fr 30px 1fr;
|
||||
display: flex;
|
||||
}
|
||||
.panes[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.paneGroup {
|
||||
flex: 1;
|
||||
}
|
||||
.pane {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
}
|
||||
/* Between two panes, as the diff viewer's divider: the bands of the changes on either side. */
|
||||
.divider {
|
||||
position: relative;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
.divider[data-separator] {
|
||||
width: var(--merge-band-width);
|
||||
background: var(--bg-app);
|
||||
}
|
||||
.divider[data-separator]:is([data-separator="hover"], [data-separator="active"]) {
|
||||
background: var(--bg-toolbar-hover);
|
||||
}
|
||||
.divider[data-separator]:focus-visible {
|
||||
outline: 1px solid var(--focus-ring);
|
||||
outline-offset: -1px;
|
||||
}
|
||||
.divider::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset-block-start: calc((var(--h-row) - 12px) / 2);
|
||||
inset-inline-start: calc(50% - 1px);
|
||||
height: 12px;
|
||||
width: 2px;
|
||||
border-radius: var(--radius-small);
|
||||
background: var(--border-strong);
|
||||
}
|
||||
/* The headings share the splitter geometry. The curves start below them. */
|
||||
.band {
|
||||
position: absolute;
|
||||
inset: var(--h-row) 0 0;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
border-left: 1px solid var(--border);
|
||||
border-right: 1px solid var(--border);
|
||||
}
|
||||
.divider > svg {
|
||||
.band > svg {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
}
|
||||
@@ -103,16 +145,42 @@
|
||||
.footer {
|
||||
flex: none;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-2);
|
||||
padding: 8px 12px;
|
||||
padding: var(--space-2) var(--space-3);
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
.footerGroup {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
min-width: 0;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
.footerGroup:last-child {
|
||||
margin-inline-start: auto;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
@container merge-editor (max-width: 680px) {
|
||||
.divider[data-separator] {
|
||||
width: 20px;
|
||||
}
|
||||
}
|
||||
@container merge-editor (max-width: 440px) {
|
||||
.divider[data-separator] {
|
||||
width: 14px;
|
||||
}
|
||||
.toolbar > .sep {
|
||||
display: none;
|
||||
}
|
||||
.status {
|
||||
flex-basis: 100%;
|
||||
order: 1;
|
||||
padding: 0;
|
||||
text-align: start;
|
||||
}
|
||||
}
|
||||
.message {
|
||||
flex: 1;
|
||||
outline: none;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** Three-pane merge editor: Yours | Result | Theirs, after IntelliJ's merge tool. */
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useId, useRef, useState } from "react";
|
||||
import { Transaction, type EditorState, type Extension, type TransactionSpec } from "@codemirror/state";
|
||||
import { EditorView, keymap } from "@codemirror/view";
|
||||
import { history, historyKeymap, undoDepth } from "@codemirror/commands";
|
||||
@@ -11,7 +11,7 @@ import { setContext } from "@/platform/context";
|
||||
import { tx, useTxTemplate } from "@/platform/i18n";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { copyText } from "@/ui/selectableText";
|
||||
import { Button, Spinner, T } from "@/ui";
|
||||
import { Button, Spinner, SplitGroup, SplitHandle, SplitPanel, T } from "@/ui";
|
||||
import { editorService, type EditorInput } from "@/workbench/contributions";
|
||||
import { blameSlot, toggleAnnotations } from "./blame";
|
||||
import { firstLineOf, languageFor, viewerBase } from "./cm";
|
||||
@@ -114,6 +114,7 @@ export function MergeEditor({ input }: { input: EditorInput }) {
|
||||
const [summary, setSummary] = useState<MergeSummary>(NOTHING_LEFT);
|
||||
const [autoApply, setAutoApply] = useState(readAutoApply);
|
||||
const [resolved, setResolved] = useState(false);
|
||||
const paneId = useId();
|
||||
const rootRef = useRef<HTMLDivElement>(null);
|
||||
const paneRef = useRef<MergeSide | "result">("result");
|
||||
const [actionHost] = useState<MergeActionHost>(() => ({
|
||||
@@ -607,45 +608,70 @@ export function MergeEditor({ input }: { input: EditorInput }) {
|
||||
</div>
|
||||
);
|
||||
|
||||
const yourTitle = txt(titles.yours);
|
||||
const resultTitle = tx("Result");
|
||||
const theirTitle = txt(titles.theirs);
|
||||
return (
|
||||
<div ref={rootRef} className={styles.root} {...focusProps}>
|
||||
<MergeToolbar summary={summary} step={goto} run={(c) => void runAction(c)} />
|
||||
<div className={styles.labels}>
|
||||
<span>{txt(titles.yours)}</span>
|
||||
<span>
|
||||
<T>Result</T>
|
||||
</span>
|
||||
<span>{txt(titles.theirs)}</span>
|
||||
</div>
|
||||
{!state || lang === null ? (
|
||||
<div className={styles.message}>
|
||||
<Spinner size={14} />
|
||||
</div>
|
||||
) : null}
|
||||
<div className={styles.panes} hidden={!state || lang === null}>
|
||||
<div
|
||||
ref={oursRef}
|
||||
className={styles.pane}
|
||||
aria-label={tx("Your version")}
|
||||
role="region"
|
||||
onContextMenu={(e) => oursView.current && showSideMenu(e, oursView.current, "left")}
|
||||
/>
|
||||
<div ref={leftDividerRef} className={styles.divider} aria-hidden />
|
||||
<div
|
||||
ref={resultRef}
|
||||
className={styles.pane}
|
||||
aria-label={tx("Result")}
|
||||
role="region"
|
||||
onContextMenu={(e) => resultView.current && showResultMenu(e, resultView.current)}
|
||||
/>
|
||||
<div ref={rightDividerRef} className={styles.divider} aria-hidden />
|
||||
<div
|
||||
ref={theirsRef}
|
||||
className={styles.pane}
|
||||
aria-label={tx("Their version")}
|
||||
role="region"
|
||||
onContextMenu={(e) => theirsView.current && showSideMenu(e, theirsView.current, "right")}
|
||||
/>
|
||||
<SplitGroup className={styles.paneGroup} orientation="horizontal">
|
||||
<SplitPanel
|
||||
id={`${paneId}-yours`}
|
||||
role="region"
|
||||
aria-label={tx("Your version")}
|
||||
className={styles.sideColumn}
|
||||
minSize="18%"
|
||||
defaultSize="30%"
|
||||
>
|
||||
<div className={styles.paneTitle} title={yourTitle}>
|
||||
<span className={styles.branchTitle}>{yourTitle}</span>
|
||||
<span className={styles.sideTitle}>{tx("Your version")}</span>
|
||||
</div>
|
||||
<div
|
||||
ref={oursRef}
|
||||
className={styles.pane}
|
||||
onContextMenu={(e) => oursView.current && showSideMenu(e, oursView.current, "left")}
|
||||
/>
|
||||
</SplitPanel>
|
||||
<SplitHandle className={styles.divider} aria-label={tx("Resize left merge pane")}>
|
||||
<div ref={leftDividerRef} className={styles.band} aria-hidden />
|
||||
</SplitHandle>
|
||||
<SplitPanel id={`${paneId}-result`} role="region" aria-label={resultTitle} minSize="24%" defaultSize="40%">
|
||||
<div className={styles.resultTitle}>{resultTitle}</div>
|
||||
<div
|
||||
ref={resultRef}
|
||||
className={styles.pane}
|
||||
onContextMenu={(e) => resultView.current && showResultMenu(e, resultView.current)}
|
||||
/>
|
||||
</SplitPanel>
|
||||
<SplitHandle className={styles.divider} aria-label={tx("Resize right merge pane")}>
|
||||
<div ref={rightDividerRef} className={styles.band} aria-hidden />
|
||||
</SplitHandle>
|
||||
<SplitPanel
|
||||
id={`${paneId}-theirs`}
|
||||
role="region"
|
||||
aria-label={tx("Their version")}
|
||||
className={styles.sideColumn}
|
||||
minSize="18%"
|
||||
defaultSize="30%"
|
||||
>
|
||||
<div className={styles.paneTitle} title={theirTitle}>
|
||||
<span className={styles.branchTitle}>{theirTitle}</span>
|
||||
<span className={styles.sideTitle}>{tx("Their version")}</span>
|
||||
</div>
|
||||
<div
|
||||
ref={theirsRef}
|
||||
className={styles.pane}
|
||||
onContextMenu={(e) => theirsView.current && showSideMenu(e, theirsView.current, "right")}
|
||||
/>
|
||||
</SplitPanel>
|
||||
</SplitGroup>
|
||||
</div>
|
||||
<MergeFooter run={(c) => void runAction(c)} />
|
||||
</div>
|
||||
|
||||
@@ -97,7 +97,9 @@ export function MergeToolbar({ summary, step, run }: ToolbarProps) {
|
||||
onClick={direct(() => run("compare"))}
|
||||
data-merge-menu="compare"
|
||||
/>
|
||||
<span className={clsx(styles.status, !summary.pending && styles.statusDone)}>{statusText(summary)}</span>
|
||||
<span className={clsx(styles.status, !summary.pending && styles.statusDone)} role="status">
|
||||
{statusText(summary)}
|
||||
</span>
|
||||
<IconButton
|
||||
icon="refresh"
|
||||
title="Reload from Disk"
|
||||
|
||||
@@ -2738,5 +2738,7 @@
|
||||
"{count} hover actions": "{count} hover actions",
|
||||
"{description}; JVM options: {flags}": "{description}; JVM options: {flags}",
|
||||
"Sorting Options": "Sorting Options",
|
||||
"Sort by Duration": "Sort by Duration"
|
||||
"Sort by Duration": "Sort by Duration",
|
||||
"Resize left merge pane": "Resize left merge pane",
|
||||
"Resize right merge pane": "Resize right merge pane"
|
||||
}
|
||||
@@ -9108,5 +9108,7 @@
|
||||
"{count} hover actions": "{count} 个悬停操作",
|
||||
"{description}; JVM options: {flags}": "{description};JVM 选项:{flags}",
|
||||
"Sorting Options": "排序选项",
|
||||
"Sort by Duration": "按持续时间排序"
|
||||
"Sort by Duration": "按持续时间排序",
|
||||
"Resize left merge pane": "调整左侧合并窗格宽度",
|
||||
"Resize right merge pane": "调整右侧合并窗格宽度"
|
||||
}
|
||||
Reference in new issue
Block a user