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

...
Автор SHA1 Повідомлення Дата
l0ng-ai f6cc95de29 fix(search): keep action names and shortcuts readable 2026-11-22 19:05:58 +08:00
l0ng-ai c209e189e0 docs(plugins): format the run-targets process tables (#5193)
Re-aligns the Running programs tables in docs/{en,zh}/plugins/guides/run-targets.mdx so pnpm format:check passes on main again. Whitespace only.
2026-11-22 17:44:20 +08:00
Muuтаmuutot 0b83b3ffbc style(ui): compact metrics for combo boxes and editor tabs (#5188)
Compact mode now also steps the combo box label padding (9/6 → 6/6, ComboBox.padding.compact) and radius (4px → 2px, ComboBox.arc.compact), and the editor tab pill's inline padding (8px → 6px, EditorTabs.tabInsets.compact), through new --combo-pad-start/end, --radius-combo and --tab-pad-x tokens. Toolbar and tool window stripe button radii stay at 6px → 4px (MainToolbar.Button.arc and Button.ToolWindow.arc 12 → 8).

Co-authored-by: muutot <[email protected]>
2026-11-22 16:55:22 +08:00
l0ng-ai 7caec95fee fix(java): stop reusing launch snapshots after Build › Rebuild (#5190)
Launch snapshots are reused while a module's sources keep their fingerprint. Build › Rebuild Project cleaned and recompiled target/classes but left the launch records untouched, so the next run kept loading a snapshot that could hold classes the clean removed (a class compiled under its old package), and Spring found two beans with the same name.

A Rebuild now clears the fingerprint of every launch record in the project, so the next launch copies the rebuilt outputs; the records stay, so those modules keep delegating to Maven.

Fixes #5179
2026-11-22 16:46:53 +08:00
11 змінених файлів з 214 додано та 28 видалено

No files matched your search

+7 -1
Переглянути файл
@@ -906,6 +906,7 @@ pub async fn build_run(
let detected = project.detected_roots.read().clone();
let config_dir = host.config_dir.clone();
let token = host.begin_project_request(window, request);
let launch_project = project.clone();
let result = tokio::task::spawn_blocking(move || {
// Fast path (#2476): an unchanged single-project Maven build skips
// Maven entirely. Previous diagnostics stay: nothing changed, so they
@@ -1003,7 +1004,12 @@ pub async fn build_run(
};
let result = compile::run(&root, &plan, &token, &|e| {
let _ = on_event.send(e);
})?;
});
if kind == BuildKind::Rebuild {
// The clean removed outputs that earlier launch snapshots still hold.
launch_project.java_launch_snapshots.lock().forget_reusable_snapshots();
}
let result = result?;
if result.success && single && kind == BuildKind::Build {
let model = with_profiles(load(&root, &cache, &settings), &cache);
compile::record_menu_build(&cache, &root, &model, file.as_deref(), &token);
+64
Переглянути файл
@@ -135,6 +135,16 @@ impl Session {
}
}
/// Build › Rebuild replaced the module outputs. The recorded snapshots were copied from
/// the outputs before the clean and may hold classes it removed (a class moved to another
/// package leaves its old file behind when jdtls wrote it), so none of them is reused:
/// the next launch copies the rebuilt outputs.
pub(crate) fn forget_reusable_snapshots(&mut self) {
if let Err(error) = forget_reusable_snapshots(&self.cache) {
tracing::warn!(%error, "Cannot invalidate Java launch snapshots");
}
}
pub(super) fn build(
&mut self,
root: &Path,
@@ -341,6 +351,32 @@ impl Drop for Session {
}
}
/// Clears the fingerprint of every launch record under `cache`, so no snapshot matches the
/// sources any more. The records stay: their modules keep delegating to Maven.
fn forget_reusable_snapshots(cache: &Path) -> std::io::Result<()> {
let records = cache.join("java-launch/records");
if !records.try_exists()? {
return Ok(());
}
let mut pending = vec![records];
while let Some(dir) = pending.pop() {
for entry in fs::read_dir(dir)? {
let entry = entry?;
let kind = entry.file_type()?;
if kind.is_dir() {
pending.push(entry.path());
} else if kind.is_file() && entry.path().extension().is_some_and(|ext| ext == "json") {
let outputs: Option<Outputs> = serde_json::from_slice(&fs::read(entry.path())?).unwrap_or(None);
if let Some(mut outputs) = outputs.filter(|o| o.fingerprint.is_some()) {
outputs.fingerprint = None;
write_record(&entry.path(), &outputs).map_err(|e| std::io::Error::other(e.message))?;
}
}
}
}
Ok(())
}
fn referenced_snapshots(cache: &Path) -> std::io::Result<HashSet<PathBuf>> {
let mut referenced = HashSet::new();
let records = cache.join("java-launch/records");
@@ -610,6 +646,34 @@ mod tests {
);
}
#[test]
fn a_menu_rebuild_stops_reusing_snapshots_that_hold_removed_classes() {
let dir = tempfile::tempdir().unwrap();
let root = dir.path();
let model = fixture(root);
let cancel = CancellationToken::new();
// A class jdtls wrote for a source since moved to another package; an incremental
// Maven build leaves it in target/classes.
fs::create_dir_all(root.join("target/classes")).unwrap();
fs::write(root.join("target/classes/Stale.class"), "stale").unwrap();
let mut session = Session::new(root.join("cache"));
let first = session.build(root, &model, root, BuildOptions::default(), None, &cancel).unwrap();
assert!(first.snapshot.join("0/Stale.class").is_file());
let reused = session.build(root, &model, root, BuildOptions::default(), None, &cancel).unwrap();
assert_eq!(reused.snapshot, first.snapshot);
// Build › Rebuild cleans the outputs and compiles again.
fs::remove_file(root.join("target/classes/Stale.class")).unwrap();
session.forget_reusable_snapshots();
assert!(has_record(root, &root.join("cache"), root));
let next = session.build(root, &model, root, BuildOptions::default(), None, &cancel).unwrap();
assert_ne!(next.snapshot, first.snapshot);
assert!(!next.snapshot.join("0/Stale.class").exists());
assert!(next.snapshot.join("0/Main.class").is_file());
let again = session.build(root, &model, root, BuildOptions::default(), None, &cancel).unwrap();
assert_eq!(again.snapshot, next.snapshot);
}
#[test]
fn jdt_errors_reuse_an_unchanged_snapshot_and_rebuild_only_on_a_cache_miss() {
let dir = tempfile::tempdir().unwrap();
+8 -8
Переглянути файл
@@ -297,14 +297,14 @@ launching as before.
## Running programs
| Function | What it does |
| ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------- |
| `Project::run_process(program, &args, stdin)` | Runs the pinned program in the project root and waits: `{ status, stdout, stderr }`, 4 MiB each. |
| `host::run_command(&Command, Some(&project), stdin)` | API 1.3: the same, with environment variables added by `Command::env`. |
| `host::run_captured(&Command, Some(&project), stdin, options)` | API 1.15: configurable output limit (up to 128 MiB per stream); errors explicitly if either stdout or stderr overflows. |
| `host::start(&Command, Some(&project))` | API 1.3: a `Child` left running: `poll`, `write`, `close_stdin`, `wait`, `kill`. At most 8. |
| `host::start_stream(&Command, Some(&project), options)` | API 1.15: lossless streaming with backpressure and bounded buffer, terminating with an explicit error on total overflow.|
| `host::open_terminal(title, program, &args)` | A Terminal tab running the program (see [Views](/en/plugins/guides/views)). |
| Function | What it does |
| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `Project::run_process(program, &args, stdin)` | Runs the pinned program in the project root and waits: `{ status, stdout, stderr }`, 4 MiB each. |
| `host::run_command(&Command, Some(&project), stdin)` | API 1.3: the same, with environment variables added by `Command::env`. |
| `host::run_captured(&Command, Some(&project), stdin, options)` | API 1.15: configurable output limit (up to 128 MiB per stream); errors explicitly if either stdout or stderr overflows. |
| `host::start(&Command, Some(&project))` | API 1.3: a `Child` left running: `poll`, `write`, `close_stdin`, `wait`, `kill`. At most 8. |
| `host::start_stream(&Command, Some(&project), options)` | API 1.15: lossless streaming with backpressure and bounded buffer, terminating with an explicit error on total overflow. |
| `host::open_terminal(title, program, &args)` | A Terminal tab running the program (see [Views](/en/plugins/guides/views)). |
```rust
use openidea_plugin::host::{self, Command};
+8 -8
Переглянути файл
@@ -254,14 +254,14 @@ register_plugin!(MyPlugin, run_target_validation);
## 运行程序
| 函数 | 作用 |
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- |
| `Project::run_process(program, &args, stdin)` | 在项目根目录运行已固定的程序并等待结束:`{ status, stdout, stderr }`,各 4 MiB。 |
| `host::run_command(&Command, Some(&project), stdin)` | API 1.3:同上,可用 `Command::env` 追加环境变量。 |
| `host::run_captured(&Command, Some(&project), stdin, options)` | API 1.15:可配置输出上限(每个流最高 128 MiB),stdout 或 stderr 溢出时明确报错。 |
| `host::start(&Command, Some(&project))` | API 1.3:保持运行的 `Child`:`poll`、`write`、`close_stdin`、`wait`、`kill`。最多 8 个。 |
| `host::start_stream(&Command, Some(&project), options)` | API 1.15:基于管道背压的有界无损流式传输,超出总预算时明确报错并终止进程。 |
| `host::open_terminal(title, program, &args)` | 运行该程序的终端标签页(见 [视图](/zh/plugins/guides/views))。 |
| 函数 | 作用 |
| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| `Project::run_process(program, &args, stdin)` | 在项目根目录运行已固定的程序并等待结束:`{ status, stdout, stderr }`,各 4 MiB。 |
| `host::run_command(&Command, Some(&project), stdin)` | API 1.3:同上,可用 `Command::env` 追加环境变量。 |
| `host::run_captured(&Command, Some(&project), stdin, options)` | API 1.15:可配置输出上限(每个流最高 128 MiB),stdout 或 stderr 溢出时明确报错。 |
| `host::start(&Command, Some(&project))` | API 1.3:保持运行的 `Child`:`poll`、`write`、`close_stdin`、`wait`、`kill`。最多 8 个。 |
| `host::start_stream(&Command, Some(&project), options)` | API 1.15:基于管道背压的有界无损流式传输,超出总预算时明确报错并终止进程。 |
| `host::open_terminal(title, program, &args)` | 运行该程序的终端标签页(见 [视图](/zh/plugins/guides/views))。 |
```rust
use openidea_plugin::host::{self, Command};
+54
Переглянути файл
@@ -1,6 +1,60 @@
import { doubleShift, expect, stubDesktop, test } from "./fixtures";
import type { Page } from "@playwright/test";
test("action names stay readable beside shortcuts and categories", async ({ workbench: page }) => {
const titles = ["Reconcile warehouse totals", "Reconcile settlement exports"];
const shortcuts = await page.evaluate(async (titles) => {
const actionsModule = "/src/platform/actions.ts";
const keymapModule = "/src/platform/keymap.ts";
const { registerActions, executeAction } = await import(/* @vite-ignore */ actionsModule);
const platformModule = "/src/platform/platformInfo.ts";
const { registerExtensionBindings, shortcutLabel } = await import(/* @vite-ignore */ keymapModule);
const { usePlatform } = await import(/* @vite-ignore */ platformModule);
usePlatform.setState({ os: "windows" });
const ids = ["review.reconcileWarehouse", "review.reconcileSettlement"];
const bindings = ["Ctrl+K Ctrl+R", "Ctrl+Alt+Shift+PageDown Ctrl+Alt+Shift+PageUp"];
registerActions(
titles.map((title, index) => ({
id: ids[index]!,
title,
category: "Warehouse reconciliation and settlement reports",
icon: "check",
run: () => document.body.setAttribute("data-review-action", title),
})),
);
ids.forEach((id, index) => registerExtensionBindings(id, [bindings[index]!]));
await executeAction("navigate.findAction");
return ids.map((id) => shortcutLabel(id) as string);
}, titles);
const dialog = page.locator('[role="dialog"]:has(#se-query)');
await dialog.getByRole("combobox", { name: "Search query" }).fill("Reconcile");
for (const width of [400, 1120]) {
await page.setViewportSize({ width, height: 630 });
for (const [index, title] of titles.entries()) {
const row = dialog.getByRole("option").filter({ hasText: title });
const keys = row.getByText(shortcuts[index]!, { exact: true });
await expect(keys).toBeAttached();
const geometry = await keys.evaluate((el) => {
const name = el.previousElementSibling!.getBoundingClientRect();
const main = el.parentElement!.getBoundingClientRect();
const key = el.getBoundingClientRect();
return { name: name.width, inside: key.left >= name.right && key.right <= main.right + 1 };
});
expect(geometry.name).toBeGreaterThanOrEqual(80);
expect(geometry.inside).toBe(true);
await expect(keys).toHaveCSS("font-size", "12px");
await expect(keys).toHaveCSS("font-weight", "600");
await expect(keys).toHaveAttribute("title", shortcuts[index]!);
if (index === 0) expect(await keys.evaluate((el) => el.scrollWidth <= el.clientWidth)).toBe(true);
}
}
await dialog.getByRole("option").filter({ hasText: titles[1]! }).click();
await expect(dialog).toBeHidden();
await expect(page.locator("body")).toHaveAttribute("data-review-action", titles[1]!);
});
async function searchFiles(page: Page) {
await stubDesktop(page);
await page.evaluate(() => {
+9
Переглянути файл
@@ -227,8 +227,14 @@
}
.shortcut {
flex: none;
max-width: 55%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: var(--fg-subtle);
font-family: var(--font-keys);
font-size: var(--fs-small);
font-weight: 600;
}
.right {
flex: none;
@@ -249,6 +255,9 @@
align-items: center;
gap: var(--space-1-5);
}
.actionRow > .right {
max-width: 30%;
}
.disabled .name,
.disabled .location,
.disabled .shortcut,
+11 -2
Переглянути файл
@@ -872,11 +872,16 @@ function ResultRow({
<span
className={clsx(styles.actionRow, !row.enabled && styles.disabled)}
aria-disabled={!row.enabled || undefined}
title={row.title}
>
<span className={styles.icon}>{row.icon ? <Icon name={row.icon} size={16} /> : null}</span>
<span className={styles.main}>
<HighlightedText className={styles.name} text={row.title} indices={row.indices} tone={tone} />
{shortcut && <span className={styles.shortcut}>{shortcut}</span>}
{shortcut && (
<kbd className={styles.shortcut} title={shortcut}>
{shortcut}
</kbd>
)}
</span>
{toggled !== undefined ? (
<span
@@ -896,7 +901,11 @@ function ResultRow({
/>
</span>
) : (
row.category && <span className={styles.right}>{row.category}</span>
row.category && (
<span className={styles.right} title={row.category}>
{row.category}
</span>
)
)}
</span>
);
+35 -5
Переглянути файл
@@ -1,10 +1,10 @@
/// <reference types="node" />
/**
* Compact mode must match JetBrains' Islands `Tree.border` insets: the normal
* left/right padding is 12px and compact is 8px (ManyIslandsDark.theme.json
* `Tree.border` "4,12,4,12" / `Tree.border.compact` "2,8,2,8"). In OpenIDEA
* that padding is split into the island gap plus the tree inset, so both must
* step 6→4 together.
* Compact mode must match JetBrains' Islands `*.compact` theme keys
* (ManyIslandsDark.theme.json). In OpenIDEA the metrics live in two tokens.css
* blocks: `:root` holds the normal value, `:root[data-compact]` the compact
* override, and components read them through `var(--…, fallback)`. Swing `arc`
* is a diameter, so the radii here are half of the theme's arc.
*/
import { describe, expect, it } from "vitest";
import { readFileSync } from "node:fs";
@@ -29,3 +29,33 @@ describe("compact tree insets match JetBrains Tree.border", () => {
expect(px(compact["--island-gap"]) + px(compact["--tree-inset"])).toBe(8);
});
});
describe("compact combo box matches JetBrains ComboBox keys", () => {
it("steps the radius 4px → 2px (Component.arc 8, ComboBox.arc.compact 4) and the label padding 9/6 → 6/6", () => {
expect(normal["--radius-combo"]).toBe("4px");
expect(compact["--radius-combo"]).toBe("2px");
expect(normal["--combo-pad-start"]).toBe("9px");
expect(normal["--combo-pad-end"]).toBe("6px");
expect(compact["--combo-pad-start"]).toBe("6px");
expect(compact["--combo-pad-end"]).toBe("6px");
});
});
describe("compact editor tabs match JetBrains EditorTabs.tabInsets", () => {
it("steps the tab pill's inline padding 8px → 6px", () => {
expect(normal["--tab-pad-x"]).toBe("8px");
expect(compact["--tab-pad-x"]).toBe("6px");
});
});
describe("compact radii match JetBrains arc keys", () => {
it("steps toolbar and stripe button radii 6px → 4px (MainToolbar.Button.arc, Button.ToolWindow.arc 12 → 8)", () => {
expect(normal["--radius-toolbar-button"]).toBe("6px");
expect(compact["--radius-toolbar-button"]).toBe("4px");
});
it("steps the control radius 4px → 3px (Component.arc 8 → 6)", () => {
expect(normal["--radius-control"]).toBe("4px");
expect(compact["--radius-control"]).toBe("3px");
});
});
+13
Переглянути файл
@@ -328,6 +328,12 @@ html {
--radius-row: 4px;
--radius-selection: 5px;
--radius-control: 4px;
/* Combo boxes follow Component.arc 8 (radius 4); ComboBox.padding 1,9,1,6 (left 9, right 6). */
--radius-combo: 4px;
--combo-pad-start: 9px;
--combo-pad-end: 6px;
/* EditorTabs.tabInsets -6,8,-6,8: the tab pill's inline padding (8px each side). */
--tab-pad-x: 8px;
--radius-tab: 6px;
--radius-toolbar-button: 6px;
/* main toolbar dropdowns (MainToolbar.Dropdown.arc 12): unchanged in compact mode */
@@ -1534,7 +1540,14 @@ html {
--island-radius: 8px;
/* Compact Tree.border is "2,8,2,8": island gap 4 + tree inset 4 = 8 horizontally. */
--tree-inset: 4px;
/* ComboBox.arc.compact "4,4,4,4" (radius 2) and padding.compact 1,6,1,6. */
--radius-combo: 2px;
--combo-pad-start: 6px;
--combo-pad-end: 6px;
/* EditorTabs.tabInsets.compact -2,6,-2,4: the pill's inline padding shrinks 8→6/4. */
--tab-pad-x: 6px;
--radius-control: 3px;
/* MainToolbar.Button.arc 12 → 8 and Button.ToolWindow.arc 12 → 8 (stripe buttons). */
--radius-toolbar-button: 4px;
}
/* Use contrast scrollbars. */
+2 -2
Переглянути файл
@@ -5,8 +5,8 @@
gap: var(--space-1-5);
height: var(--h-field, 28px);
min-width: 0;
padding: 0 6px 0 9px;
border-radius: var(--radius-control, 4px);
padding: 0 var(--combo-pad-end, 6px) 0 var(--combo-pad-start, 9px);
border-radius: var(--radius-combo, var(--radius-control, 4px));
color: var(--fg-strong);
transition:
background var(--dur-fast) var(--ease),
+3 -2
Переглянути файл
@@ -11,9 +11,10 @@
--tab-selected-bg: var(--bg-tab-selected-inactive);
--tab-selected-border: var(--border-tab-selected-inactive);
}
/* Islands tabs: the selected tab is a rounded pill (tab-selected-bg / -border); no underline, no separators. */
/* Islands tabs: the selected tab is a rounded pill (tab-selected-bg / -border); no underline, no separators.
EditorTabs.tabInsets -6,8,-6,8 (tabInsets.compact -2,6,-2,4) put 8px (6px compact) around the tab label. */
.editor {
--tab-inline-padding: var(--space-2);
--tab-inline-padding: var(--tab-pad-x, 8px);
height: var(--h-header);
font-size: var(--fs-chrome);
padding: 0 4px;