дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
Порівняти коміти
4
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
b321690741 | ||
|
|
c23696c51f | ||
|
|
3e6e9ed255 | ||
|
|
cbc6b24c5f |
No files matched your search
Створено
@@ -4796,6 +4796,7 @@ dependencies = [
|
||||
"tempfile",
|
||||
"toml 0.9.12+spec-1.1.0",
|
||||
"tracing",
|
||||
"url",
|
||||
"zip",
|
||||
]
|
||||
|
||||
|
||||
@@ -492,7 +492,7 @@ for line in sys.stdin:
|
||||
}
|
||||
let concurrent = async {
|
||||
if outcome == "session_report" {
|
||||
tokio::time::timeout(Duration::from_secs(2), async {
|
||||
tokio::time::timeout(Duration::from_secs(10), async {
|
||||
while !root.join("initialized").exists() {
|
||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||
}
|
||||
@@ -564,7 +564,7 @@ for line in sys.stdin:
|
||||
};
|
||||
assert_eq!(subtypes, expected, "{outcome}");
|
||||
let pid = std::fs::read_to_string(root.join("pid")).unwrap();
|
||||
tokio::time::timeout(Duration::from_secs(2), async {
|
||||
tokio::time::timeout(Duration::from_secs(10), async {
|
||||
while std::process::Command::new("kill").args(["-0", pid.trim()]).output().unwrap().status.success() {
|
||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||
}
|
||||
|
||||
@@ -1314,15 +1314,22 @@ mod tests {
|
||||
std::fs::write(&file, format!("{}=warning\n{}=ignore\nother=error\n", ACCESS_OPTIONS[0], ACCESS_OPTIONS[1]))
|
||||
.unwrap();
|
||||
let mut cfg: ide_language::LanguageServerConfig = toml::from_str("name = 'jdtls'\ncommand = 'jdtls'").unwrap();
|
||||
cfg.initialization_options = Some(
|
||||
toml::Value::try_from(json!({"settings": {"java": {"settings": {"url": file.to_string_lossy()}}}}))
|
||||
.unwrap(),
|
||||
);
|
||||
let with_url = |cfg: &mut ide_language::LanguageServerConfig, url: String| {
|
||||
cfg.initialization_options =
|
||||
Some(toml::Value::try_from(json!({"settings": {"java": {"settings": {"url": url}}}})).unwrap());
|
||||
};
|
||||
with_url(&mut cfg, crate::uri::path_to_uri_string(&file));
|
||||
assert_eq!(compiler_defaults(&cfg), json!({}));
|
||||
for prefix in ["", "--jvm-arg="] {
|
||||
cfg.args = vec![format!("{prefix}-Djava.import.generatesMetadataFilesAtProjectRoot=false")];
|
||||
assert_eq!(compiler_defaults(&cfg), json!({ACCESS_OPTIONS[0]: "warning", ACCESS_OPTIONS[1]: "ignore"}));
|
||||
}
|
||||
with_url(&mut cfg, file.to_string_lossy().into_owned());
|
||||
assert_eq!(
|
||||
compiler_defaults(&cfg),
|
||||
json!({ACCESS_OPTIONS[0]: "warning", ACCESS_OPTIONS[1]: "ignore"}),
|
||||
"a path"
|
||||
);
|
||||
cfg.args.push("--jvm-arg=-Djava.import.generatesMetadataFilesAtProjectRoot=true".into());
|
||||
assert_eq!(compiler_defaults(&cfg), json!({}), "the final JVM property wins");
|
||||
cfg.args.pop();
|
||||
|
||||
@@ -19,4 +19,5 @@ specta.workspace = true
|
||||
tempfile.workspace = true
|
||||
toml.workspace = true
|
||||
tracing.workspace = true
|
||||
url = "2"
|
||||
zip.workspace = true
|
||||
@@ -876,9 +876,10 @@ org.eclipse.jdt.core.compiler.codegen.targetPlatform={jdt_ver}\n"
|
||||
tracing::warn!("jdtls: cannot write compiler defaults: {e}");
|
||||
return;
|
||||
}
|
||||
// jdtls accepts absolute filesystem paths as well as URLs (including paths
|
||||
// containing spaces and Windows backslashes). Explicit server settings win later.
|
||||
let defaults = json!({"settings": {"java": {"settings": {"url": file.to_string_lossy()}}}});
|
||||
// A `file:` URI: jdtls parses the setting as a URI when matching watched-file
|
||||
// changes, which fails on a bare path with spaces. Explicit server settings win later.
|
||||
let url = url::Url::from_file_path(&file).map_or_else(|()| file.to_string_lossy().into_owned(), String::from);
|
||||
let defaults = json!({"settings": {"java": {"settings": {"url": url}}}});
|
||||
let existing = cfg.initialization_options.clone();
|
||||
merge_init_options(cfg, defaults);
|
||||
if let Some(existing) = existing {
|
||||
@@ -1824,13 +1825,18 @@ mod java_compiler_tests {
|
||||
serde_json::to_value(cfg.initialization_options.as_ref().unwrap()).unwrap()
|
||||
}
|
||||
|
||||
fn prefs_path(options: &Value) -> PathBuf {
|
||||
let url = options.pointer("/settings/java/settings/url").unwrap().as_str().unwrap();
|
||||
url::Url::parse(url).unwrap().to_file_path().unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serial_version_inspection_sets_the_compiler_option() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let url = |inspections: &InspectionSettings| {
|
||||
let mut cfg = custom_server("jdtls", &LanguageServerSettings::default());
|
||||
configure_java_compiler(&mut cfg, tmp.path(), inspections);
|
||||
options(&cfg).pointer("/settings/java/settings/url").unwrap().as_str().unwrap().to_owned()
|
||||
prefs_path(&options(&cfg))
|
||||
};
|
||||
let set = |o: ide_core::settings::InspectionOverride| {
|
||||
let mut s = InspectionSettings::default();
|
||||
@@ -1869,7 +1875,9 @@ mod java_compiler_tests {
|
||||
merge_init_options(&mut cfg, json!({"settings": {"java": {"format": {"tabSize": 4}}}}));
|
||||
configure_java_compiler(&mut cfg, &cache, &InspectionSettings::default());
|
||||
let options = options(&cfg);
|
||||
let path = PathBuf::from(options.pointer("/settings/java/settings/url").unwrap().as_str().unwrap());
|
||||
let url = options.pointer("/settings/java/settings/url").unwrap().as_str().unwrap();
|
||||
assert!(url.starts_with("file://") && !url.contains(' '), "{url}");
|
||||
let path = prefs_path(&options);
|
||||
assert!(path.starts_with(&cache));
|
||||
let prefs = std::fs::read_to_string(&path).unwrap();
|
||||
assert_eq!(prefs.lines().count(), 2);
|
||||
|
||||
@@ -16,6 +16,8 @@ export const test = base.extend<{ workbench: Page }>({
|
||||
await page.goto("/");
|
||||
await expect(page.getByRole("tree", { name: "Project" })).toBeVisible();
|
||||
await expect(page.getByRole("treeitem", { name: /acme-api/ })).toBeVisible();
|
||||
// The start-up splash swallows raw mouse presses until it has faded out.
|
||||
await expect(page.locator("#splash")).toHaveCount(0);
|
||||
await provide(page);
|
||||
expect(errors, "uncaught page errors").toEqual([]);
|
||||
},
|
||||
|
||||
@@ -78,8 +78,6 @@ const settle = (page: Page) =>
|
||||
page.evaluate(() => new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(done))));
|
||||
|
||||
async function fileRow(page: Page) {
|
||||
// The start-up splash swallows raw mouse presses until it has faded out.
|
||||
await expect(page.locator("#splash")).toHaveCount(0);
|
||||
const file = page.getByRole("tree", { name: "Project" }).getByRole("treeitem", { name: "settings.gradle.kts" });
|
||||
await file.scrollIntoViewIfNeeded();
|
||||
const content = file.locator("[data-project-path]");
|
||||
|
||||
@@ -484,6 +484,41 @@ describe("mermaid in the markdown preview", () => {
|
||||
expect(document.activeElement).toBe(button);
|
||||
});
|
||||
|
||||
it("redraws the full-screen view when the diagram is redrawn behind it", async () => {
|
||||
const html = document.documentElement;
|
||||
const previous = html.dataset.colorTheme;
|
||||
try {
|
||||
html.dataset.colorTheme = "one-dark";
|
||||
const root = preview(SEQ);
|
||||
await renderMermaidIn(root).done;
|
||||
root.querySelector<HTMLButtonElement>('[data-mermaid-tools] button[aria-label="Full screen"]')!.click();
|
||||
const overlay = document.querySelector<HTMLElement>("[data-mermaid-preview]")!;
|
||||
const pan = overlay.querySelector<HTMLElement>(".pan-zoom-content")!;
|
||||
const before = overlay.querySelector("svg")!;
|
||||
pan.parentElement!.dispatchEvent(
|
||||
new WheelEvent("wheel", { deltaY: -120, ctrlKey: true, bubbles: true, cancelable: true }),
|
||||
);
|
||||
const zoomed = pan.style.transform;
|
||||
|
||||
html.dataset.colorTheme = "solarized-dark";
|
||||
m.render.mockImplementationOnce(async (id: string) => ({ svg: `<svg id="${id}"><text>redrawn</text></svg>` }));
|
||||
await renderMermaidIn(root).done;
|
||||
const after = overlay.querySelector("svg")!;
|
||||
expect(after).not.toBe(before);
|
||||
expect(after.textContent).toBe("redrawn");
|
||||
expect(after.parentElement).toBe(pan);
|
||||
expect(pan.style.transform).toBe(zoomed);
|
||||
|
||||
document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));
|
||||
html.dataset.colorTheme = "one-dark";
|
||||
await renderMermaidIn(root).done;
|
||||
expect(document.querySelector("[data-mermaid-preview]")).toBeNull();
|
||||
} finally {
|
||||
if (previous === undefined) delete html.dataset.colorTheme;
|
||||
else html.dataset.colorTheme = previous;
|
||||
}
|
||||
});
|
||||
|
||||
it("saves a diagram as a PNG through the file dialog", async () => {
|
||||
const context = { fillStyle: "", scale: vi.fn(), fillRect: vi.fn(), drawImage: vi.fn() };
|
||||
const getContext = vi
|
||||
|
||||
@@ -27,10 +27,12 @@ export function attachDiagramTools(block: HTMLElement, svg: SVGSVGElement): void
|
||||
tools.className = styles.tools!;
|
||||
tools.setAttribute(TOOLS_ATTR, "");
|
||||
tools.append(
|
||||
toolButton("fullscreen", tx("Full screen"), (button) => openDiagramPreview(svg, button)),
|
||||
toolButton("fullscreen", tx("Full screen"), (button) => openDiagramPreview(block, svg, button)),
|
||||
toolButton("download", tx("Download image"), () => void saveDiagram(svg)),
|
||||
);
|
||||
block.append(tools);
|
||||
// Redrawn (a theme change, an edit) while shown full screen: the preview follows.
|
||||
if (preview?.block === block) preview.redraw(svg);
|
||||
}
|
||||
|
||||
function toolButton(icon: ToolIcon, label: string, onClick: (button: HTMLButtonElement) => void): HTMLButtonElement {
|
||||
@@ -49,13 +51,15 @@ function toolButton(icon: ToolIcon, label: string, onClick: (button: HTMLButtonE
|
||||
}
|
||||
|
||||
let closeActive: (() => void) | null = null;
|
||||
/** The block shown full screen, and how to show its newest drawing. */
|
||||
let preview: { block: HTMLElement; redraw: (svg: SVGSVGElement) => void } | null = null;
|
||||
|
||||
/**
|
||||
* The diagram over the whole window, fitted and centered: drag pans it anywhere,
|
||||
* ⌘/Ctrl+wheel zooms, double-click resets. Escape (or a click outside, or Close)
|
||||
* returns to the page, with focus back on the button that opened it.
|
||||
*/
|
||||
function openDiagramPreview(svg: SVGSVGElement, returnTo?: HTMLElement): void {
|
||||
function openDiagramPreview(block: HTMLElement, svg: SVGSVGElement, returnTo?: HTMLElement): void {
|
||||
closeActive?.();
|
||||
const returnFocus = returnTo ?? (document.activeElement instanceof HTMLElement ? document.activeElement : null);
|
||||
const overlay = document.createElement("div");
|
||||
@@ -71,6 +75,7 @@ function openDiagramPreview(svg: SVGSVGElement, returnTo?: HTMLElement): void {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
if (closeActive === close) closeActive = null;
|
||||
if (preview?.redraw === redraw) preview = null;
|
||||
document.removeEventListener("keydown", onKey, true);
|
||||
layer.release();
|
||||
overlay.remove();
|
||||
@@ -93,7 +98,7 @@ function openDiagramPreview(svg: SVGSVGElement, returnTo?: HTMLElement): void {
|
||||
|
||||
const tools = document.createElement("div");
|
||||
tools.className = styles.previewTools!;
|
||||
const download = toolButton("download", tx("Download image"), () => void saveDiagram(svg));
|
||||
const download = toolButton("download", tx("Download image"), () => void saveDiagram(current));
|
||||
tools.append(download, toolButton("close", tx("Close"), close));
|
||||
overlay.append(tools);
|
||||
|
||||
@@ -106,7 +111,10 @@ function openDiagramPreview(svg: SVGSVGElement, returnTo?: HTMLElement): void {
|
||||
// The canvas fills the window: the fitted drawing is centred in it, and the
|
||||
// whole window stays a drag surface once zoomed in. Top rows stay free of it
|
||||
// so the Close and Download buttons never cover the drawing.
|
||||
const fitted = fittedCopy(svg, canvas.clientWidth, Math.max(1, canvas.clientHeight - 32));
|
||||
const fit = (next: SVGSVGElement) => fittedCopy(next, canvas.clientWidth, Math.max(1, canvas.clientHeight - 32));
|
||||
let current = svg;
|
||||
let shown = fit(svg);
|
||||
const fitted = shown;
|
||||
canvas.append(fitted);
|
||||
const width = Number(fitted.getAttribute("width"));
|
||||
const height = Number(fitted.getAttribute("height"));
|
||||
@@ -118,6 +126,14 @@ function openDiagramPreview(svg: SVGSVGElement, returnTo?: HTMLElement): void {
|
||||
y: (canvas.clientHeight - height) / 2,
|
||||
},
|
||||
});
|
||||
// In place, inside the pan/zoom layer, so the current pan and zoom stay.
|
||||
const redraw = (next: SVGSVGElement) => {
|
||||
current = next;
|
||||
const copy = fit(next);
|
||||
shown.replaceWith(copy);
|
||||
shown = copy;
|
||||
};
|
||||
preview = { block, redraw };
|
||||
closeActive = close;
|
||||
download.focus({ preventScroll: true });
|
||||
}
|
||||
|
||||
Reference in new issue
Заблокувати користувача