mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-22 23:56:05 -10:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fad38a1bd | ||
|
|
f8477b506d |
No files matched your search
@@ -0,0 +1,72 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
async function showBuild(page: Page) {
|
||||
await page.evaluate(async () => {
|
||||
const storePath = "/src/features/build/store.ts";
|
||||
const layoutPath = "/src/workbench/toolwindows/store.ts";
|
||||
const { useBuildRun } = await import(/* @vite-ignore */ storePath);
|
||||
const { showToolWindow } = await import(/* @vite-ignore */ layoutPath);
|
||||
useBuildRun.setState({
|
||||
title: "Build Project",
|
||||
system: "typescript",
|
||||
status: "failed",
|
||||
durationMs: 1200,
|
||||
selected: null,
|
||||
lines: [
|
||||
{ kind: "out", text: "Compiling TypeScript" },
|
||||
{ kind: "err", text: "Expected a number" },
|
||||
],
|
||||
messages: [{ severity: "error", text: "Expected a number", path: null, range: null, code: null }],
|
||||
});
|
||||
showToolWindow("build", true);
|
||||
});
|
||||
const build = page.getByRole("region", { name: "Build", exact: true });
|
||||
await expect(build.getByRole("log", { name: "Build output" })).toBeVisible();
|
||||
return build;
|
||||
}
|
||||
|
||||
test("Build gives about two thirds of the initial split to output", async ({ workbench: page }) => {
|
||||
const build = await showBuild(page);
|
||||
const tree = build.locator("[data-panel][id=build-tree]");
|
||||
const console = build.locator("[data-panel][id=build-console]");
|
||||
const treeWidth = (await tree.boundingBox())!.width;
|
||||
const consoleWidth = (await console.boundingBox())!.width;
|
||||
expect(treeWidth / (treeWidth + consoleWidth)).toBeCloseTo(0.33, 2);
|
||||
});
|
||||
|
||||
test("Build output and diagnostics respond to a console font change", async ({ workbench: page }) => {
|
||||
const build = await showBuild(page);
|
||||
const log = build.getByRole("log", { name: "Build output" });
|
||||
const rowGap = async () => {
|
||||
const first = (await log.getByText("Compiling TypeScript", { exact: true }).boundingBox())!;
|
||||
const second = (await log.getByText("Expected a number", { exact: true }).boundingBox())!;
|
||||
return second.y - first.y;
|
||||
};
|
||||
await expect.poll(rowGap).toBe(20);
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ path);
|
||||
const { settings } = useProject.getState();
|
||||
useProject.setState({
|
||||
settings: {
|
||||
...settings,
|
||||
terminal: {
|
||||
...settings?.terminal,
|
||||
useEditorFont: false,
|
||||
fontFamily: "Fira Code",
|
||||
fallbackFontFamily: "Maple Mono NF CN",
|
||||
fontSize: 18,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
await expect(log).toHaveCSS("font-size", "18px");
|
||||
await expect(log).toHaveCSS("font-family", /"Fira Code".*"Maple Mono NF CN"/);
|
||||
await expect.poll(rowGap).toBe(27);
|
||||
await build.getByRole("treeitem", { name: "Expected a number", exact: true }).click();
|
||||
const diagnostic = build.getByRole("document", { name: "Build message" });
|
||||
await expect(diagnostic).toContainText("Expected a number");
|
||||
await expect(diagnostic).toHaveCSS("font-size", "18px");
|
||||
await expect(diagnostic).toHaveCSS("line-height", "27px");
|
||||
});
|
||||
@@ -76,8 +76,6 @@
|
||||
overflow: auto;
|
||||
position: relative;
|
||||
padding: 4px 0;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-code);
|
||||
color: var(--fg);
|
||||
background: var(--bg-app);
|
||||
-webkit-user-select: text;
|
||||
@@ -99,7 +97,6 @@
|
||||
left: 0;
|
||||
min-width: 100%;
|
||||
padding: 0 12px;
|
||||
line-height: 20px;
|
||||
white-space: pre;
|
||||
tab-size: 4;
|
||||
}
|
||||
@@ -141,9 +138,6 @@
|
||||
.detail {
|
||||
overflow: auto;
|
||||
padding: 4px 12px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-code);
|
||||
line-height: 20px;
|
||||
color: var(--fg);
|
||||
background: var(--bg-app);
|
||||
-webkit-user-select: text;
|
||||
|
||||
@@ -5,7 +5,16 @@
|
||||
* its source (as IDEA: selection shows, navigation jumps).
|
||||
*/
|
||||
import { copySelectionOnKeyDown } from "@/ui/selectableText";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, type MouseEvent, type ReactNode } from "react";
|
||||
import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
type MouseEvent,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
import clsx from "clsx";
|
||||
import { useVirtualizer } from "@tanstack/react-virtual";
|
||||
import { basename, relativeDir, useProject } from "@/platform/project";
|
||||
@@ -41,6 +50,7 @@ import { openTarget, openUrl } from "@/features/run/navigate";
|
||||
import { navigateToMessage, rerunBuild, selectBuildNode, useBuildRun } from "./store";
|
||||
import styles from "./Build.module.css";
|
||||
import { WidestColumns } from "@/platform/consoleColumns";
|
||||
import { useConsoleFont } from "@/platform/consoleFont";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
const SEVERITY_ICON: Record<Severity, string> = { error: "error", warning: "warning", info: "info", hint: "info" };
|
||||
@@ -203,8 +213,6 @@ function BuildTree() {
|
||||
);
|
||||
}
|
||||
|
||||
const LINE_HEIGHT = 20;
|
||||
|
||||
/**
|
||||
* One console line: file locations and URLs (compiler diagnostics, stack
|
||||
* frames) are links, resolved against the directory of the step that printed
|
||||
@@ -242,7 +250,7 @@ function ConsoleLineText({ line, root }: { line: ConsoleLine; root: string }) {
|
||||
return <>{out}</>;
|
||||
}
|
||||
|
||||
function BuildConsole() {
|
||||
function BuildConsole({ rowHeight }: { rowHeight: number }) {
|
||||
const root = useProject((s) => s.project?.root ?? "/");
|
||||
const lines = useBuildRun((s) => s.lines);
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
@@ -252,12 +260,15 @@ function BuildConsole() {
|
||||
const virtualizer = useVirtualizer({
|
||||
count: lines.length,
|
||||
getScrollElement: () => ref.current,
|
||||
estimateSize: () => LINE_HEIGHT,
|
||||
estimateSize: () => rowHeight,
|
||||
overscan: 20,
|
||||
});
|
||||
useLayoutEffect(() => {
|
||||
virtualizer.measure();
|
||||
}, [rowHeight, virtualizer]);
|
||||
useEffect(() => {
|
||||
if (stick.current && lines.length) virtualizer.scrollToIndex(lines.length - 1, { align: "end" });
|
||||
}, [lines.length, virtualizer]);
|
||||
}, [lines.length, rowHeight, virtualizer]);
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
@@ -268,7 +279,7 @@ function BuildConsole() {
|
||||
aria-label={tx("Build output")}
|
||||
onScroll={(e) => {
|
||||
const el = e.currentTarget;
|
||||
stick.current = el.scrollHeight - el.scrollTop - el.clientHeight < LINE_HEIGHT * 2;
|
||||
stick.current = el.scrollHeight - el.scrollTop - el.clientHeight < rowHeight * 2;
|
||||
}}
|
||||
>
|
||||
<div
|
||||
@@ -319,15 +330,16 @@ function MessageDetail({ message }: { message: BuildMessage }) {
|
||||
);
|
||||
}
|
||||
|
||||
function BuildOutput() {
|
||||
function BuildOutput({ rowHeight }: { rowHeight: number }) {
|
||||
const selected = useBuildRun((s) => s.selected);
|
||||
const messages = useBuildRun((s) => s.messages);
|
||||
const node = useMemo(() => (selected ? findNode(messages, selected) : undefined), [selected, messages]);
|
||||
return node?.kind === "message" ? <MessageDetail message={node.message} /> : <BuildConsole />;
|
||||
return node?.kind === "message" ? <MessageDetail message={node.message} /> : <BuildConsole rowHeight={rowHeight} />;
|
||||
}
|
||||
|
||||
export function BuildView() {
|
||||
const hasBuild = useBuildRun((s) => s.status !== null);
|
||||
const font = useConsoleFont();
|
||||
if (!hasBuild) {
|
||||
return (
|
||||
<div className={styles.view}>
|
||||
@@ -345,12 +357,22 @@ export function BuildView() {
|
||||
id="build-view-split"
|
||||
storageKey="openidea.build.split"
|
||||
>
|
||||
<SplitPanel id="build-tree" defaultSize="38%" minSize="120px" className={styles.pane}>
|
||||
<SplitPanel id="build-tree" defaultSize="33%" minSize="120px" className={styles.pane}>
|
||||
<BuildTree />
|
||||
</SplitPanel>
|
||||
<SplitHandle />
|
||||
<SplitPanel id="build-console" minSize="120px" className={styles.pane}>
|
||||
<BuildOutput />
|
||||
<SplitPanel
|
||||
id="build-console"
|
||||
minSize="120px"
|
||||
className={styles.pane}
|
||||
style={{
|
||||
fontFamily: font.family,
|
||||
fontSize: font.size,
|
||||
fontWeight: font.weight,
|
||||
lineHeight: `${font.rowHeight}px`,
|
||||
}}
|
||||
>
|
||||
<BuildOutput rowHeight={font.rowHeight} />
|
||||
</SplitPanel>
|
||||
</SplitGroup>
|
||||
</div>
|
||||
|
||||
@@ -12,8 +12,8 @@ export interface ConsoleFont {
|
||||
}
|
||||
|
||||
/**
|
||||
* The font of the Run and Debug consoles: Tools › Terminal › Font (which can follow
|
||||
* Editor › Font), with the row height both consoles lay their lines out with. The
|
||||
* The font of the Build, Run and Debug consoles: Tools › Terminal › Font (which can follow
|
||||
* Editor › Font), with the row height the consoles lay their lines out with. The
|
||||
* weights match the terminal's: the editor's main and bold weights when the terminal
|
||||
* uses the editor font, else regular and bold.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user