Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 7836609a98 fix(editor): keep color picker controls in view 2026-11-22 23:07:42 +08:00
l0ng-ai 36061abc91 fix(debugger): lay out inline evaluation and history together (#5216)
The Variables pane now keeps Add to Watches and the history arrow at the trailing edge of the evaluation field. The field uses the configured editor font family at up to the workbench text size, and its short placeholder fits narrow docks. The history menu matches the field width and uses the existing Evaluate history for single-line expressions.
2026-11-22 22:24:43 +08:00
15 змінених файлів з 284 додано та 45 видалено

No files matched your search

+62
Переглянути файл
@@ -0,0 +1,62 @@
import { expect, test } from "./fixtures";
test("the editor color picker fits recent colors and keeps its actions visible", async ({ workbench: page }) => {
await page.setViewportSize({ width: 980, height: 720 });
await page.evaluate(async () => {
const recent = Array.from({ length: 20 }, (_, i) => `#${((i + 1) * 314241).toString(16).padStart(6, "0")}ff`);
localStorage.setItem("openidea.colorPicker.recent.v1", JSON.stringify(recent));
const contributions = "/src/workbench/contributions.ts";
const { editorService } = await import(/* @vite-ignore */ contributions);
await editorService().openFile("/dev/acme-api/theme.css");
});
const editor = page.locator(".cm-editor").first();
const contents = editor.locator(".cm-content");
await contents.click();
await page.keyboard.press("Meta+a");
await page.keyboard.insertText(".notice { color: #5a8fbd; }");
const swatch = editor.locator(".cm-openidea-gutter-colors").getByTitle("#5a8fbd", { exact: true });
const picker = page.getByRole("dialog", { name: "Color picker", exact: true });
const palette = picker.locator(".react-colorful__saturation");
const hex = picker.getByRole("textbox", { name: "Hexadecimal", exact: true });
const apply = picker.getByRole("button", { name: "Apply", exact: true });
const cancel = picker.getByRole("button", { name: "Cancel", exact: true });
const recent = picker.getByRole("group", { name: "Recent colors", exact: true }).getByRole("button");
await swatch.click();
await expect(hex).toHaveValue("5A8FBDFF");
expect((await picker.boundingBox())!.width).toBeLessThanOrEqual(308);
await expect(palette).toHaveCSS("height", "152px");
expect(await picker.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
await hex.fill("#ff0000");
expect(await picker.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
await page.keyboard.press("Escape");
await expect(picker).toBeHidden();
await page.setViewportSize({ width: 280, height: 315 });
await swatch.click();
await expect(recent).toHaveCount(20);
const swatchRows = await recent.evaluateAll((elements) => {
const rows: number[] = [];
for (const element of elements) {
const box = element.getBoundingClientRect();
if (!rows.includes(box.top)) rows.push(box.top);
const previous = element.previousElementSibling?.getBoundingClientRect();
if (previous?.top === box.top && previous.right > box.left) throw new Error("Color swatches overlap");
}
return rows.length;
});
expect(swatchRows).toBeGreaterThan(2);
expect(await picker.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
await expect(apply).toBeInViewport({ ratio: 1 });
await expect(cancel).toBeInViewport({ ratio: 1 });
await hex.fill("#d27c54");
await cancel.click();
await expect(picker).toBeHidden();
await expect(contents).toContainText("#5a8fbd");
await swatch.click();
await hex.fill("#d27c54");
await apply.click();
await expect(picker).toBeHidden();
await expect(contents).toContainText("#d27c54");
});
+83
Переглянути файл
@@ -200,3 +200,86 @@ test("Evaluate keeps a multiline expression and its result visible in a short di
await expect(field).toHaveValue(expression);
await expect(field).toBeFocused();
});
test("Variables keeps evaluation, watches and expression history together in a narrow dock", async ({
workbench: page,
}) => {
await page.setViewportSize({ width: 720, height: 620 });
await stubDesktop(page);
await page.evaluate(async (session) => {
const handlers = window.__ipc.handlers;
handlers.debug_capabilities = () => ({});
handlers.debug_completions = () => [];
handlers.debug_scopes = () => [];
handlers.debug_evaluate_in = () => ({
name: "result",
value: "42",
typeName: "int",
variablesReference: 0,
evaluateName: null,
});
const statePath = "/src/features/debugger/state.ts";
const historyPath = "/src/features/debugger/ui/expressionHistory.ts";
const projectPath = "/src/platform/project.ts";
const servicesPath = "/src/workbench/contributions.ts";
const layoutPath = "/src/workbench/toolwindows/store.ts";
const { adoptSession } = await import(/* @vite-ignore */ statePath);
const { pushHistory } = await import(/* @vite-ignore */ historyPath);
const { useProject } = await import(/* @vite-ignore */ projectPath);
const { toolWindowService } = await import(/* @vite-ignore */ servicesPath);
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutPath);
const settings = useProject.getState().settings;
useProject.setState({
settings: { ...settings, editor: { ...settings?.editor, fontFamily: "Consolas", fontSize: 18 } },
});
pushHistory("evaluate", "order.total + tax");
pushHistory("evaluate", "if ready:\n settle()");
adoptSession(session, { name: "Checkout", adapter: "debugpy", status: "paused", selectedFrame: 11 });
moveToolWindow("debug", "right");
setToolWindowSize("right", 285);
toolWindowService().show("debug", true);
}, SESSION);
const debug = page.getByRole("region", { name: "Debug", exact: true });
const variables = debug.getByRole("tab", { name: "Variables", exact: true });
if (await variables.isVisible()) await variables.click();
const field = debug.getByRole("textbox", { name: "Evaluate expression", exact: true });
const historyButton = debug.getByRole("button", { name: "History", exact: true });
const watch = debug.getByRole("button", { name: "Add to Watches", exact: true });
await expect(field).toBeVisible();
await expect(historyButton).toBeVisible();
await expect(field).toHaveAttribute("placeholder", "Evaluate expression");
await expect(field).toHaveCSS("font-family", /^"?Consolas"?,/);
await expect(field).toHaveCSS("font-size", "13px");
expect((await field.boundingBox())!.width).toBeGreaterThan(100);
expect((await watch.boundingBox())!.x).toBeLessThan((await historyButton.boundingBox())!.x);
await historyButton.click();
const menu = page.getByRole("menu", { name: "Expression history", exact: true });
await expect(menu.getByRole("menuitem")).toHaveText(["order.total + tax"]);
const row = (await field.locator("..").boundingBox())!;
const popup = (await menu.locator("..").boundingBox())!;
expect(popup.x).toBeCloseTo(row.x, 0);
expect(popup.width).toBeCloseTo(row.width, 0);
await page.keyboard.press("Escape");
await expect(menu).toBeHidden();
await expect(historyButton).toBeFocused();
await historyButton.press("Enter");
await menu.getByRole("menuitem", { name: "order.total + tax" }).press("Enter");
await expect(field).toBeFocused();
await expect(field).toHaveValue("order.total + tax");
await field.press("Enter");
await expect
.poll(() => ipcCalls(page, "debug_evaluate_in"))
.toContainEqual(expect.objectContaining({ expression: "order.total + tax", context: "repl" }));
await field.fill("order.total");
await watch.click();
await expect(field).toHaveValue("");
await expect
.poll(() => ipcCalls(page, "debug_evaluate_in"))
.toContainEqual(expect.objectContaining({ expression: "order.total", context: "watch" }));
await historyButton.click();
await expect(menu.getByRole("menuitem")).toHaveText(["order.total", "order.total + tax"]);
});
+1 -1
Переглянути файл
@@ -293,7 +293,7 @@ describe("debug tool window", () => {
expect(screen.getByRole("tab", { name: "Threads & Variables" })).toBeTruthy();
expect(screen.getByRole("tab", { name: "Console" })).toBeTruthy();
expect(screen.getByRole("option", { selected: true })).toHaveTextContent("main:12, main.py");
expect(screen.getByPlaceholderText("Evaluate expression (↩) or add a watch (⇧⌘↩)")).toBeTruthy();
expect(screen.getByRole("textbox", { name: "Evaluate expression" })).toBeTruthy();
expect(await screen.findByText("{int}")).toBeTruthy();
expect(screen.getByText("'hi'")).toBeTruthy();
// A multi-line rendering stays on its row.
+16 -2
Переглянути файл
@@ -210,14 +210,28 @@
}
.evalField {
height: 30px;
min-height: var(--h-field);
flex: none;
display: flex;
align-items: center;
gap: var(--space-1);
padding: 0 4px 0 12px;
padding: var(--space-0-5) var(--space-1) var(--space-0-5) var(--space-2);
background: var(--bg-input);
border-bottom: 1px solid var(--border);
}
.evalField:focus-within {
box-shadow: inset 0 -1px var(--focus-ring);
}
.evalField > button {
flex: none;
}
.evalField .evalInput {
padding: 0;
}
.evalHistory {
padding-block: var(--space-1);
overflow-x: hidden;
}
.repl {
height: 28px;
+81 -10
Переглянути файл
@@ -3,6 +3,10 @@ import { writeClipboardText } from "@/platform/clipboard";
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from "react";
import clsx from "clsx";
import { executeAction } from "@/platform/actions";
import { editorPrefs } from "@/platform/editorSettings";
import { monoFontFamily } from "@/platform/fonts";
import { isImeKey } from "@/platform/ime";
import { formatBinding, hostBinding } from "@/platform/keymap";
import { basename, useProject } from "@/platform/project";
import { call, commands, isTauri, type Scope, type Variable } from "@/platform/ipc";
import {
@@ -11,6 +15,8 @@ import {
IconButton,
Kbd,
Menu,
MenuList,
Popup,
Select,
SplitGroup,
SplitHandle,
@@ -54,6 +60,7 @@ import { MemoryView } from "../memory/MemoryView";
import { DebugConsole } from "./DebugConsole";
import { VariablesView, type VarRoot } from "./VariablesView";
import { useExpressionCompletion } from "./ExpressionCompletion";
import { pushHistory, readHistory } from "./expressionHistory";
import { sortVariables } from "../values";
import { workflowSettings } from "@/platform/workflowSettings";
import { useToolWindowShown } from "@/workbench/contributions";
@@ -555,9 +562,12 @@ function VariablesPane({ session }: { session: DebugSession }) {
const watches = useDebug((s) => s.watches);
const stopSeq = useDebug((s) => s.stopSeq);
const variablesEpoch = useDebug((s) => s.variablesEpoch);
const settings = useProject((s) => s.settings);
const [expression, setExpression] = useState("");
const evalField = useRef<HTMLInputElement>(null);
const evalRow = useRef<HTMLDivElement>(null);
const completion = useExpressionCompletion(evalField, expression, setExpression, session);
const [history, setHistory] = useState<{ sessionId: number; stopSeq: number; entries: string[] } | null>(null);
const [lastEval, setLastEval] = useState<EvalRow | null>(null);
const [scopeData, setScopeData] = useState<{ frame: number | null; scopes: Scope[]; locals: Variable[] }>({
frame: null,
@@ -570,6 +580,8 @@ function VariablesPane({ session }: { session: DebugSession }) {
rows: [],
});
const frame = session.status === "paused" ? session.selectedFrame : null;
const historyOpen = frame != null && history?.sessionId === session.id && history.stopSeq === stopSeq;
const editor = settings?.editor;
const live = liveWatchesApply(session);
// A hidden tool window stays mounted: its watches must not go on running in the page.
const liveWatches = useLiveWatches(session, watches, useToolWindowShown());
@@ -676,6 +688,7 @@ function VariablesPane({ session }: { session: DebugSession }) {
const run = async () => {
const e = expression.trim();
if (!e) return;
pushHistory("evaluate", e);
try {
setLastEval({
expression: e,
@@ -687,12 +700,32 @@ function VariablesPane({ session }: { session: DebugSession }) {
}
};
const addExpressionWatch = () => {
const e = expression.trim();
if (!e) return;
pushHistory("evaluate", e);
addWatch(e);
setExpression("");
};
const recall = (text: string) => {
setExpression(text);
requestAnimationFrame(() => {
evalField.current?.focus();
evalField.current?.setSelectionRange(text.length, text.length);
});
};
return (
<div className={styles.variables}>
<div className={styles.evalField}>
<div ref={evalRow} className={styles.evalField}>
<input
ref={evalField}
className={styles.evalInput}
style={{
fontFamily: monoFontFamily(editor?.fontFamily, editorPrefs(settings).fallbackFont, "var(--font-mono)"),
fontSize: editor?.fontSize ? `min(var(--fs-ui), ${editor.fontSize}px)` : undefined,
}}
value={expression}
onChange={(e) => {
setExpression(e.target.value);
@@ -700,17 +733,16 @@ function VariablesPane({ session }: { session: DebugSession }) {
}}
onBlur={completion.close}
onKeyDown={(e) => {
if (completion.onKeyDown(e)) return;
if (isImeKey(e.nativeEvent) || completion.onKeyDown(e)) return;
if (e.key === "Enter" && (e.metaKey || e.ctrlKey) && e.shiftKey) {
e.preventDefault();
addWatch(expression);
setExpression("");
addExpressionWatch();
} else if (e.key === "Enter") {
e.preventDefault();
void run();
}
}}
placeholder={frame != null ? "Evaluate expression (↩) or add a watch (⇧⌘↩)" : "Evaluate expression"}
placeholder={tx("Evaluate expression")}
aria-label={tx("Evaluate expression")}
spellCheck={false}
autoComplete="off"
@@ -720,16 +752,55 @@ function VariablesPane({ session }: { session: DebugSession }) {
<IconButton
icon="plus"
title="Add to Watches"
shortcut="⇧⌘↩"
shortcut={formatBinding(hostBinding("Meta+Shift+Enter"))}
size="small"
iconSize={16}
disabled={!expression.trim()}
onClick={() => {
addWatch(expression);
setExpression("");
}}
onClick={addExpressionWatch}
/>
<IconButton
icon="chevron-down"
title="History"
size="small"
aria-haspopup="menu"
aria-expanded={historyOpen}
disabled={frame == null}
onClick={() =>
setHistory(
historyOpen
? null
: {
sessionId: session.id,
stopSeq,
entries: readHistory("evaluate")
.filter((entry) => !/[\r\n]/.test(entry))
.slice(0, 20),
},
)
}
/>
</div>
<Popup
open={historyOpen}
onClose={() => setHistory(null)}
anchor={evalRow}
placement="bottom-start"
matchWidth
role="presentation"
autoFocus={false}
className={styles.evalHistory}
>
<MenuList
aria-label={tx("Expression history")}
iconColumn={false}
onDone={() => setHistory(null)}
items={
history?.entries.length
? history.entries.map((entry) => ({ label: entry, verbatim: true, run: () => recall(entry) }))
: [{ label: "No history", disabled: true }]
}
/>
</Popup>
{frame == null && !watches.length && !lastEval ? (
<div className={styles.note}>
{session.status === "terminated"
+1
Переглянути файл
@@ -837,6 +837,7 @@
"Unknown error": "Unknown error",
"Retry Loading Conversation": "Retry Loading Conversation",
"No conversation history": "No conversation history",
"No history": "No history",
"Loading the conversation timed out. Try again.": "Loading the conversation timed out. Try again.",
"Couldn't load the conversation: {0}": "Couldn't load the conversation: {0}",
"Astro Language Server": "Astro Language Server",
-1
Переглянути файл
@@ -782,7 +782,6 @@
"Evaluate": "Evaluar",
"Evaluate Expression…": "Evaluar expresión…",
"Evaluate expression": "Evaluar expresión",
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "Evaluar expresión (↩) o agregar una expresión de inspección (⇧⌘↩)",
"Evaluate in the debug console": "Evaluar en la consola de depuración",
"Evaluation result": "Resultado de la evaluación",
"Everything is up to date": "Todo está actualizado",
-1
Переглянути файл
@@ -719,7 +719,6 @@
"Evaluate": "Évaluer",
"Evaluate Expression…": "Évaluer l'expression…",
"Evaluate expression": "Évaluer l'expression",
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "Évaluer l'expression (↩) ou ajouter une expression surveillée (⇧⌘↩)",
"Evaluate in the debug console": "Évaluer dans la console de débogage",
"Evaluation result": "Résultat de l'évaluation",
"Everything is up to date": "Tout est à jour",
-1
Переглянути файл
@@ -818,7 +818,6 @@
"Evaluate": "평가",
"Evaluate Expression…": "표현식 평가…",
"Evaluate expression": "표현식 평가",
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "표현식 평가(↩) 또는 watch 추가(⇧⌘↩)",
"Evaluate in the debug console": "디버그 콘솔에서 평가",
"Evaluation result": "평가 결과",
"Everything is up to date": "모두 최신 상태입니다",
-1
Переглянути файл
@@ -774,7 +774,6 @@
"Evaluate": "Oblicz/Ewaluuj",
"Evaluate Expression…": "Oblicz wyrażenie…",
"Evaluate expression": "Oblicz wyrażenie",
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "Oblicz wyrażenie (↩) lub dodaj do obserwowanych (⇧⌘↩)",
"Evaluate in the debug console": "Oblicz w konsoli debugowania",
"Evaluation result": "Wynik obliczenia",
"Everything is up to date": "Wszystko jest aktualne",
-1
Переглянути файл
@@ -774,7 +774,6 @@
"Evaluate": "Avaliar",
"Evaluate Expression…": "Avaliar expressão…",
"Evaluate expression": "Avaliar expressão",
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "Avaliar expressão (↩) ou adicionar inspeção (⇧⌘↩)",
"Evaluate in the debug console": "Avaliar no console de depuração",
"Evaluation result": "Resultado da avaliação",
"Everything is up to date": "Tudo está atualizado",
-1
Переглянути файл
@@ -3570,7 +3570,6 @@
"Evaluate": "Değerlendir",
"Evaluate Expression…": "İfadeyi Değerlendir…",
"Evaluate expression": "İfadeyi değerlendir",
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "İfadeyi değerlendir (↩) veya izleme ekle (⇧⌘↩)",
"Evaluate in the debug console": "Hata ayıklama konsolunda değerlendir",
"Evaluation result": "Değerlendirme sonucu",
"Everything is up to date": "Her şey güncel",
-1
Переглянути файл
@@ -1438,7 +1438,6 @@
"Evaluate": "計算",
"Evaluate Expression…": "計算表示式…",
"Evaluate expression": "計算表示式",
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "計算表示式 (↩) 或新增監視 (⇧⌘↩)",
"Evaluate in the debug console": "在偵錯主控台中計算",
"Evaluation result": "計算結果",
"Everything is up to date": "一切都是最新的",
-1
Переглянути файл
@@ -1777,7 +1777,6 @@
"Evaluate": "计算",
"Evaluate Expression…": "计算表达式…",
"Evaluate expression": "计算表达式",
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "计算表达式 (↩) 或添加监视 (⇧⌘↩)",
"Evaluate in the debug console": "在调试控制台中计算",
"Evaluation result": "计算结果",
"Everything is up to date": "一切都是最新的",
+40 -24
Переглянути файл
@@ -1,13 +1,12 @@
.popup {
width: 340px;
width: 304px;
max-width: calc(100vw - 12px);
padding: 0 0 12px;
max-height: calc(100vh - 12px);
overflow: auto;
}
.opaque .control:global(.react-colorful) {
grid-template-rows: minmax(0, 1fr) 54px;
grid-template-rows: var(--saturation-height) 48px;
}
.opaque .control :global(.react-colorful__hue) {
@@ -23,25 +22,30 @@
}
.control:global(.react-colorful) {
--saturation-height: clamp(104px, 36vh, 152px);
display: grid;
grid-template-columns: 104px minmax(0, 1fr);
grid-template-rows: minmax(0, 1fr) 27px 27px;
grid-template-columns: 88px minmax(0, 1fr);
grid-template-rows: var(--saturation-height) 24px 24px;
align-items: center;
width: 100%;
height: 262px;
height: auto;
border-radius: 0;
}
.control :global(.react-colorful__saturation) {
grid-column: 1 / -1;
grid-row: 1;
align-self: stretch;
overflow: hidden;
border-radius: 0;
}
.control :global(.react-colorful__hue),
.control :global(.react-colorful__alpha) {
grid-column: 2;
height: 14px;
margin: 6px 14px 7px 2px;
height: 12px;
margin-inline-end: var(--space-3);
border-radius: var(--radius-small);
}
@@ -53,6 +57,12 @@
grid-row: 3;
}
.control :global(.react-colorful__hue-pointer),
.control :global(.react-colorful__alpha-pointer) {
width: var(--h-control-small);
height: var(--h-control-small);
}
.sampleRow {
position: absolute;
left: 0;
@@ -60,14 +70,14 @@
display: flex;
align-items: center;
gap: var(--space-2);
width: 104px;
height: 54px;
padding: 0 10px;
width: 88px;
height: 48px;
padding-inline: var(--space-2);
}
.preview {
width: 36px;
height: 36px;
width: 32px;
height: 32px;
border: 1px solid var(--border-strong);
border-radius: 50%;
overflow: hidden;
@@ -84,8 +94,8 @@
.fields {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(78px, 1.65fr);
gap: 7px;
padding: 0 12px;
gap: var(--space-1);
padding-inline: var(--space-3);
}
.field {
@@ -101,13 +111,14 @@
.field input {
width: 100%;
min-width: 0;
height: 28px;
height: var(--h-control);
border: 1px solid var(--border-input, var(--border));
border-radius: var(--radius-small);
padding: 0 3px;
background: var(--bg-input);
color: var(--fg-strong);
font: inherit;
font-family: inherit;
font-size: var(--fs-ui);
font-variant-numeric: tabular-nums;
text-align: center;
outline: none;
@@ -122,24 +133,29 @@
}
.actions {
position: sticky;
bottom: 0;
z-index: 1;
display: flex;
justify-content: flex-end;
gap: var(--space-2);
padding: var(--space-3) var(--space-3) 0;
padding: var(--space-2) var(--space-3) var(--space-3);
background: var(--bg-popup);
}
.recent {
display: grid;
grid-template-columns: repeat(10, minmax(0, 1fr));
gap: var(--space-2) 5px;
margin: 12px 12px 0;
padding-top: 10px;
grid-template-columns: repeat(auto-fill, minmax(24px, 1fr));
justify-items: center;
gap: var(--space-1);
margin: var(--space-2) var(--space-3) 0;
padding-top: var(--space-2);
border-top: 1px solid var(--border);
}
.recentColor {
width: 25px;
height: 25px;
width: 24px;
height: 24px;
border: 1px solid var(--border-strong);
border-radius: var(--radius-small);
padding: 0;