дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 01:57:13 +02:00
Порівняти коміти
6
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
853c802a63 | ||
|
|
d47e9688cb | ||
|
|
94e318e740 | ||
|
|
6303cd5aef | ||
|
|
748f567abc | ||
|
|
9fe1dd8d7b |
No files matched your search
@@ -92,6 +92,12 @@ pub enum IdeEvent {
|
||||
/// Text version when this transition occurred, including when it was saved.
|
||||
version: u32,
|
||||
},
|
||||
/// An open document's file changed on disk while the buffer had unsaved changes. The buffer
|
||||
/// keeps them (autosave leaves the file alone); the UI offers to load the disk version.
|
||||
DocDiskConflict {
|
||||
doc: DocId,
|
||||
path: String,
|
||||
},
|
||||
/// A complete workspace edit can be undone as one operation.
|
||||
WorkspaceEditApplied {
|
||||
id: u32,
|
||||
|
||||
@@ -70,6 +70,13 @@ pub async fn doc_save(host: &Host, window: &str, doc: DocId) -> IdeResult<()> {
|
||||
host.debugger.refresh_source_mirrors(host.owner_window(window)).await
|
||||
}
|
||||
|
||||
/// Load Changes from Disk: discards the buffer's unsaved changes and reads its file again.
|
||||
#[command(trust = always)]
|
||||
pub async fn doc_reload_from_disk(host: &Host, window: &str, doc: DocId) -> IdeResult<()> {
|
||||
let project = host.project(window)?;
|
||||
host.blocking(move || project.documents.discard_and_reload(doc)).await
|
||||
}
|
||||
|
||||
/// An automatic save: `false` (nothing written) when the file changed on disk after the
|
||||
/// buffer was edited, which only an explicit save overwrites.
|
||||
#[command(trust = always)]
|
||||
@@ -120,6 +127,7 @@ ide_command::domain!(
|
||||
doc_edit,
|
||||
doc_open,
|
||||
doc_open_untitled,
|
||||
doc_reload_from_disk,
|
||||
doc_save,
|
||||
doc_autosave,
|
||||
doc_save_all,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::*;
|
||||
use crate::{HostConfig, Project};
|
||||
use ide_core::{IdeEvent, TextChange, event::NotifyLevel};
|
||||
use ide_core::{IdeEvent, TextChange};
|
||||
use parking_lot::Mutex;
|
||||
use std::{path::Path, sync::Arc};
|
||||
|
||||
@@ -57,7 +57,9 @@ impl Fixture {
|
||||
self.events
|
||||
.lock()
|
||||
.iter()
|
||||
.filter(|e| matches!(e, IdeEvent::DocPatched { .. } | IdeEvent::DocDirty { .. } | IdeEvent::Notify { .. }))
|
||||
.filter(|e| {
|
||||
matches!(e, IdeEvent::DocPatched { .. } | IdeEvent::DocDirty { .. } | IdeEvent::DocDiskConflict { .. })
|
||||
})
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
@@ -110,7 +112,7 @@ async fn dirty_document_keeps_edits_and_warns_once() {
|
||||
let loaded = f.project.documents.snapshot(original.id).unwrap();
|
||||
assert_eq!(loaded.text, "local original\n");
|
||||
assert!(loaded.dirty);
|
||||
assert!(matches!(f.document_events().as_slice(), [IdeEvent::Notify { level: NotifyLevel::Warning, .. }]));
|
||||
assert!(matches!(f.document_events().as_slice(), [IdeEvent::DocDiskConflict { .. }]));
|
||||
f.events.lock().clear();
|
||||
f.sync().await;
|
||||
assert!(f.document_events().is_empty());
|
||||
|
||||
@@ -191,6 +191,7 @@ pub fn client_accepts(event: &IdeEvent, trusted: bool) -> bool {
|
||||
| IdeEvent::ExcludedDirsChanged { .. }
|
||||
| IdeEvent::DocPatched { .. }
|
||||
| IdeEvent::DocDirty { .. }
|
||||
| IdeEvent::DocDiskConflict { .. }
|
||||
| IdeEvent::WorkspaceEditApplied { .. }
|
||||
| IdeEvent::DocLanguage { .. }
|
||||
| IdeEvent::Diagnostics { .. }
|
||||
|
||||
@@ -631,9 +631,11 @@ fn spring_boot_apps(root: &Path, build: &Path, out: &mut Vec<RunConfig>) {
|
||||
}
|
||||
}
|
||||
|
||||
/// The module has main sources, and its build applies the Spring Boot plugin: its own build
|
||||
/// file, or a build above it in `build` that applies it to its modules (a parent POM's
|
||||
/// `<build><plugins>`, Gradle's `subprojects` / `allprojects`).
|
||||
/// The module has main sources and Spring Boot on its classpath, as far as its build files
|
||||
/// tell: its own build, or a build above it in `build` that hands Spring Boot to its modules,
|
||||
/// references it (a dependency, the starter parent, the BOM or the plugin). A Maven module that
|
||||
/// depends on Spring Boot through a parent or another module is a Spring Boot application even
|
||||
/// without the packaging plugin; only `<pluginManagement>` alone doesn't count.
|
||||
fn applies_spring_boot(build: &Path, module: &Path) -> bool {
|
||||
if !["java", "kotlin"].iter().any(|l| module.join("src/main").join(l).is_dir()) {
|
||||
return false;
|
||||
@@ -642,15 +644,19 @@ fn applies_spring_boot(build: &Path, module: &Path) -> bool {
|
||||
if pom.contains("<packaging>pom</packaging>") {
|
||||
return false;
|
||||
}
|
||||
if pom.contains("spring-boot-maven-plugin") {
|
||||
if references_spring_boot(&without_plugin_management(&pom)) {
|
||||
return true;
|
||||
}
|
||||
} else if GRADLE_BUILDS.iter().filter_map(|n| read(&module.join(n))).any(|text| applies_boot_gradle_plugin(&text)) {
|
||||
} else if GRADLE_BUILDS
|
||||
.iter()
|
||||
.filter_map(|n| read(&module.join(n)))
|
||||
.any(|text| applies_boot_gradle_plugin(&text) || text.contains("org.springframework.boot:"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
module.ancestors().skip(1).take_while(|dir| dir.starts_with(build)).any(|dir| {
|
||||
if let Some(pom) = read(&dir.join("pom.xml")) {
|
||||
return without_plugin_management(&pom).contains("spring-boot-maven-plugin");
|
||||
return references_spring_boot(&without_plugin_management(&pom));
|
||||
}
|
||||
GRADLE_BUILDS.iter().filter_map(|n| read(&dir.join(n))).any(|text| {
|
||||
(text.contains("subprojects") || text.contains("allprojects")) && applies_boot_gradle_plugin(&text)
|
||||
@@ -658,6 +664,14 @@ fn applies_spring_boot(build: &Path, module: &Path) -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
/// A POM (without its `<pluginManagement>`) referencing Spring Boot: a dependency or the parent
|
||||
/// (`org.springframework.boot`), a starter, the BOM import or the plugin.
|
||||
fn references_spring_boot(pom: &str) -> bool {
|
||||
["org.springframework.boot", "spring-boot-starter", "spring-boot-dependencies", "spring-boot-maven-plugin"]
|
||||
.iter()
|
||||
.any(|m| pom.contains(m))
|
||||
}
|
||||
|
||||
/// A Gradle build applying the plugin (`id("org.springframework.boot")`, `apply plugin: '…'`),
|
||||
/// not only depending on Spring Boot (`org.springframework.boot:…`).
|
||||
fn applies_boot_gradle_plugin(text: &str) -> bool {
|
||||
|
||||
@@ -380,27 +380,59 @@ fn a_root_build_disables_the_nested_scan() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spring_boot_applications_need_the_plugin_and_a_main() {
|
||||
fn spring_boot_applications_need_spring_boot_and_a_main() {
|
||||
let main =
|
||||
"package demo;\n@SpringBootApplication\npublic class App {\n public static void main(String[] args) {}\n}\n";
|
||||
// A library using Spring Boot without the plugin, a configuration class without `main`,
|
||||
// the annotation in a comment, a parent POM.
|
||||
// A module without Spring Boot in its build, a configuration class without `main`, the
|
||||
// annotation in a comment, a parent POM.
|
||||
let dir = project(&[
|
||||
("lib/pom.xml", "<project><dependencies>spring-boot-starter</dependencies></project>"),
|
||||
("lib/src/main/java/demo/App.java", main),
|
||||
("plain/pom.xml", "<project><dependencies>commons-lang3</dependencies></project>"),
|
||||
("plain/src/main/java/demo/App.java", main),
|
||||
("svc/pom.xml", BOOT_POM),
|
||||
("svc/src/main/java/demo/Config.java", "package demo;\n@SpringBootApplication\npublic class Config {}\n"),
|
||||
(
|
||||
"svc/src/main/java/demo/Old.java",
|
||||
"package demo;\n// @SpringBootApplication\nclass Old { public static void main(String[] a) {} }\n",
|
||||
),
|
||||
("gr/build.gradle", "dependencies { implementation 'org.springframework.boot:spring-boot-starter' }\n"),
|
||||
("gr/build.gradle", "dependencies { implementation 'com.google.guava:guava:33.0.0-jre' }\n"),
|
||||
("gr/src/main/java/demo/App.java", main),
|
||||
]);
|
||||
let c = detect(dir.path());
|
||||
assert!(!c.iter().any(|c| c.kind == "spring-boot"), "{:?}", ids(&c));
|
||||
}
|
||||
|
||||
/// Spring Boot on the classpath is enough, as for IntelliJ IDEA: a module depending on a
|
||||
/// starter (directly or through its parent POM) without the packaging plugin, and Gradle's
|
||||
/// dependency on `org.springframework.boot:…`.
|
||||
#[test]
|
||||
fn spring_boot_applications_without_the_plugin() {
|
||||
let main =
|
||||
"package demo;\n@SpringBootApplication\npublic class App {\n public static void main(String[] args) {}\n}\n";
|
||||
let dir = project(&[
|
||||
(
|
||||
"lib/pom.xml",
|
||||
"<project><dependencies><dependency><groupId>org.springframework.boot</groupId>\
|
||||
<artifactId>spring-boot-starter-web</artifactId></dependency></dependencies></project>",
|
||||
),
|
||||
("lib/src/main/java/demo/App.java", main),
|
||||
("gr/build.gradle", "dependencies { implementation 'org.springframework.boot:spring-boot-starter' }\n"),
|
||||
("gr/src/main/java/demo/App.java", main),
|
||||
]);
|
||||
let c = detect(dir.path());
|
||||
assert_eq!(find(&c, "application:lib:demo.App").kind, "spring-boot");
|
||||
assert_eq!(find(&c, "application:gr:demo.App").kind, "spring-boot");
|
||||
|
||||
let parent = "<project><packaging>pom</packaging><modules><module>job</module></modules>\
|
||||
<parent><groupId>org.springframework.boot</groupId>\
|
||||
<artifactId>spring-boot-starter-parent</artifactId></parent></project>";
|
||||
let dir = project(&[
|
||||
("pom.xml", parent),
|
||||
("job/pom.xml", "<project><artifactId>job</artifactId></project>"),
|
||||
("job/src/main/java/demo/App.java", main),
|
||||
]);
|
||||
assert_eq!(find(&detect(dir.path()), "application:job:demo.App").kind, "spring-boot");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spring_boot_modules_inherit_the_plugin_from_their_parent_build() {
|
||||
let main = |pkg: &str, ann: &str, cls: &str| {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use crate::editorconfig::{EditorConfig, EditorConfigProps};
|
||||
use crate::file_defaults::FileDefaults;
|
||||
use ide_core::error::ErrorKind;
|
||||
use ide_core::event::NotifyLevel;
|
||||
use ide_core::{ChangeSet, DocId, IdeError, IdeEvent, IdeResult, LanguageId, SharedSink, TextEdit};
|
||||
use ide_text::{AppliedChange, ByteEdit, Document, LineEnding};
|
||||
use parking_lot::{Mutex, ReentrantMutex, RwLock};
|
||||
@@ -1138,6 +1137,24 @@ impl Documents {
|
||||
})
|
||||
}
|
||||
|
||||
/// Load Changes from Disk: drops the buffer's unsaved changes and reads its file again in
|
||||
/// the buffer's encoding, after the file changed on disk (`IdeEvent::DocDiskConflict`).
|
||||
pub fn discard_and_reload(&self, doc: DocId) -> IdeResult<()> {
|
||||
self.with_doc(doc, |st| {
|
||||
if st.uri.is_some() || st.binary {
|
||||
return Err(IdeError::invalid("only a file's text can be reloaded from disk"));
|
||||
}
|
||||
let loaded = Self::load_as(&st.path, &st.encoding, st.native_to_ascii)?;
|
||||
st.has_bom = loaded.has_bom;
|
||||
st.disk_mtime = loaded.mtime_ms;
|
||||
st.disk_len = disk_len(&st.path);
|
||||
st.disk_conflict = false;
|
||||
self.replace_locked(doc, st, &loaded.text)?;
|
||||
self.set_dirty(doc, st, false);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
/// The URI of a virtual document, or `None` for a file-backed one.
|
||||
pub fn virtual_uri(&self, doc: DocId) -> IdeResult<Option<String>> {
|
||||
self.with_doc(doc, |st| Ok(st.uri.clone()))
|
||||
@@ -1250,7 +1267,7 @@ impl Documents {
|
||||
}
|
||||
|
||||
/// Re-reads from disk after an external change. Clean documents reload
|
||||
/// silently; dirty ones are left alone and reported via `IdeEvent::Notify`.
|
||||
/// silently; dirty ones are left alone and reported via `IdeEvent::DocDiskConflict`.
|
||||
/// Changes matching our own last save are ignored.
|
||||
pub fn on_disk_changed(&self, paths: &[PathBuf]) {
|
||||
self.reload_from_disk(paths, false, false);
|
||||
@@ -1289,16 +1306,7 @@ impl Documents {
|
||||
st.disk_mtime = mtime;
|
||||
st.disk_len = meta.len();
|
||||
st.disk_conflict = true;
|
||||
let name = st.path.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default();
|
||||
self.sink.emit(IdeEvent::Notify {
|
||||
level: NotifyLevel::Warning,
|
||||
title: format!("{name} changed on disk"),
|
||||
body: Some(format!(
|
||||
"{} was modified externally but has unsaved changes in the editor. \
|
||||
Saving explicitly will overwrite the external changes; autosave leaves the file alone.",
|
||||
st.path.display()
|
||||
)),
|
||||
});
|
||||
self.sink.emit(IdeEvent::DocDiskConflict { doc: id, path: st.path.to_string_lossy().into_owned() });
|
||||
return Ok(());
|
||||
}
|
||||
let loaded = if force_clean {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use ide_core::error::ErrorKind;
|
||||
use ide_core::event::NotifyLevel;
|
||||
use ide_core::{ChangeSet, DocId, IdeEvent, LanguageId, Pos, Range, SharedSink, TextChange, TextEdit};
|
||||
use ide_text::{AppliedChange, LineEnding};
|
||||
use ide_workspace::documents::DocumentObserver;
|
||||
@@ -565,15 +564,31 @@ fn external_changes() {
|
||||
fs::write(&path, "something else\n").unwrap();
|
||||
f.docs.on_disk_changed(std::slice::from_ref(&path));
|
||||
assert_eq!(f.docs.snapshot(id).unwrap().text, "// alpha\nBETA\ngamma\n");
|
||||
let warnings =
|
||||
f.events.lock().iter().filter(|e| matches!(e, IdeEvent::Notify { level: NotifyLevel::Warning, .. })).count();
|
||||
let warnings = f
|
||||
.events
|
||||
.lock()
|
||||
.iter()
|
||||
.filter(|e| matches!(e, IdeEvent::DocDiskConflict { path: p, .. } if *p == path.to_string_lossy()))
|
||||
.count();
|
||||
assert_eq!(warnings, 1);
|
||||
// The same disk state is reported only once.
|
||||
f.docs.on_disk_changed(std::slice::from_ref(&path));
|
||||
let warnings =
|
||||
f.events.lock().iter().filter(|e| matches!(e, IdeEvent::Notify { level: NotifyLevel::Warning, .. })).count();
|
||||
let warnings = f
|
||||
.events
|
||||
.lock()
|
||||
.iter()
|
||||
.filter(|e| matches!(e, IdeEvent::DocDiskConflict { path: p, .. } if *p == path.to_string_lossy()))
|
||||
.count();
|
||||
assert_eq!(warnings, 1);
|
||||
|
||||
// Load Changes from Disk drops the buffer's changes; autosave writes again afterwards.
|
||||
f.docs.discard_and_reload(id).unwrap();
|
||||
let reloaded = f.docs.snapshot(id).unwrap();
|
||||
assert_eq!((reloaded.text.as_str(), reloaded.dirty), ("something else\n", false));
|
||||
f.docs.edit(id, reloaded.version, change(0, 0, "# ")).unwrap();
|
||||
assert!(f.docs.autosave(id).unwrap());
|
||||
assert_eq!(fs::read_to_string(&path).unwrap(), "# something else\n");
|
||||
|
||||
// Unknown paths are ignored.
|
||||
f.docs.on_disk_changed(&[f.root.join("other.txt")]);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,39 @@ test("⌘F opens the find bar and highlights matches; Escape returns to the edit
|
||||
await expect(editor.locator(".cm-content")).toBeFocused();
|
||||
});
|
||||
|
||||
test("Go to Line keeps its label beside the selected coordinates and returns focus to the editor", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
const editor = await openFromTree(page, "build.gradle.kts");
|
||||
const content = editor.locator(".cm-content");
|
||||
await content.focus();
|
||||
await page.keyboard.press("Meta+l");
|
||||
const dialog = page.getByRole("dialog", { name: "Go to Line:Column", exact: true });
|
||||
const coordinates = dialog.getByRole("textbox", { name: "Line and column", exact: true });
|
||||
await expect(coordinates).toBeFocused();
|
||||
await expect(coordinates).toHaveValue("1:1");
|
||||
expect(await coordinates.evaluate((el: HTMLInputElement) => [el.selectionStart, el.selectionEnd])).toEqual([0, 3]);
|
||||
|
||||
await page.setViewportSize({ width: 360, height: 500 });
|
||||
const label = dialog.getByText("Line and column", { exact: true });
|
||||
await expect(label).toBeVisible();
|
||||
const text = (await label.boundingBox())!;
|
||||
const field = (await coordinates.boundingBox())!;
|
||||
expect(text.x + text.width).toBeLessThan(field.x);
|
||||
expect(Math.abs(text.y + text.height / 2 - field.y - field.height / 2)).toBeLessThan(2);
|
||||
await expect(coordinates).toHaveCSS("font-size", await label.evaluate((el) => getComputedStyle(el).fontSize));
|
||||
|
||||
await coordinates.fill("0:2");
|
||||
await expect(coordinates).toHaveAttribute("aria-invalid", "true");
|
||||
await expect(dialog.getByRole("button", { name: "OK", exact: true })).toBeDisabled();
|
||||
await coordinates.fill("6:8");
|
||||
await coordinates.press("Enter");
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect(content).toBeFocused();
|
||||
await page.setViewportSize({ width: 960, height: 600 });
|
||||
await expect(page.getByRole("button", { name: "6:8", exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test("each file keeps its own find bar, query and caret", async ({ workbench: page }) => {
|
||||
const find = page.getByRole("textbox", { name: "Find" });
|
||||
const caret = page.getByRole("button", { name: /^\d+:\d+/ });
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test.use({ video: "on" });
|
||||
|
||||
@@ -100,3 +100,46 @@ test("uses the single project's type in the keyboard New popup", async ({ workbe
|
||||
page.getByRole("dialog", { name: "New File from Template" }).getByText("Go File", { exact: true }),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("names a file from a template and keeps keyboard kind selection visible in a short window", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
const root = "/dev/acme-api";
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(() => {
|
||||
window.__ipc.handlers.fs_create_file = () => null;
|
||||
});
|
||||
await page.locator(`[data-project-path="${root}"]`).click();
|
||||
await page.keyboard.press("Meta+n");
|
||||
const menu = page.getByRole("dialog", { name: "New", exact: true });
|
||||
await menu.getByRole("textbox", { name: "Search for file type" }).fill("from template");
|
||||
await menu.getByText("From Template…", { exact: true }).click();
|
||||
const templates = page.getByRole("dialog", { name: "New File from Template" });
|
||||
const kotlin = templates.getByRole("option", { name: "Kotlin Class/File", exact: true });
|
||||
await kotlin.hover();
|
||||
await expect(kotlin).toHaveAttribute("aria-selected", "true");
|
||||
await page.keyboard.press("Enter");
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "New Kotlin Class/File", exact: true });
|
||||
const name = dialog.getByRole("textbox", { name: "Name", exact: true });
|
||||
const kinds = dialog.getByRole("listbox", { name: "Kind", exact: true });
|
||||
await expect(name).toBeFocused();
|
||||
await page.setViewportSize({ width: 430, height: 380 });
|
||||
const bounds = (await dialog.boundingBox())!;
|
||||
expect(Math.abs(bounds.y + bounds.height / 2 - 190)).toBeLessThan(12);
|
||||
await expect.poll(() => kinds.evaluate((el) => el.scrollHeight - el.clientHeight)).toBeGreaterThan(0);
|
||||
|
||||
await name.press("Enter");
|
||||
await expect(dialog.getByRole("alert")).toHaveText("Enter a name");
|
||||
await name.fill("OrderSummary");
|
||||
await name.press("ArrowUp");
|
||||
const last = kinds.getByRole("option", { name: "JUnit 5 Test", selected: true });
|
||||
await expect(last).toBeInViewport({ ratio: 1 });
|
||||
await expect(name).toBeFocused();
|
||||
for (let i = 0; i < 3; i++) await name.press("ArrowUp");
|
||||
await expect(kinds.getByRole("option", { name: "Data class", selected: true })).toBeVisible();
|
||||
await name.press("Enter");
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect.poll(() => ipcCalls(page, "fs_create_file")).toEqual([{ path: `${root}/OrderSummary.kt` }]);
|
||||
await expect(page.getByRole("tab", { name: "OrderSummary.kt" })).toHaveAttribute("aria-selected", "true");
|
||||
});
|
||||
@@ -215,6 +215,7 @@ doc_open_untitled always project_host bin
|
||||
doc_open_virtual always project_host bindings async
|
||||
doc_outline always project_host bindings async
|
||||
doc_python_facts always project_host bindings async
|
||||
doc_reload_from_disk always project_host bindings async
|
||||
doc_save always project_host bindings async
|
||||
doc_save_all always project_host bindings async
|
||||
doc_save_as always project_host bindings async
|
||||
|
||||
@@ -533,6 +533,8 @@ export const commands = {
|
||||
docOutline: (doc: DocId) => typedError<OutlineItem[], IdeError>(__TAURI_INVOKE("doc_outline", { doc })),
|
||||
/** Python class facts for the inheritance inspections: tree-sitter, no language server. */
|
||||
docPythonFacts: (doc: DocId) => typedError<PythonFacts, IdeError>(__TAURI_INVOKE("doc_python_facts", { doc })),
|
||||
/** Load Changes from Disk: discards the buffer's unsaved changes and reads its file again. */
|
||||
docReloadFromDisk: (doc: DocId) => typedError<null, IdeError>(__TAURI_INVOKE("doc_reload_from_disk", { doc })),
|
||||
docSave: (doc: DocId) => typedError<null, IdeError>(__TAURI_INVOKE("doc_save", { doc })),
|
||||
docSaveAll: () => typedError<null, IdeError>(__TAURI_INVOKE("doc_save_all")),
|
||||
/**
|
||||
@@ -7033,6 +7035,11 @@ workspaceEdit?: boolean } |
|
||||
{ type: "docDirty"; doc: DocId; dirty: boolean;
|
||||
/** Text version when this transition occurred, including when it was saved. */
|
||||
version: number } |
|
||||
/**
|
||||
* An open document's file changed on disk while the buffer had unsaved changes. The buffer
|
||||
* keeps them (autosave leaves the file alone); the UI offers to load the disk version.
|
||||
*/
|
||||
{ type: "docDiskConflict"; doc: DocId; path: string } |
|
||||
/** A complete workspace edit can be undone as one operation. */
|
||||
{ type: "workspaceEditApplied"; id: number; paths: IpcPath[];
|
||||
/**
|
||||
|
||||
@@ -77,6 +77,10 @@ export interface DocBackend {
|
||||
onDirty(handler: (e: DocDirtyEvent) => void): () => void;
|
||||
/** Files changed on disk (used to refresh nothing but closed-file state). */
|
||||
onFsChanged?(handler: (e: { removed: string[] }) => void): () => void;
|
||||
/** A file changed on disk while its buffer had unsaved changes, which the buffer kept. */
|
||||
onDiskConflict?(handler: (e: { doc: DocId; path: string }) => void): () => void;
|
||||
/** Load Changes from Disk: drops the buffer's unsaved changes and reads its file again. */
|
||||
reloadDiscarding?(doc: DocId): Promise<void>;
|
||||
/**
|
||||
* Every OpenIDEA window lost focus to another application. Also seen while focus is in a frame
|
||||
* (a plugin's web view), which hides the window's own `blur`.
|
||||
@@ -112,6 +116,8 @@ export const ipcBackend: DocBackend = {
|
||||
onPatched: (h) => onIdeEvent("docPatched", (e) => h(e)),
|
||||
onDirty: (h) => onIdeEvent("docDirty", (e) => h(e)),
|
||||
onFsChanged: (h) => onIdeEvent("fsChanged", (e) => h(e)),
|
||||
onDiskConflict: (h) => onIdeEvent("docDiskConflict", (e) => h(e)),
|
||||
reloadDiscarding: async (doc) => void (await call(commands.docReloadFromDisk(doc))),
|
||||
onApplicationDeactivated: (h) => {
|
||||
if (!isTauri()) return () => {};
|
||||
const listener = getCurrentWebviewWindow().listen("ide://application-deactivated", () => h());
|
||||
|
||||
@@ -466,6 +466,8 @@ export class EditorController implements SlotHost {
|
||||
if (prevRoot) this.projectTransition = this.restoreSession(prevRoot);
|
||||
if (this.manager.backend.onFsChanged)
|
||||
this.disposers.push(this.manager.backend.onFsChanged((e) => this.onFilesRemoved(e.removed)));
|
||||
if (this.manager.backend.onDiskConflict)
|
||||
this.disposers.push(this.manager.backend.onDiskConflict((e) => this.onDiskConflict(e.path)));
|
||||
const onWindowBlur = () => {
|
||||
if (this.autoSave() && !this.closeSession) {
|
||||
void this.manager.saveAll("auto");
|
||||
@@ -1765,6 +1767,39 @@ export class EditorController implements SlotHost {
|
||||
});
|
||||
}
|
||||
/** Reload from Disk: re-reads the open, unmodified documents of `paths`. */
|
||||
/**
|
||||
* A file changed on disk while its buffer had unsaved changes: the buffer keeps them (autosave
|
||||
* leaves the file alone) until the user loads the disk version or saves over it.
|
||||
*/
|
||||
private onDiskConflict(path: string) {
|
||||
const key = `disk-conflict:${path}`;
|
||||
notifications().notify({
|
||||
level: "warning",
|
||||
key,
|
||||
sticky: true,
|
||||
title: tx`${basename(path)} changed on disk`,
|
||||
body: tx(
|
||||
"The file was changed outside the IDE while it has unsaved changes in the editor. Saving keeps the editor's version and overwrites the file.",
|
||||
),
|
||||
actions: [
|
||||
{
|
||||
label: tx("Load Changes from Disk"),
|
||||
run: () => {
|
||||
const doc = this.manager.get(path)?.getMeta().doc;
|
||||
if (doc === undefined || !this.manager.backend.reloadDiscarding) return;
|
||||
this.manager.backend.reloadDiscarding(doc).catch((e: unknown) =>
|
||||
notifications().notify({
|
||||
level: "error",
|
||||
title: tx("Cannot reload from disk"),
|
||||
body: e instanceof Error ? e.message : String(e),
|
||||
}),
|
||||
);
|
||||
},
|
||||
},
|
||||
{ label: tx("Keep Editor Changes"), run: () => {} },
|
||||
],
|
||||
});
|
||||
}
|
||||
async reloadFromDisk(paths: string[]) {
|
||||
for (const path of paths) {
|
||||
const model = this.manager.get(path);
|
||||
|
||||
@@ -275,12 +275,19 @@
|
||||
|
||||
/* Go to line */
|
||||
.gotoBody {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
padding: 8px 16px 0;
|
||||
display: grid;
|
||||
grid-template-columns: fit-content(50%) minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: var(--space-1) var(--space-2);
|
||||
padding: var(--space-1) var(--space-4) 0;
|
||||
}
|
||||
.gotoLabel {
|
||||
overflow-wrap: anywhere;
|
||||
color: var(--fg);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.gotoHint {
|
||||
grid-column: 2;
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/** ⌘L: "Go to Line:Column" (1-based `line[:col]`). */
|
||||
import { useState, type FormEvent } from "react";
|
||||
import { Dialog, Input } from "@/ui";
|
||||
import { useId, useState, type FormEvent } from "react";
|
||||
import { Dialog, Input, T } from "@/ui";
|
||||
import { editorController, useEditorStatus, useGotoLine } from "../controller";
|
||||
import styles from "./EditorArea.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export function parseLineCol(text: string): { line: number; col: number } | null {
|
||||
const m = /^\s*(\d+)\s*(?:[:,]\s*(\d+))?\s*$/.exec(text);
|
||||
@@ -22,6 +21,7 @@ export function GotoLineDialog() {
|
||||
|
||||
function GotoLineInner() {
|
||||
const status = useEditorStatus((s) => s.status);
|
||||
const coordinatesId = useId();
|
||||
const [value, setValue] = useState(() => (status ? `${status.line + 1}:${status.col + 1}` : ""));
|
||||
const parsed = parseLineCol(value);
|
||||
const close = () => useGotoLine.setState({ open: false });
|
||||
@@ -43,19 +43,24 @@ function GotoLineInner() {
|
||||
]}
|
||||
>
|
||||
<form onSubmit={submit} className={styles.gotoBody}>
|
||||
<label className={styles.gotoLabel} htmlFor={coordinatesId}>
|
||||
<T>Line and column</T>
|
||||
</label>
|
||||
<Input
|
||||
id={coordinatesId}
|
||||
data-autofocus=""
|
||||
mono
|
||||
value={value}
|
||||
invalid={!!value && !parsed}
|
||||
onChange={(e) => setValue(e.target.value)}
|
||||
onFocus={(e) => e.currentTarget.select()}
|
||||
aria-label="Line and column"
|
||||
aria-describedby={status ? undefined : `${coordinatesId}-hint`}
|
||||
placeholder="line[:column]"
|
||||
/>
|
||||
<span className={styles.gotoHint}>
|
||||
{status ? tx`Current position ${status.line + 1}:${status.col + 1}` : tx("No active editor")}
|
||||
</span>
|
||||
{!status && (
|
||||
<span className={styles.gotoHint} id={`${coordinatesId}-hint`}>
|
||||
<T>No active editor</T>
|
||||
</span>
|
||||
)}
|
||||
</form>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
} from "@/ui";
|
||||
import { useContributions, type RunConfigTypeContribution } from "@/workbench/contributions";
|
||||
import { TASK_LABELS, taskLabel, type BeforeLaunchKind } from "./beforeLaunch";
|
||||
import { ExpandableTextarea } from "./ExpandableTextarea";
|
||||
import {
|
||||
commandLine,
|
||||
compoundCycle,
|
||||
@@ -817,7 +818,6 @@ function TypeField({
|
||||
invalid: boolean;
|
||||
onChange: (value: string) => void;
|
||||
}) {
|
||||
const tx = useTx();
|
||||
const root = useProject((s) => s.project?.root ?? null);
|
||||
const listId = `run-field-${field.key}`;
|
||||
const [loaded, setLoaded] = useState<ReadonlyArray<{ value: string; label: string; detail?: string }>>([]);
|
||||
@@ -848,14 +848,13 @@ function TypeField({
|
||||
return <Checkbox checked={value === "true"} onChange={(on) => onChange(on ? "true" : "")} label={field.label} />;
|
||||
if (field.control === "textarea")
|
||||
return (
|
||||
<textarea
|
||||
className={clsx(styles.textarea, invalid && styles.textareaInvalid)}
|
||||
aria-label={tx(field.label)}
|
||||
spellCheck={false}
|
||||
<ExpandableTextarea
|
||||
label={field.label}
|
||||
value={value}
|
||||
placeholder={tx(field.placeholder)}
|
||||
rows={field.rows ?? 4}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
placeholder={field.placeholder}
|
||||
rows={field.rows}
|
||||
invalid={invalid}
|
||||
onChange={onChange}
|
||||
/>
|
||||
);
|
||||
const suggestions = field.suggestions?.(all, params) ?? [];
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { afterEach, expect, it, vi } from "vitest";
|
||||
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
||||
import { ExpandableTextarea } from "./ExpandableTextarea";
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
const LONG = "-Ddemo.endpoint=https://example.com/demo/environments/local/feature-flags/configuration/versions/current";
|
||||
const VALUE = `-Xmx512m\n${LONG}\n-Ddemo.mode=local`;
|
||||
|
||||
function editors() {
|
||||
return screen.getAllByRole("textbox", { name: "VM options" }) as HTMLTextAreaElement[];
|
||||
}
|
||||
|
||||
it("edits in an expanded editor that keeps each line on one visual line", () => {
|
||||
const onChange = vi.fn();
|
||||
render(<ExpandableTextarea label="VM options" value={VALUE} onChange={onChange} />);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Expand (⇧⏎)" }));
|
||||
const expanded = editors()[1]!;
|
||||
expect(expanded.value).toBe(VALUE);
|
||||
expect(expanded.getAttribute("wrap")).toBe("off");
|
||||
fireEvent.change(expanded, { target: { value: `${VALUE}\n-Dextra=1` } });
|
||||
fireEvent.click(screen.getByRole("button", { name: "OK" }));
|
||||
expect(onChange).toHaveBeenCalledWith(`${VALUE}\n-Dextra=1`);
|
||||
expect(editors()).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("leaves the value alone on Cancel or OK without edits, and opens with Shift+Enter", () => {
|
||||
const onChange = vi.fn();
|
||||
render(<ExpandableTextarea label="VM options" value={VALUE} onChange={onChange} />);
|
||||
fireEvent.keyDown(editors()[0]!, { key: "Enter", shiftKey: true });
|
||||
fireEvent.change(editors()[1]!, { target: { value: "-Xmx1g" } });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
|
||||
expect(editors()).toHaveLength(1);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Expand (⇧⏎)" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "OK" }));
|
||||
expect(onChange).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -0,0 +1,100 @@
|
||||
import { useState } from "react";
|
||||
import clsx from "clsx";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import { Dialog, IconButton } from "@/ui";
|
||||
import styles from "./Run.module.css";
|
||||
|
||||
/**
|
||||
* A run configuration's multi-line field (VM options, say) with an Expand button (⇧⏎) that
|
||||
* edits it in a larger editor where each line stays on one visual line and scrolls sideways,
|
||||
* so one long argument isn't mistaken for several.
|
||||
*/
|
||||
export function ExpandableTextarea({
|
||||
label,
|
||||
value,
|
||||
placeholder,
|
||||
rows,
|
||||
invalid,
|
||||
onChange,
|
||||
}: {
|
||||
label: string;
|
||||
value: string;
|
||||
placeholder?: string;
|
||||
rows?: number;
|
||||
invalid?: boolean;
|
||||
onChange: (value: string) => void;
|
||||
}) {
|
||||
const tx = useTx();
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
return (
|
||||
<div className={styles.textareaWithButton}>
|
||||
<textarea
|
||||
className={clsx(styles.textarea, invalid && styles.textareaInvalid)}
|
||||
aria-label={tx(label)}
|
||||
spellCheck={false}
|
||||
value={value}
|
||||
placeholder={tx(placeholder)}
|
||||
rows={rows ?? 4}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" && e.shiftKey && !e.altKey && !e.metaKey && !e.ctrlKey) {
|
||||
e.preventDefault();
|
||||
setExpanded(true);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<IconButton icon="expand-all" size="small" iconSize={14} title="Expand (⇧⏎)" onClick={() => setExpanded(true)} />
|
||||
{expanded && (
|
||||
<ExpandedTextDialog label={label} value={value} onOk={onChange} onClose={() => setExpanded(false)} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ExpandedTextDialog({
|
||||
label,
|
||||
value,
|
||||
onOk,
|
||||
onClose,
|
||||
}: {
|
||||
label: string;
|
||||
value: string;
|
||||
onOk: (value: string) => void;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const tx = useTx();
|
||||
const [text, setText] = useState(value);
|
||||
return (
|
||||
<Dialog
|
||||
open
|
||||
title={tx(label)}
|
||||
onClose={onClose}
|
||||
width={720}
|
||||
resizable="both"
|
||||
minWidth={360}
|
||||
minHeight={220}
|
||||
buttons={[
|
||||
{
|
||||
label: "OK",
|
||||
role: "default",
|
||||
onClick: () => {
|
||||
if (text !== value) onOk(text);
|
||||
onClose();
|
||||
},
|
||||
},
|
||||
{ label: "Cancel", role: "cancel" },
|
||||
]}
|
||||
>
|
||||
<textarea
|
||||
className={clsx(styles.textarea, styles.expandedTextarea)}
|
||||
aria-label={tx(label)}
|
||||
spellCheck={false}
|
||||
wrap="off"
|
||||
rows={14}
|
||||
value={text}
|
||||
autoFocus
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
/>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -848,6 +848,29 @@
|
||||
font-size: var(--fs-ui);
|
||||
outline: none;
|
||||
}
|
||||
.textareaWithButton {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: var(--space-1-5);
|
||||
min-width: 0;
|
||||
}
|
||||
.textareaWithButton > textarea {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.textareaWithButton > button {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
/* One visual line per line of text: a long argument scrolls instead of wrapping. */
|
||||
.expandedTextarea {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 160px;
|
||||
box-sizing: border-box;
|
||||
resize: none;
|
||||
white-space: pre;
|
||||
overflow: auto;
|
||||
}
|
||||
.textarea:focus {
|
||||
box-shadow: inset 0 0 0 1px var(--focus-ring);
|
||||
}
|
||||
|
||||
@@ -71,11 +71,15 @@ async function openDialog(page?: string) {
|
||||
}
|
||||
|
||||
describe("Settings dialog", () => {
|
||||
it("offers only new window, current window and ask, including old attach settings", async () => {
|
||||
it("offers new window, current window, a new tab and ask, but not attach", async () => {
|
||||
current = setAt(current, "general.openProjectIn", "attach");
|
||||
const dialog = await openDialog("general");
|
||||
const group = within(dialog).getByRole("radiogroup", { name: "Open project in" });
|
||||
expect(within(group).getAllByRole("radio")).toHaveLength(3);
|
||||
expect(
|
||||
within(group)
|
||||
.getAllByRole("radio")
|
||||
.map((r) => r.closest("label")?.textContent),
|
||||
).toEqual(["New window", "Current window", "New tab in current window", "Ask"]);
|
||||
expect(within(group).getByRole("radio", { name: "Ask" })).toBeChecked();
|
||||
expect(within(group).queryByRole("radio", { name: "Attach" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -43,28 +43,36 @@
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
.kinds {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 2px 0;
|
||||
.nameDialog .form {
|
||||
padding: 0 var(--space-2) var(--space-2);
|
||||
gap: 0;
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.kind {
|
||||
.nameField {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
height: var(--h-row);
|
||||
padding: 0 8px;
|
||||
border-radius: var(--radius-row);
|
||||
color: var(--fg);
|
||||
cursor: default;
|
||||
gap: var(--space-1-5);
|
||||
min-height: calc(var(--h-field) + var(--space-1));
|
||||
padding-inline: var(--space-2);
|
||||
}
|
||||
.kind:hover {
|
||||
background: var(--bg-hover);
|
||||
.nameField:has(input[aria-invalid="true"]) {
|
||||
box-shadow: inset 0 -1px var(--danger);
|
||||
}
|
||||
.kindActive,
|
||||
.kindActive:hover {
|
||||
background: var(--bg-selected);
|
||||
color: var(--fg-strong);
|
||||
.nameInput {
|
||||
width: 100%;
|
||||
}
|
||||
.nameDialog .kinds {
|
||||
border-top: 1px solid var(--border);
|
||||
padding-block: var(--space-1);
|
||||
}
|
||||
.kindList {
|
||||
--list-inset: 0px;
|
||||
max-height: min(240px, 40vh);
|
||||
}
|
||||
.kindLabel {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.hint {
|
||||
min-height: 16px;
|
||||
@@ -74,6 +82,11 @@
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.nameDialog .hint {
|
||||
margin: var(--space-1) var(--space-2) 0;
|
||||
}
|
||||
.error {
|
||||
color: var(--danger);
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/** "New ▸ <template>" dialog: template chooser, then name + kind (IDEA's New Class dialog). */
|
||||
import { useEffect, useEffectEvent, useMemo, useRef, useState, type KeyboardEvent } from "react";
|
||||
import { useEffect, useEffectEvent, useId, useMemo, useRef, useState, type KeyboardEvent } from "react";
|
||||
import { create } from "zustand";
|
||||
import clsx from "clsx";
|
||||
import { relativePath, useProject } from "@/platform/project";
|
||||
@@ -120,6 +120,8 @@ function NameStep({
|
||||
}) {
|
||||
const [name, setName] = useState(template.fileName ?? initialName ?? "");
|
||||
const variables = template.variables ?? [];
|
||||
const hasVariables = variables.length > 0;
|
||||
const hintId = useId();
|
||||
const [values, setValues] = useState<Record<string, string>>(() =>
|
||||
Object.fromEntries(variables.map((v) => [v.name, ""])),
|
||||
);
|
||||
@@ -230,12 +232,13 @@ function NameStep({
|
||||
open
|
||||
onClose={close}
|
||||
title={tx`New ${tx(template.name)}`}
|
||||
width={380}
|
||||
position="top"
|
||||
width={hasVariables ? 380 : 320}
|
||||
position={hasVariables ? "top" : "center"}
|
||||
popup
|
||||
aria-label={tx`New ${tx(template.name)}`}
|
||||
className={variables.length ? styles.variableDialog : undefined}
|
||||
className={hasVariables ? styles.variableDialog : styles.nameDialog}
|
||||
buttons={
|
||||
variables.length
|
||||
hasVariables
|
||||
? [
|
||||
{ label: "Cancel", role: "cancel" },
|
||||
{ label: "Create", role: "default", onClick: () => void submit(), disabled: busy },
|
||||
@@ -245,19 +248,25 @@ function NameStep({
|
||||
>
|
||||
<div className={styles.form}>
|
||||
{template.fileName === undefined && (
|
||||
<Input
|
||||
disabled={busy}
|
||||
data-autofocus
|
||||
value={name}
|
||||
invalid={!!error}
|
||||
placeholder={effective.extension ? tx`Name (.${effective.extension})` : "File name with extension"}
|
||||
aria-label="Name"
|
||||
onChange={(e) => {
|
||||
setName(e.target.value);
|
||||
setError(null);
|
||||
}}
|
||||
onKeyDown={onKeyDown}
|
||||
/>
|
||||
<div className={hasVariables ? undefined : styles.nameField}>
|
||||
{!hasVariables && <Icon name={template.icon} size={16} className={styles.icon} />}
|
||||
<Input
|
||||
className={styles.nameInput}
|
||||
variant={hasVariables ? "framed" : "bare"}
|
||||
disabled={busy}
|
||||
data-autofocus
|
||||
value={name}
|
||||
invalid={!!error}
|
||||
placeholder={effective.extension ? tx`Name (.${effective.extension})` : "File name with extension"}
|
||||
aria-label="Name"
|
||||
aria-describedby={hintId}
|
||||
onChange={(e) => {
|
||||
setName(e.target.value);
|
||||
setError(null);
|
||||
}}
|
||||
onKeyDown={onKeyDown}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{variables.map((v, i) => (
|
||||
<VerbatimTextContext.Provider key={v.name} value={true}>
|
||||
@@ -278,26 +287,33 @@ function NameStep({
|
||||
</VerbatimTextContext.Provider>
|
||||
))}
|
||||
{template.kinds.length > 1 && (
|
||||
<div className={styles.kinds} role="listbox" aria-label={tx("Kind")}>
|
||||
{template.kinds.map((k, i) => (
|
||||
<div
|
||||
key={k.id}
|
||||
role="option"
|
||||
aria-selected={i === kind}
|
||||
className={clsx(styles.kind, i === kind && styles.kindActive)}
|
||||
onMouseDown={(e) => {
|
||||
e.preventDefault();
|
||||
setKind(i);
|
||||
}}
|
||||
onDoubleClick={() => void submit()}
|
||||
>
|
||||
<Icon name={template.icon} size={14} className={styles.icon} />
|
||||
{tx(k.label)}
|
||||
</div>
|
||||
))}
|
||||
<div className={styles.kinds}>
|
||||
<List
|
||||
className={styles.kindList}
|
||||
aria-label={tx("Kind")}
|
||||
items={template.kinds}
|
||||
getKey={(k) => k.id}
|
||||
activeIndex={kind}
|
||||
onActiveChange={setKind}
|
||||
focusable={false}
|
||||
onActivate={(_, _index, event) => {
|
||||
if ("detail" in event && event.detail === 2) void submit();
|
||||
}}
|
||||
renderItem={(k) => (
|
||||
<>
|
||||
<Icon name={template.icon} size={16} className={styles.icon} />
|
||||
<span className={styles.kindLabel}>{tx(k.label)}</span>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className={clsx(styles.hint, error && styles.error)}>
|
||||
<div
|
||||
id={hintId}
|
||||
className={clsx(styles.hint, error && styles.error)}
|
||||
title={error ? undefined : where}
|
||||
role={error ? "alert" : undefined}
|
||||
>
|
||||
{error ?? (
|
||||
<>
|
||||
{where}
|
||||
|
||||
@@ -2732,5 +2732,9 @@
|
||||
"Presentation": "Presentation",
|
||||
"Code Assistance": "Code Assistance",
|
||||
"Managed version {version} in {location}": "Managed version {version} in {location}",
|
||||
"Managed in {location}": "Managed in {location}"
|
||||
"Managed in {location}": "Managed in {location}",
|
||||
"{name} changed on disk": "{name} changed on disk",
|
||||
"The file was changed outside the IDE while it has unsaved changes in the editor. Saving keeps the editor's version and overwrites the file.": "The file was changed outside the IDE while it has unsaved changes in the editor. Saving keeps the editor's version and overwrites the file.",
|
||||
"Load Changes from Disk": "Load Changes from Disk",
|
||||
"Keep Editor Changes": "Keep Editor Changes"
|
||||
}
|
||||
@@ -4625,7 +4625,6 @@
|
||||
"HEAD is detached; check out a branch to push.": "HEAD está desacoplado; cambie a una rama para hacer push.",
|
||||
"No shelved changes": "No hay cambios en el estante",
|
||||
"No recent projects": "No hay proyectos recientes",
|
||||
"Current position {line}:{col}": "Posición actual {line}:{col}",
|
||||
"{count} detected folders are unmarked.": "{count} carpetas detectadas están desmarcadas.",
|
||||
"Rebase commits of {head} not on:": "Hacer rebase de las confirmaciones de {head} que no están en:",
|
||||
"{head} has no upstream: commits up to {revision} will be pushed as a new branch:": "{head} no tiene rama remota de seguimiento (upstream): las confirmaciones hasta {revision} se enviarán con push como una rama nueva:",
|
||||
|
||||
@@ -4480,7 +4480,6 @@
|
||||
"HEAD is detached; check out a branch to push.": "HEAD est détachée ; extrayez une branche pour pousser.",
|
||||
"No shelved changes": "Aucune modification mise de côté",
|
||||
"No recent projects": "Aucun projet récent",
|
||||
"Current position {line}:{col}": "Position actuelle {line}:{col}",
|
||||
"{count} detected folders are unmarked.": "{count} dossiers détectés ne sont pas marqués.",
|
||||
"Rebase commits of {head} not on:": "Rebaser les commits de {head} absents de :",
|
||||
"{head} has no upstream: commits up to {revision} will be pushed as a new branch:": "{head} n'a pas de branche amont : les commits jusqu'à {revision} seront poussés comme nouvelle branche :",
|
||||
|
||||
@@ -4693,7 +4693,6 @@
|
||||
"HEAD is detached; check out a branch to push.": "HEAD가 분리되었습니다. 푸시하려면 브랜치를 체크아웃하세요.",
|
||||
"No shelved changes": "보류된 변경 사항 없음",
|
||||
"No recent projects": "최근 프로젝트 없음",
|
||||
"Current position {line}:{col}": "현재 위치 {line}:{col}",
|
||||
"{count} detected folders are unmarked.": "감지된 폴더 {count}개가 표시되지 않았습니다.",
|
||||
"Rebase commits of {head} not on:": "다음에 없는 {head}의 커밋 리베이스:",
|
||||
"{head} has no upstream: commits up to {revision} will be pushed as a new branch:": "{head}에 업스트림이 없습니다. {revision}까지의 커밋이 새 브랜치로 푸시됩니다:",
|
||||
|
||||
@@ -4577,7 +4577,6 @@
|
||||
"HEAD is detached; check out a branch to push.": "Wskaźnik HEAD jest odłączony; przełącz się na gałąź, aby wykonać push.",
|
||||
"No shelved changes": "Brak odłożonych zmian (shelved)",
|
||||
"No recent projects": "Brak ostatnich projektów",
|
||||
"Current position {line}:{col}": "Bieżąca pozycja: {line}:{col}",
|
||||
"{count} detected folders are unmarked.": "Wykryte foldery w liczbie {count} nie zostały zaznaczone.",
|
||||
"Rebase commits of {head} not on:": "Wykonaj rebase zatwierdzeń {head} nieobecnych w:",
|
||||
"{head} has no upstream: commits up to {revision} will be pushed as a new branch:": "Gałąź {head} nie ma ustawionego repozytorium nadrzędnego (upstream): zatwierdzenia do wersji {revision} zostaną wysłane jako nowa gałąź:",
|
||||
|
||||
@@ -4591,7 +4591,6 @@
|
||||
"HEAD is detached; check out a branch to push.": "HEAD está desanexada; faça checkout de uma branch para fazer push.",
|
||||
"No shelved changes": "Nenhuma alteração no shelf",
|
||||
"No recent projects": "Nenhum projeto recente",
|
||||
"Current position {line}:{col}": "Posição atual {line}:{col}",
|
||||
"{count} detected folders are unmarked.": "{count} pastas detectadas não estão marcadas.",
|
||||
"Rebase commits of {head} not on:": "Fazer rebase dos commits de {head} ausentes em:",
|
||||
"{head} has no upstream: commits up to {revision} will be pushed as a new branch:": "{head} não tem upstream: commits até {revision} serão enviados com push como uma nova branch:",
|
||||
|
||||
@@ -5537,7 +5537,6 @@
|
||||
"HEAD is detached; check out a branch to push.": "HEAD 处于分离状态;请签出一个分支后再推送。",
|
||||
"No shelved changes": "没有已搁置的更改",
|
||||
"No recent projects": "没有最近的项目",
|
||||
"Current position {line}:{col}": "当前位置 {line}:{col}",
|
||||
"{count} detected folders are unmarked.": "有 {count} 个检测到的文件夹未标记。",
|
||||
"Rebase commits of {head} not on:": "变基 {head} 中不在以下分支上的提交:",
|
||||
"{head} has no upstream: commits up to {revision} will be pushed as a new branch:": "{head} 没有上游分支:截至 {revision} 的提交将作为新分支推送:",
|
||||
@@ -9098,5 +9097,9 @@
|
||||
"Leave empty to use the active GitHub CLI account. OpenIDEA resolves the token at launch and never stores it.": "留空则使用 GitHub CLI 当前登录的账号。OpenIDEA 在启动时获取令牌,不会保存它。",
|
||||
"github-username": "GitHub 用户名",
|
||||
"Managed version {version} in {location}": "版本 {version} 由 {location} 管理",
|
||||
"Managed in {location}": "由 {location} 管理"
|
||||
"Managed in {location}": "由 {location} 管理",
|
||||
"{name} changed on disk": "{name} 已在磁盘上更改",
|
||||
"The file was changed outside the IDE while it has unsaved changes in the editor. Saving keeps the editor's version and overwrites the file.": "该文件在 IDE 外被修改,而编辑器中还有未保存的更改。保存会保留编辑器中的版本并覆盖该文件。",
|
||||
"Load Changes from Disk": "从磁盘加载更改",
|
||||
"Keep Editor Changes": "保留编辑器中的更改"
|
||||
}
|
||||
@@ -134,6 +134,8 @@ export interface DialogProps {
|
||||
* and drag only by a `[data-dialog-drag]` element, such as their title.
|
||||
*/
|
||||
position?: "center" | "top";
|
||||
/** Use lightweight popup chrome even when the dialog is centered. */
|
||||
popup?: boolean;
|
||||
className?: string;
|
||||
"aria-label"?: string;
|
||||
/** Close when clicking outside (default: only for `top` popups). */
|
||||
@@ -227,6 +229,7 @@ function DialogInner({
|
||||
initialSize,
|
||||
onResized,
|
||||
position = "center",
|
||||
popup: asPopup = false,
|
||||
className,
|
||||
dismissOnBackdrop,
|
||||
closeOnDeactivate,
|
||||
@@ -240,8 +243,7 @@ function DialogInner({
|
||||
const overlayTitleBar = usePlatform((s) => s.overlayTitleBar);
|
||||
const given = useGivenTx();
|
||||
if (typeof title === "string") title = given(title);
|
||||
// Choosers and untitled dialogs (Recent Files, About) are IDEA popups.
|
||||
const popup = position === "top" || (title == null && !icon);
|
||||
const popup = asPopup || position === "top" || (title == null && !icon);
|
||||
const onCloseRef = useRef(onClose);
|
||||
const buttonsRef = useRef(buttons);
|
||||
const restoreFocusRef = useRef(restoreFocus);
|
||||
|
||||
Reference in new issue
Заблокувати користувача