дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-28 13:32:29 +02:00
Порівняти коміти
1
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
cd14222b4d |
No files matched your search
Створено
+44
-44
@@ -4144,7 +4144,7 @@ checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
|
||||
|
||||
[[package]]
|
||||
name = "ide-agent"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"encoding_rs",
|
||||
@@ -4168,7 +4168,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-analysis"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"ast-grep-core",
|
||||
"ide-core",
|
||||
@@ -4182,7 +4182,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-android"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"serde",
|
||||
@@ -4193,7 +4193,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-build"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"chardetng",
|
||||
@@ -4211,7 +4211,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-cli"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"serde",
|
||||
@@ -4225,7 +4225,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-clipboard"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"gtk",
|
||||
"objc2 0.6.5",
|
||||
@@ -4235,7 +4235,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-core"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"encoding_rs",
|
||||
@@ -4252,7 +4252,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-coverage"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-run",
|
||||
@@ -4266,7 +4266,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-dap"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"ide-core",
|
||||
@@ -4293,7 +4293,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-db"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bb8",
|
||||
@@ -4329,7 +4329,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-docker"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"serde",
|
||||
@@ -4342,7 +4342,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-extension"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"blake3",
|
||||
@@ -4363,7 +4363,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-fonts"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"objc2-core-foundation",
|
||||
"objc2-core-text",
|
||||
@@ -4375,7 +4375,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-github"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-vcs",
|
||||
@@ -4388,7 +4388,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-heap"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"ide-core",
|
||||
@@ -4406,7 +4406,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-host"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"blake3",
|
||||
@@ -4477,7 +4477,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-http"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-vfs",
|
||||
@@ -4496,7 +4496,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-index"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"criterion",
|
||||
@@ -4518,7 +4518,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-jdwp"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"ide-jvm-inspect",
|
||||
"proptest",
|
||||
@@ -4530,7 +4530,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-jsonrpc"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"futures",
|
||||
@@ -4547,7 +4547,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-jvm-attach"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"tempfile",
|
||||
@@ -4556,7 +4556,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-jvm-inspect"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"serde",
|
||||
@@ -4567,7 +4567,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-language"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"criterion",
|
||||
@@ -4624,7 +4624,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-lsp"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"encoding_rs",
|
||||
@@ -4652,7 +4652,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-mcp"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"dunce",
|
||||
@@ -4671,7 +4671,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-notebook"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"ide-core",
|
||||
@@ -4694,7 +4694,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-plugin"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"dunce",
|
||||
@@ -4717,7 +4717,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-profiler"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-jvm-attach",
|
||||
@@ -4731,7 +4731,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-remote"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"futures",
|
||||
@@ -4751,7 +4751,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-run"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"encoding_rs",
|
||||
@@ -4775,7 +4775,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-scaffold"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-tools",
|
||||
@@ -4791,7 +4791,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-sdk"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"ide-core",
|
||||
@@ -4812,7 +4812,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-search"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"encoding_rs",
|
||||
@@ -4833,7 +4833,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-spell"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"parking_lot",
|
||||
@@ -4846,7 +4846,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-ssh"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"flate2",
|
||||
@@ -4871,7 +4871,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-syntax"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-language",
|
||||
@@ -4886,7 +4886,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-terminal"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"libc",
|
||||
@@ -4899,7 +4899,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-text"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"ide-core",
|
||||
@@ -4912,7 +4912,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-tools"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"hex",
|
||||
@@ -4933,7 +4933,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-vcs"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"dunce",
|
||||
@@ -4954,7 +4954,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-vfs"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"chardetng",
|
||||
"dunce",
|
||||
@@ -4978,7 +4978,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-web"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"ide-core",
|
||||
@@ -4994,7 +4994,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-workspace"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"dunce",
|
||||
@@ -6595,7 +6595,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openidea"
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"blake3",
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ members = ["crates/*", "src-tauri"]
|
||||
exclude = ["sdk", "plugins"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.45"
|
||||
version = "0.1.44"
|
||||
edition = "2024"
|
||||
rust-version = "1.96"
|
||||
license = "Apache-2.0"
|
||||
|
||||
@@ -27,38 +27,17 @@ fn git_dir(root: &Path) -> Option<std::path::PathBuf> {
|
||||
Some(if path.is_absolute() { path.to_owned() } else { root.join(path) })
|
||||
}
|
||||
|
||||
/// The config and exclude file of the Git directory `git`; a linked worktree's directory
|
||||
/// (`.git/worktrees/<name>`) reads the shared ones its `commondir` names as well.
|
||||
fn insert_git_inputs(out: &mut std::collections::BTreeSet<std::path::PathBuf>, git: &Path) {
|
||||
out.insert(git.join("config"));
|
||||
out.insert(git.join("info/exclude"));
|
||||
if let Ok(common) = std::fs::read_to_string(git.join("commondir")) {
|
||||
let common = Path::new(common.trim());
|
||||
let common = if common.is_absolute() { common.to_owned() } else { git.join(common) };
|
||||
out.insert(common.join("config"));
|
||||
out.insert(common.join("info/exclude"));
|
||||
}
|
||||
}
|
||||
|
||||
/// External ignore/config inputs, including candidates that do not exist yet.
|
||||
/// These are outside the directory manifest (`.git` is skipped), so the full
|
||||
/// path set must match at warm start.
|
||||
pub(crate) fn external_ignore_candidates(root: &Path) -> Vec<std::path::PathBuf> {
|
||||
let mut out = std::collections::BTreeSet::new();
|
||||
if let Some(git) = git_dir(root) {
|
||||
insert_git_inputs(&mut out, &git);
|
||||
out.insert(git.join("config"));
|
||||
out.insert(git.join("info/exclude"));
|
||||
}
|
||||
out.insert(root.join(".git/config"));
|
||||
out.insert(root.join(".git/info/exclude"));
|
||||
// The walker also reads the ignore files above the root (`parents`), and a project nested
|
||||
// in a repository uses that repository's exclude file and config.
|
||||
for dir in root.ancestors().skip(1) {
|
||||
out.insert(dir.join(".gitignore"));
|
||||
out.insert(dir.join(".ignore"));
|
||||
if let Some(git) = git_dir(dir) {
|
||||
insert_git_inputs(&mut out, &git);
|
||||
}
|
||||
}
|
||||
if let Some(path) = ignore::gitignore::gitconfig_excludes_path() {
|
||||
out.insert(path);
|
||||
}
|
||||
|
||||
@@ -797,52 +797,6 @@ fn warm_start_detects_changed_ignore_rules() {
|
||||
assert_eq!(idx.status().files, 1, "an updated ignore rule invalidates the warm snapshot");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn warm_start_detects_changed_ignore_rules_above_the_project() {
|
||||
// The project is a folder of a repository whose ignore files sit above it.
|
||||
let f = Fixture::new(&[("generated/a.rs", "fn a() {}\n"), ("src/b.rs", "fn b() {}\n")]);
|
||||
let repo = f.root.parent().unwrap().to_owned();
|
||||
std::fs::create_dir_all(repo.join(".git/info")).unwrap();
|
||||
std::fs::write(repo.join(".git/HEAD"), "ref: refs/heads/main\n").unwrap();
|
||||
let idx = f.open();
|
||||
assert_eq!(idx.status().files, 2);
|
||||
drop(idx);
|
||||
|
||||
std::fs::write(repo.join(".gitignore"), "proj/generated/\n").unwrap();
|
||||
let idx = f.open();
|
||||
assert_eq!(idx.status().files, 1, "a new ignore file above the project invalidates the warm snapshot");
|
||||
drop(idx);
|
||||
|
||||
std::thread::sleep(Duration::from_millis(20));
|
||||
std::fs::write(repo.join(".gitignore"), "").unwrap();
|
||||
std::fs::write(repo.join(".git/info/exclude"), "proj/src/\n").unwrap();
|
||||
let idx = f.open();
|
||||
assert_eq!(idx.status().files, 1, "so do the enclosing repository's changed rules");
|
||||
assert!(!symbols(&idx, "a", SymbolFilter::All).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn warm_start_detects_a_changed_exclude_file_of_a_linked_worktree() {
|
||||
// The project is a linked worktree: its `.git` file points into the main repository,
|
||||
// whose shared `info/exclude` the walker reads through `commondir`.
|
||||
let f = Fixture::new(&[("generated/a.rs", "fn a() {}\n"), ("src/b.rs", "fn b() {}\n")]);
|
||||
let main = f.root.parent().unwrap().join("main/.git");
|
||||
let worktree = main.join("worktrees/proj");
|
||||
std::fs::create_dir_all(main.join("info")).unwrap();
|
||||
std::fs::create_dir_all(&worktree).unwrap();
|
||||
std::fs::write(main.join("HEAD"), "ref: refs/heads/main\n").unwrap();
|
||||
std::fs::write(worktree.join("HEAD"), "ref: refs/heads/wt\n").unwrap();
|
||||
std::fs::write(worktree.join("commondir"), "../..\n").unwrap();
|
||||
std::fs::write(f.root.join(".git"), format!("gitdir: {}\n", worktree.display())).unwrap();
|
||||
let idx = f.open();
|
||||
assert_eq!(idx.status().files, 2);
|
||||
drop(idx);
|
||||
|
||||
std::fs::write(main.join("info/exclude"), "generated/\n").unwrap();
|
||||
let idx = f.open();
|
||||
assert_eq!(idx.status().files, 1, "the shared exclude file invalidates the warm snapshot");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn warm_start_detects_a_new_file_in_an_existing_empty_directory() {
|
||||
let f = Fixture::new(&[("src/a.rs", "fn a() {}\n")]);
|
||||
|
||||
@@ -40,37 +40,22 @@ const LOOSE: &AsciiSet = &CONTROLS
|
||||
.add(b'|')
|
||||
.add(b'}');
|
||||
|
||||
/// Fields of LSP messages whose value is a URI.
|
||||
const URI_FIELDS: [&str; 9] =
|
||||
["uri", "targetUri", "newUri", "oldUri", "baseUri", "scopeUri", "rootUri", "target", "href"];
|
||||
|
||||
/// Percent-encodes the characters URIs don't allow in the `file:` URIs of `value`: the URI
|
||||
/// fields and the keys of a workspace edit's `changes`. Eclipse's jdtls sends a path as is
|
||||
/// (`file:///H:/项目/…`), which `lsp_types::Uri` rejects, failing the whole response. Other
|
||||
/// strings stay as sent: an edit's `newText` may well start with `file:` (YAML, `.env`).
|
||||
/// Percent-encodes the characters URIs don't allow in every `file:` URI in `value`, string
|
||||
/// values and object keys alike (a workspace edit's `changes`). Eclipse's jdtls sends a path
|
||||
/// as is (`file:///H:/项目/…`), which `lsp_types::Uri` rejects, failing the whole response.
|
||||
pub fn encode_loose_file_uris(value: &mut Value) {
|
||||
match value {
|
||||
Value::String(s) => {
|
||||
if let Some(encoded) = encode_loose(s) {
|
||||
*s = encoded;
|
||||
}
|
||||
}
|
||||
Value::Array(items) => items.iter_mut().for_each(encode_loose_file_uris),
|
||||
Value::Object(map) => {
|
||||
for (key, value) in map.iter_mut() {
|
||||
match value {
|
||||
Value::String(s) if URI_FIELDS.contains(&key.as_str()) => {
|
||||
if let Some(encoded) = encode_loose(s) {
|
||||
*s = encoded;
|
||||
}
|
||||
}
|
||||
Value::Object(changes) if key == "changes" => {
|
||||
if changes.keys().any(|k| encode_loose(k).is_some()) {
|
||||
*changes = std::mem::take(changes)
|
||||
.into_iter()
|
||||
.map(|(k, v)| (encode_loose(&k).unwrap_or(k), v))
|
||||
.collect();
|
||||
}
|
||||
changes.values_mut().for_each(encode_loose_file_uris);
|
||||
}
|
||||
_ => encode_loose_file_uris(value),
|
||||
}
|
||||
if map.keys().any(|k| encode_loose(k).is_some()) {
|
||||
*map = std::mem::take(map).into_iter().map(|(k, v)| (encode_loose(&k).unwrap_or(k), v)).collect();
|
||||
}
|
||||
map.values_mut().for_each(encode_loose_file_uris);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -176,28 +161,9 @@ mod tests {
|
||||
assert!(v["edit"]["changes"].get("file:///tmp/%E7%9B%AE%E5%BD%95/b.java").is_some());
|
||||
assert_eq!(v["text"], "项目", "only file: URIs change");
|
||||
// Already encoded: untouched.
|
||||
let mut encoded = serde_json::json!({ "uri": "file:///a%20b/%E9%A1%B9.java" });
|
||||
let mut encoded = serde_json::json!("file:///a%20b/%E9%A1%B9.java");
|
||||
encode_loose_file_uris(&mut encoded);
|
||||
assert_eq!(encoded["uri"], "file:///a%20b/%E9%A1%B9.java");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn text_that_starts_with_file_is_not_a_uri() {
|
||||
// A YAML formatting edit and a completion whose text begins with `file:`.
|
||||
let mut v = serde_json::json!({ "result": [
|
||||
{ "range": { "start": { "line": 0, "character": 0 }, "end": { "line": 1, "character": 0 } }, "newText": "file: a b\n - c\n" },
|
||||
{ "label": "file:", "insertText": "file: ${1:path}", "documentation": "file: the input" }
|
||||
], "edit": { "changes": { "file:///tmp/a b.yaml": [{ "newText": "file: x y" }] } } });
|
||||
encode_loose_file_uris(&mut v);
|
||||
assert_eq!(v["result"][0]["newText"], "file: a b\n - c\n");
|
||||
assert_eq!(v["result"][1]["insertText"], "file: ${1:path}");
|
||||
assert_eq!(v["result"][1]["documentation"], "file: the input");
|
||||
let changes = &v["edit"]["changes"]["file:///tmp/a%20b.yaml"];
|
||||
assert_eq!(changes[0]["newText"], "file: x y");
|
||||
// A diagnostic's help link is a URI too.
|
||||
let mut d = serde_json::json!({ "codeDescription": { "href": "file:///tmp/help files/rule.html" } });
|
||||
encode_loose_file_uris(&mut d);
|
||||
assert_eq!(d["codeDescription"]["href"], "file:///tmp/help%20files/rule.html");
|
||||
assert_eq!(encoded, "file:///a%20b/%E9%A1%B9.java");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
||||
@@ -1136,10 +1136,7 @@ pub(crate) fn stash_push(
|
||||
paths: &[PathBuf],
|
||||
) -> IdeResult<()> {
|
||||
let rel = r.rel_paths(paths)?;
|
||||
// Literal pathspecs only for the chosen files: git's whole-tree stash passes itself `:/`,
|
||||
// which a literal pathspec turns into a file of that name.
|
||||
let mut args = if rel.is_empty() { vec![] } else { vec!["--literal-pathspecs"] };
|
||||
args.extend(["stash", "push", "-q"]);
|
||||
let mut args = vec!["--literal-pathspecs", "stash", "push", "-q"];
|
||||
if include_untracked {
|
||||
args.push("--include-untracked");
|
||||
}
|
||||
|
||||
@@ -769,11 +769,11 @@ fn stash_push_list_apply_pop() {
|
||||
let repo = fx.repo();
|
||||
|
||||
fx.write("s.txt", "change 1\n");
|
||||
repo.stash_push(Some("first stash"), false, false, &[]).unwrap();
|
||||
repo.stash_push(Some("first stash"), false, false).unwrap();
|
||||
assert_eq!(fx.read("s.txt"), "base\n");
|
||||
fx.write("s.txt", "change 2\n");
|
||||
fx.write("u.txt", "untracked\n");
|
||||
repo.stash_push(None, true, false, &[]).unwrap();
|
||||
repo.stash_push(None, true, false).unwrap();
|
||||
assert!(!fx.path("u.txt").exists());
|
||||
|
||||
let stashes = repo.stashes().unwrap();
|
||||
@@ -808,7 +808,7 @@ fn stash_keep_index_reinstate_index_and_branch() {
|
||||
fx.write("a.txt", "a staged\n");
|
||||
fx.git(&["add", "a.txt"]);
|
||||
fx.write("b.txt", "b unstaged\n");
|
||||
repo.stash_push(Some("keep"), false, true, &[]).unwrap();
|
||||
repo.stash_push(Some("keep"), false, true).unwrap();
|
||||
// Keep index: the staged change stays, the unstaged one is stashed.
|
||||
assert_eq!(fx.read("a.txt"), "a staged\n");
|
||||
assert_eq!(fx.read("b.txt"), "b\n");
|
||||
|
||||
@@ -75,7 +75,7 @@ Pick **VS Code (macOS)** or **VS Code (Windows)** as the keymap; then `⇧⌘P`
|
||||
| Extensions | **Settings › Plugins** |
|
||||
| `settings.json` | **Settings** (`⌘,` / `Ctrl+Alt+S`), stored in `settings.toml`; per-project values in `.openidea/settings.toml` |
|
||||
| `launch.json` | Run configurations: **Import Run Configurations from .vscode/launch.json** |
|
||||
| Multi-root workspace | **File › New › Workspace…** and **Attach Project…** |
|
||||
| Multi-root workspace | **File › New Workspace…** and **Attach Project…** |
|
||||
|
||||
`.editorconfig` files are applied. VS Code settings and extensions are not imported.
|
||||
|
||||
@@ -84,7 +84,7 @@ Pick **VS Code (macOS)** or **VS Code (Windows)** as the keymap; then `⇧⌘P`
|
||||
Pick **Eclipse (macOS)** or **Eclipse** as the keymap.
|
||||
|
||||
- **Formatter.** To keep using an Eclipse formatter profile for Java, open **Settings › Editor › Code Style › Java**, set **Formatting profile** to **Custom Eclipse formatter XML** and choose the exported XML file.
|
||||
- **Workspaces and projects.** Eclipse opens many projects in one workspace. OpenIDEA opens one project per window; to work on several folders together, create a workspace with **File › New › Workspace…** or add folders with **Attach Project…**.
|
||||
- **Workspaces and projects.** Eclipse opens many projects in one workspace. OpenIDEA opens one project per window; to work on several folders together, create a workspace with **File › New Workspace…** or add folders with **Attach Project…**.
|
||||
- **Perspectives.** OpenIDEA has no perspectives. Arrange tool windows the way you like and save the arrangement with **Window › Tool Window Layouts › Save Current Layout as…**.
|
||||
|
||||
## Concepts at a glance
|
||||
|
||||
@@ -13,7 +13,7 @@ A scratch file is a throwaway file in any language: a place to try a snippet, ke
|
||||
|
||||
<Steps>
|
||||
<Step title="Create one">
|
||||
Choose **File › New › Scratch File** (or **Scratch File** at the top of the Project view's **New** menu).
|
||||
Choose **File › New Scratch File…** (or **Scratch File** at the top of the Project view's **New** menu).
|
||||
</Step>
|
||||
<Step title="Pick a language">
|
||||
Type to filter the language list and press `↵` / `Enter`.
|
||||
|
||||
@@ -73,7 +73,7 @@ The page also has **Expand abbreviations with Tab** and **Show live templates in
|
||||
|
||||
Live templates, postfix settings and macros are stored per user on this machine, not in the project.
|
||||
|
||||
For new-file templates (what **File › New › File…** creates), see **Settings › Editor › File and Code Templates**.
|
||||
For new-file templates (what **File › New…** creates), see **Settings › Editor › File and Code Templates**.
|
||||
|
||||
## Macros
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ This page covers how a plugin works with files:
|
||||
projects.
|
||||
- **Other files** (`fs.wit`, API 1.3): files outside the projects, under explicit grants,
|
||||
and the plugin's own private directory.
|
||||
- **File templates**: entries of the **File › New › File…** menu, no code needed.
|
||||
- **File templates**: entries of the **File › New…** menu, no code needed.
|
||||
|
||||
## File actions
|
||||
|
||||
@@ -180,7 +180,7 @@ as an argument to an approved process.
|
||||
|
||||
## File templates
|
||||
|
||||
`[[contributes.fileTemplates]]` adds entries to the **File › New › File…** menu. They need no code and grant
|
||||
`[[contributes.fileTemplates]]` adds entries to the **File › New…** menu. They need no code and grant
|
||||
no file access: files are created only when the user invokes a template, through the IDE's
|
||||
normal New File flow.
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ Vim 模式会读取 `~/.ideavimrc`(或 `~/.openideavimrc`)。通过 **工具
|
||||
| 扩展 | **设置 › 插件** |
|
||||
| `settings.json` | **设置**(`⌘,` / `Ctrl+Alt+S`),保存在 `settings.toml`;项目级的值保存在 `.openidea/settings.toml` |
|
||||
| `launch.json` | 运行配置:**从 .vscode/launch.json 导入运行配置** |
|
||||
| 多根工作区 | **文件 › 新建 › 工作区…** 和 **附加项目…** |
|
||||
| 多根工作区 | **文件 › 新建工作区…** 和 **附加项目…** |
|
||||
|
||||
项目中的 `.editorconfig` 会生效。VS Code 的设置和扩展不会导入。
|
||||
|
||||
@@ -84,7 +84,7 @@ Vim 模式会读取 `~/.ideavimrc`(或 `~/.openideavimrc`)。通过 **工具
|
||||
把快捷键方案切换为 **Eclipse (macOS)** 或 **Eclipse**。
|
||||
|
||||
- **格式化器。** 想继续用 Eclipse 的 Java 格式化配置,打开 **设置 › 编辑器 › 代码样式 › Java**,把 **格式化方案** 设为 **自定义 Eclipse 格式化 XML**,然后选择导出的 XML 文件。
|
||||
- **工作空间与项目。** Eclipse 在一个工作空间里打开多个项目;OpenIDEA 每个窗口打开一个项目。需要同时处理多个文件夹时,用 **文件 › 新建 › 工作区…** 创建工作区,或用 **附加项目…** 添加文件夹。
|
||||
- **工作空间与项目。** Eclipse 在一个工作空间里打开多个项目;OpenIDEA 每个窗口打开一个项目。需要同时处理多个文件夹时,用 **文件 › 新建工作区…** 创建工作区,或用 **附加项目…** 添加文件夹。
|
||||
- **透视图。** OpenIDEA 没有透视图。按自己的习惯摆放工具窗口,再用 **窗口 › 工具窗口布局 › 将当前布局另存为…** 保存。
|
||||
|
||||
## 概念对照
|
||||
|
||||
@@ -13,7 +13,7 @@ description: "在项目之外保留临时文件,并在 TODO 工具窗口中汇
|
||||
|
||||
<Steps>
|
||||
<Step title="新建">
|
||||
选择 **文件 › 新建 › 临时文件**(或项目视图 **新建** 菜单最上面的 **临时文件**)。
|
||||
选择 **文件 › 新建临时文件…**(或项目视图 **新建** 菜单最上面的 **临时文件**)。
|
||||
</Step>
|
||||
<Step title="选择语言">
|
||||
输入文字过滤语言列表,按 `↵` / `Enter` 确认。
|
||||
|
||||
@@ -67,7 +67,7 @@ items.for → for (var item : items) { … }
|
||||
|
||||
实时模板、后缀补全设置和宏都按用户保存在本机,不保存在项目里。
|
||||
|
||||
新建文件用的模板(**文件 › 新建 › 文件…** 创建的内容)在 **设置 › 编辑器 › 文件和代码模板** 中设置。
|
||||
新建文件用的模板(**文件 › 新建…** 创建的内容)在 **设置 › 编辑器 › 文件和代码模板** 中设置。
|
||||
|
||||
## 宏
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ description: "创建、重命名或删除文件的快速修复,读写项目文
|
||||
- **文件操作**(`file-actions.wit`,API 1.3):创建、重命名或删除文件的快速修复和重构,作为一次可撤销的工作区编辑应用。
|
||||
- **项目文件**(`workspace.wit`):读取、写入、查找和搜索打开项目中的文件。
|
||||
- **其他文件**(`fs.wit`,API 1.3):在明确授权下访问项目之外的文件,以及插件自己的私有目录。
|
||||
- **文件模板**:**文件 › 新建 › 文件…** 菜单中的条目,不需要代码。
|
||||
- **文件模板**:**文件 › 新建…** 菜单中的条目,不需要代码。
|
||||
|
||||
## 文件操作
|
||||
|
||||
@@ -162,7 +162,7 @@ fs::write_file("~/.config/mytool/state.json", "{}")?;
|
||||
|
||||
## 文件模板
|
||||
|
||||
`[[contributes.fileTemplates]]` 在 **文件 › 新建 › 文件…** 菜单中添加条目。不需要代码,也不授予任何文件访问权限:
|
||||
`[[contributes.fileTemplates]]` 在 **文件 › 新建…** 菜单中添加条目。不需要代码,也不授予任何文件访问权限:
|
||||
只有用户调用模板时,才通过 IDE 正常的新建文件流程创建文件。
|
||||
|
||||
```toml
|
||||
|
||||
@@ -19,9 +19,9 @@ test("an unresolved module gets a startup timeout", async ({ page }) => {
|
||||
);
|
||||
await page.goto("/", { waitUntil: "commit" });
|
||||
await page.locator("#splash").waitFor({ state: "attached" });
|
||||
await page.clock.runFor(60_000);
|
||||
await page.clock.runFor(30_000);
|
||||
await expect(page.getByRole("textbox", { name: "Startup error details" })).toHaveValue(
|
||||
/Startup did not finish within 60 seconds/,
|
||||
/Startup did not finish within 30 seconds/,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@ test("a slow module load succeeds before the deadline and cancels the startup ti
|
||||
await expect(page.locator("#root")).not.toBeEmpty();
|
||||
await page.clock.runFor(4000);
|
||||
await expect(page.locator("#splash")).toHaveCount(0);
|
||||
await page.clock.runFor(50_000);
|
||||
await page.clock.runFor(35_000);
|
||||
await expect(page.locator("#boot-error")).toHaveCount(0);
|
||||
expect(await page.evaluate(() => sessionStorage.getItem("boot-error-seen"))).toBeNull();
|
||||
});
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "openidea",
|
||||
"private": true,
|
||||
"description": "An open-source IDE inspired by IntelliJ IDEA",
|
||||
"version": "0.1.45",
|
||||
"version": "0.1.44",
|
||||
"license": "Apache-2.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
copied: "已复制",
|
||||
manual: "无法复制。请选择下方详情并手动复制。",
|
||||
details: "启动错误详情",
|
||||
timeout: "启动未在 60 秒内完成。",
|
||||
timeout: "启动未在 30 秒内完成。",
|
||||
outdatedMac:
|
||||
"这台 Mac 的系统网页引擎过旧:OpenIDEA 的界面运行在 macOS 自带的 WebKit 引擎上,需要 macOS 13 Ventura 或更高版本。在 macOS 11、12 上更新 Safari 不会更新其他应用使用的引擎,需要升级 macOS。",
|
||||
outdated:
|
||||
@@ -25,7 +25,7 @@
|
||||
copied: "Copied",
|
||||
manual: "Could not copy. Select the details below and copy them.",
|
||||
details: "Startup error details",
|
||||
timeout: "Startup did not finish within 60 seconds.",
|
||||
timeout: "Startup did not finish within 30 seconds.",
|
||||
outdatedMac:
|
||||
"The system web engine on this Mac is too old: OpenIDEA's interface runs on macOS's built-in WebKit and needs macOS 13 Ventura or later. On macOS 11 and 12 a Safari update doesn't update the engine other apps use, so macOS itself needs upgrading.",
|
||||
outdated:
|
||||
@@ -146,7 +146,7 @@
|
||||
};
|
||||
// The timeout counts only while the window shows: a hidden or covered window gets no
|
||||
// animation frames, and the splash waits for those to finish startup.
|
||||
let remaining = 60_000;
|
||||
let remaining = 30_000;
|
||||
let armedAt = 0;
|
||||
let timer;
|
||||
const arm = () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// The commit being prepared in the window the current command or event came
|
||||
/// from (the Commit tool window, or the Commit dialog while it is open): the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Plugin-owned project data sources. Requires database.sources and project trust.
|
||||
/// Runs on the Database subsystem's host, including on remote project servers.
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Editor and project-tree decorations (API 1.4). Requires project.read. An editor set
|
||||
/// follows its file: the file's own project, or the nearest one when it is outside them all.
|
||||
/// Tree sets are rooted in an open project. Sets belong to the plugin and disappear when it stops.
|
||||
/// Project-scoped decorations (API 1.4). Requires project.read; paths must be inside
|
||||
/// an open project. Sets belong to the plugin and disappear when it stops.
|
||||
/// Styles: highlight, search, added, modified, removed, warning, error, info,
|
||||
/// typo, weak, underline, strikethrough, muted. Unknown styles are ignored. Theme tokens only.
|
||||
/// underline, strikethrough, muted. Unknown styles are ignored. Theme tokens only.
|
||||
interface decorations {
|
||||
use types.{error, range};
|
||||
/// An editor annotation; after is plain text shown after the range.
|
||||
@@ -23,9 +22,4 @@ interface decorations {
|
||||
/// Replace this set's tree annotation for a file with a note shown after its name (API 1.7):
|
||||
/// one line of at most 200 characters, with an optional tooltip.
|
||||
set-file-note: func(path: string, set-id: string, note: string, tooltip: option<string>) -> result<_, error>;
|
||||
/// Replace this set's tree icon for a file or folder with an id declared under
|
||||
/// `[[contributes.fileIcons]]` (API 1.8), with an optional tooltip.
|
||||
set-file-icon: func(path: string, set-id: string, icon: string, tooltip: option<string>) -> result<_, error>;
|
||||
/// Replace all `(path, icon)` entries of a tree set at once (API 1.8; at most 10,000 entries).
|
||||
set-file-icons: func(set-id: string, items: list<tuple<string, string>>) -> result<_, error>;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// What the pane beside the Services tree shows for a plugin's node.
|
||||
interface detail-types {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Optional export (world `plugin-diagnostics`): problems in the current,
|
||||
/// possibly unsaved document, for the languages declared with the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// HTTP endpoints found in a project (`[[contributes.endpoints]]`).
|
||||
interface endpoints-provider {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Workbench events, delivered in batches to `event-handler.handle`.
|
||||
interface events {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
interface lifecycle {
|
||||
use types.{context, error};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// What other plugins contributed to the extension points this plugin declares
|
||||
/// (`[[extension-points]]` in `plugin.toml`; the contributors list this plugin
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Optional export (world `plugin-file-actions`): quick fixes and
|
||||
/// refactorings that create, rename or delete files, next to the text edits
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Files outside the open projects: the configuration of the program a
|
||||
/// plugin integrates with, a tool installed elsewhere, a licence file.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Writes to the IDE log, tagged with the plugin id.
|
||||
interface log {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Optional export (world `plugin-hover`): Markdown added to the hover of
|
||||
/// documents of the languages declared with the `hover` provider kind,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Cross-file associations a plugin publishes for the files it declares under
|
||||
/// `[[contributes.documentIndexers]]`. The host calls `index` in cancellable
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Embedded languages. The host routes plugin providers and configured language
|
||||
/// servers inside these ranges, preserving host-document UTF-16 coordinates.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Optional export (world `plugin-inlay-hints`): inline hints in documents of
|
||||
/// the languages declared with the `inlay-hints` provider kind, including
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Problems in files, shown in the editor and the Problems view.
|
||||
interface diagnostics {
|
||||
use types.{error, range, location};
|
||||
/// Problems one producer reported for a file, wherever the file is: the host records every
|
||||
/// diagnostics event it emits, so this follows the file, not the invoking window.
|
||||
/// Problems reported by a source for a file in this window's project.
|
||||
record file-problems { path: string, source: string, diagnostics: list<diagnostic> }
|
||||
/// The diagnostics the host recorded, one entry per producer, optionally
|
||||
/// filtered to a file: language servers, builds, spelling and plugin
|
||||
/// providers alike, whatever window or project opened the file.
|
||||
/// Current Problems view snapshot, optionally filtered to a project file.
|
||||
/// Requires project.read and an invoking window. Empty for remote projects.
|
||||
problems: func(path: option<string>) -> result<list<file-problems>, error>;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Additional language features, called only for declared API 1.4 provider kinds.
|
||||
/// Editor calls have a 50 ms soft / 500 ms hard budget; formatting has 5 seconds.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Discovery of the IDE's built-in MCP server; never exposes its URL or token.
|
||||
interface mcp {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/// `fs` and `workspace`, and everything else goes through the imports below,
|
||||
/// gated by the capabilities granted in `plugin.toml` (a missing one returns
|
||||
/// `error::denied`).
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
world plugin {
|
||||
import log;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Editor features a plugin provides for the languages it declares under
|
||||
/// `[[contributes.providers]]` (the host calls only declared kinds). They run
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Project-scoped targets owned by the registering plugin (API 1.4).
|
||||
interface run-targets {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Launches this plugin's configurations in the invoking window's Run tool window.
|
||||
interface run {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Optional export (world `plugin-semantic-tokens`): semantic colouring of
|
||||
/// documents of the languages declared with the `semantic-tokens` provider
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Shared types. Positions are 0-based lines and UTF-16 code unit columns,
|
||||
/// as in the editor and LSP.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
/// Declarative views: tool windows declared
|
||||
/// under `[[contributes.views]]` and custom editors under
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package openidea:plugin@1.8.0;
|
||||
package openidea:plugin@1.7.0;
|
||||
|
||||
interface workspace {
|
||||
use types.{error, location};
|
||||
@@ -135,9 +135,7 @@ interface editor {
|
||||
|
||||
/// Applies versioned edits to an open project document from a background
|
||||
/// event. The path is project-relative and requires `project.read` and
|
||||
/// `editor.write`. The host refuses VCS/IDE control directories and every
|
||||
/// symlink, junction or reparse-point component before it finds the open
|
||||
/// document. Stale versions are rejected without changing text.
|
||||
/// `editor.write`. Stale versions are rejected without changing text.
|
||||
/// These background edits are non-undoable and are not re-emitted as
|
||||
/// `document-changed` events.
|
||||
apply-edits-at: func(project: borrow<project>, path: string, version: u64, edits: list<text-edit>) -> result<u64, error>;
|
||||
|
||||
@@ -65,9 +65,8 @@ pub fn apply(state: &AppState) {
|
||||
}
|
||||
// Another address, port or token: clients connect anew.
|
||||
if let Some(running) = server.take() {
|
||||
let held = (running.address(), running.port());
|
||||
running.stop();
|
||||
if let Some(port) = port_to_wait_for(held, wanted.port) {
|
||||
if let Some(port) = wanted.port {
|
||||
wait_until_free(address, port);
|
||||
}
|
||||
}
|
||||
@@ -105,14 +104,6 @@ pub fn apply(state: &AppState) {
|
||||
}
|
||||
}
|
||||
|
||||
/// The port a restart listening on `wanted` waits for after stopping the server that listened
|
||||
/// on `held`: only its own, at any address (`127.0.0.1` and `0.0.0.0` overlap). A port another
|
||||
/// program holds (the run fell back to a free one) stays taken, and waiting for it would block
|
||||
/// the window.
|
||||
fn port_to_wait_for(held: (IpAddr, u16), wanted: Option<u16>) -> Option<u16> {
|
||||
wanted.filter(|port| held.1 == *port)
|
||||
}
|
||||
|
||||
/// Waits briefly for a stopped server's port to close, so the restart gets it again.
|
||||
fn wait_until_free(address: IpAddr, port: u16) {
|
||||
for _ in 0..100 {
|
||||
@@ -252,21 +243,3 @@ pub fn mcp_respond(
|
||||
) -> IdeResult<()> {
|
||||
state.host.mcp_requests.answer(window.label(), id, allow, error)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::net::Ipv4Addr;
|
||||
|
||||
#[test]
|
||||
fn a_restart_waits_only_for_the_port_the_stopped_server_held() {
|
||||
let local = IpAddr::V4(Ipv4Addr::LOCALHOST);
|
||||
let any = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
assert_eq!(port_to_wait_for((local, 64342), Some(64342)), Some(64342));
|
||||
// Another address on the same port overlaps the old listener: wait for it too.
|
||||
assert_eq!(port_to_wait_for((any, 64342), Some(64342)), Some(64342));
|
||||
// The fixed port was taken by another program: the server ran on a free one.
|
||||
assert_eq!(port_to_wait_for((local, 51234), Some(64342)), None);
|
||||
assert_eq!(port_to_wait_for((local, 64342), None), None);
|
||||
}
|
||||
}
|
||||
@@ -217,18 +217,14 @@ pub fn spec(os: Os) -> Vec<Entry> {
|
||||
}
|
||||
|
||||
let mut file = vec![
|
||||
sub(
|
||||
"new",
|
||||
"New",
|
||||
vec![
|
||||
act("file.newProject", "Project…"),
|
||||
act("workspace.create", "Workspace…"),
|
||||
SEP,
|
||||
act("file.new", "File…"),
|
||||
act("file.newScratchFile", "Scratch File"),
|
||||
],
|
||||
),
|
||||
act("file.newProject", "New Project…"),
|
||||
act("workspace.create", "New Workspace…"),
|
||||
act("workspace.open", "Open Workspace…"),
|
||||
act("workspace.manage", "Manage Workspace…"),
|
||||
act("file.new", "New…"),
|
||||
act("file.newScratchFile", "New Scratch File…"),
|
||||
act("file.openProject", "Open…"),
|
||||
act("project.attach", "Attach Project…"),
|
||||
act("file.openFile", "Open File…"),
|
||||
act("file.openInNewWindow", "Open in New Window…"),
|
||||
sub(
|
||||
@@ -236,11 +232,6 @@ pub fn spec(os: Os) -> Vec<Entry> {
|
||||
"Open Recent",
|
||||
vec![Entry::RecentProjects, SEP, act("welcome.recentProjects", "Manage Projects…")],
|
||||
),
|
||||
act("project.attach", "Attach Project…"),
|
||||
SEP,
|
||||
act("workspace.open", "Open Workspace…"),
|
||||
act("workspace.manage", "Manage Workspace…"),
|
||||
SEP,
|
||||
act("file.closeProject", "Close Project"),
|
||||
act("file.renameProject", "Rename Project…"),
|
||||
SEP,
|
||||
@@ -1621,7 +1612,7 @@ pub fn install<R: Runtime>(app: &AppHandle<R>, menu_state: &MenuState, recent: &
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::collections::{BTreeSet, HashSet};
|
||||
use std::collections::HashSet;
|
||||
|
||||
const ALL_OS: [Os; 3] = [Os::Mac, Os::Windows, Os::Linux];
|
||||
|
||||
@@ -1981,56 +1972,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_menu_starts_with_a_new_submenu() {
|
||||
for os in ALL_OS {
|
||||
let menus = spec(os);
|
||||
let Some(Entry::Submenu { children: file, .. }) =
|
||||
menus.iter().find(|e| matches!(e, Entry::Submenu { id: "file", .. }))
|
||||
else {
|
||||
panic!("File menu missing on {os:?}")
|
||||
};
|
||||
let Some(Entry::Submenu { id: "new", children: new, .. }) = file.first() else {
|
||||
panic!("File menu does not start with New on {os:?}")
|
||||
};
|
||||
assert_eq!(
|
||||
action_ids(new),
|
||||
["file.newProject", "workspace.create", "file.new", "file.newScratchFile"],
|
||||
"{os:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_menu_item_has_a_catalog_label() {
|
||||
fn walk(entries: &[Entry], out: &mut BTreeSet<&'static str>) {
|
||||
for e in entries {
|
||||
match e {
|
||||
Entry::Submenu { id, children, .. } => {
|
||||
out.insert(id);
|
||||
walk(children, out);
|
||||
}
|
||||
Entry::Action { id, .. } => {
|
||||
out.insert(id);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut ids = BTreeSet::new();
|
||||
for os in ALL_OS {
|
||||
walk(&spec(os), &mut ids);
|
||||
}
|
||||
for (locale, catalog) in [
|
||||
("en", include_str!("../../src/platform/locales/en.json")),
|
||||
("zh", include_str!("../../src/platform/locales/zh.json")),
|
||||
] {
|
||||
let catalog: serde_json::Map<String, serde_json::Value> = serde_json::from_str(catalog).unwrap();
|
||||
let missing: Vec<_> = ids.iter().filter(|id| !catalog.contains_key(&format!("menu.{id}"))).collect();
|
||||
assert!(missing.is_empty(), "{locale}.json lacks menu labels for {missing:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recent_labels_tildify_home() {
|
||||
let recent = vec![ide_workspace::RecentProject {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "OpenIDEA",
|
||||
"version": "0.1.45",
|
||||
"version": "0.1.44",
|
||||
"identifier": "ai.l0ng.openidea",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm dev",
|
||||
|
||||
@@ -1335,10 +1335,7 @@ export class EditorController implements SlotHost {
|
||||
* (`EditorKindContribution.isBusy`): asks before ending what runs in them,
|
||||
* like closing a busy terminal session. Resolves false to keep the tabs.
|
||||
*/
|
||||
private async confirmBusyClose(
|
||||
removal: (s: TabsState) => TabsState,
|
||||
confirmed: Set<string> = new Set(),
|
||||
): Promise<boolean> {
|
||||
private async confirmBusyClose(removal: (s: TabsState) => TabsState): Promise<boolean> {
|
||||
const kinds = useContributions.getState().editorKinds;
|
||||
const current = useTabs.getState();
|
||||
const remaining = openKeys(removal(current));
|
||||
@@ -1346,19 +1343,15 @@ export class EditorController implements SlotHost {
|
||||
for (const pane of Object.values(current.panes))
|
||||
for (const tab of pane.tabs)
|
||||
if (!remaining.has(tab.input.key) && kinds.get(tab.input.kind)?.isBusy) closing.set(tab.input.key, tab.input);
|
||||
// Tabs whose ending was confirmed earlier in this close aren't asked about again.
|
||||
const busy: EditorInput[] = [];
|
||||
for (const input of closing.values())
|
||||
if (!confirmed.has(input.key) && (await inputBusy(input, kinds))) busy.push(input);
|
||||
const busy: string[] = [];
|
||||
for (const input of closing.values()) if (await inputBusy(input, kinds)) busy.push(tabTitle(input, kinds));
|
||||
if (!busy.length) return true;
|
||||
const name = busy.map((input) => tabTitle(input, kinds)).join(", ");
|
||||
const ok = await confirm({
|
||||
const name = busy.join(", ");
|
||||
return confirm({
|
||||
title: t("editor.closeBusy.title", { name }),
|
||||
message: t("editor.closeBusy.message", { name }),
|
||||
ok: t("editor.closeBusy.terminate"),
|
||||
});
|
||||
if (ok) for (const input of busy) confirmed.add(input.key);
|
||||
return ok;
|
||||
}
|
||||
|
||||
/** Close exactly the originally selected tabs, evaluating references after every await. */
|
||||
@@ -1395,8 +1388,6 @@ export class EditorController implements SlotHost {
|
||||
try {
|
||||
const authorized = new Set<string>();
|
||||
const discards = new Map<string, CustomDocument>();
|
||||
const confirmedBusy = new Set<string>();
|
||||
let busyAsked = false;
|
||||
for (;;) {
|
||||
const current = useTabs.getState();
|
||||
const d = closedDocuments(current, currentRemoval(current), useContributions.getState().editorKinds).find(
|
||||
@@ -1406,13 +1397,6 @@ export class EditorController implements SlotHost {
|
||||
// A later Cancel/save failure must not discard earlier documents.
|
||||
const discard = [...discards.values()].find(stillLast);
|
||||
if (!discard) break;
|
||||
// Nor may a Cancel on ending a busy tab's session: ask before discarding anything.
|
||||
if (!busyAsked) {
|
||||
if (!(await this.confirmBusyClose(currentRemoval, confirmedBusy))) return false;
|
||||
if (generation !== this.projectGeneration) return false;
|
||||
busyAsked = true;
|
||||
continue;
|
||||
}
|
||||
discards.delete(discard.input.key);
|
||||
await discard.lifecycle.discard(discard.input);
|
||||
// The await may have changed which documents lose their last tab.
|
||||
@@ -1443,8 +1427,7 @@ export class EditorController implements SlotHost {
|
||||
}
|
||||
authorized.add(d.input.key);
|
||||
}
|
||||
// Again after the discards: a tab may have become busy while they ran.
|
||||
if (!(await this.confirmBusyClose(currentRemoval, confirmedBusy))) return false;
|
||||
if (!(await this.confirmBusyClose(currentRemoval))) return false;
|
||||
if (generation !== this.projectGeneration) return false;
|
||||
if (options.beforeRemove && !(await options.beforeRemove())) return false;
|
||||
// Commit only the original target ids against the latest tab state.
|
||||
|
||||
@@ -4,7 +4,7 @@ import { createMemoryBackend } from "./backend";
|
||||
import { findTab, initialTabsState, paneIds } from "./model/tabs";
|
||||
import { useDocMeta } from "./model/document";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { ask, confirm } from "@/workbench/messages";
|
||||
import { ask } from "@/workbench/messages";
|
||||
import type * as Messages from "@/workbench/messages";
|
||||
import * as virtualDocs from "@/platform/virtualDocs";
|
||||
import type { VirtualDocument } from "@/platform/ipc";
|
||||
@@ -18,7 +18,6 @@ import {
|
||||
vi.mock("@/workbench/messages", async (original) => ({
|
||||
...(await original<typeof Messages>()),
|
||||
ask: vi.fn(),
|
||||
confirm: vi.fn(),
|
||||
}));
|
||||
|
||||
class TestDocument implements EditorDocumentLifecycle {
|
||||
@@ -249,57 +248,6 @@ describe("custom editor document lifetime", () => {
|
||||
expect(findTab(useTabs.getState(), input().key)).toBeNull();
|
||||
});
|
||||
|
||||
it("keeps discarded changes when ending a busy tab's session is cancelled", async () => {
|
||||
const busy = registerEditorKind({
|
||||
kind: "busy-test",
|
||||
component: () => null,
|
||||
title: (i) => i.key,
|
||||
isBusy: () => true,
|
||||
});
|
||||
try {
|
||||
const doc = await open();
|
||||
await ctrl.openInput({ kind: "busy-test", key: "busy:1" }, { focus: false });
|
||||
vi.mocked(ask).mockResolvedValue({ button: "discard", checked: false });
|
||||
vi.mocked(confirm).mockResolvedValue(false);
|
||||
const pane = useTabs.getState().activePane;
|
||||
expect(await ctrl.closeAll(pane)).toBe(false);
|
||||
expect(confirm).toHaveBeenCalledOnce();
|
||||
expect(doc.text).toBe("edited");
|
||||
expect(useTabs.getState().panes[pane]!.tabs.map((tab) => tab.input.key)).toEqual(["custom:a", "busy:1"]);
|
||||
} finally {
|
||||
busy();
|
||||
vi.mocked(confirm).mockReset();
|
||||
}
|
||||
});
|
||||
|
||||
it("asks about a tab that becomes busy while changes are discarded", async () => {
|
||||
let busyNow = false;
|
||||
const busy = registerEditorKind({
|
||||
kind: "busy-test",
|
||||
component: () => null,
|
||||
title: (i) => i.key,
|
||||
isBusy: () => busyNow,
|
||||
});
|
||||
try {
|
||||
const doc = await open();
|
||||
doc.discard = async () => {
|
||||
busyNow = true;
|
||||
doc.pending = "";
|
||||
doc.text = doc.saved;
|
||||
};
|
||||
await ctrl.openInput({ kind: "busy-test", key: "busy:1" }, { focus: false });
|
||||
vi.mocked(ask).mockResolvedValue({ button: "discard", checked: false });
|
||||
vi.mocked(confirm).mockResolvedValue(false);
|
||||
const pane = useTabs.getState().activePane;
|
||||
expect(await ctrl.closeAll(pane)).toBe(false);
|
||||
expect(confirm).toHaveBeenCalledOnce();
|
||||
expect(useTabs.getState().panes[pane]!.tabs.map((tab) => tab.input.key)).toContain("busy:1");
|
||||
} finally {
|
||||
busy();
|
||||
vi.mocked(confirm).mockReset();
|
||||
}
|
||||
});
|
||||
|
||||
it("discards without a removal-triggered autosave", async () => {
|
||||
const doc = await open();
|
||||
useProject.setState({ settings: { files: { autoSave: true } } as never });
|
||||
|
||||
@@ -438,10 +438,7 @@
|
||||
.suggestion:focus-visible {
|
||||
outline: 2px solid var(--focus-ring);
|
||||
}
|
||||
/* The file name truncates first; the hint stays on one line. */
|
||||
.suggestionHint {
|
||||
flex: none;
|
||||
white-space: nowrap;
|
||||
color: var(--fg-faint);
|
||||
}
|
||||
.removeChip {
|
||||
@@ -461,7 +458,6 @@
|
||||
color: var(--fg-strong);
|
||||
}
|
||||
.attachmentName {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
|
||||
@@ -88,16 +88,3 @@
|
||||
max-width: 45%;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.notes {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
height: 0;
|
||||
}
|
||||
.docked .notes {
|
||||
height: auto;
|
||||
}
|
||||
.docked .notes:empty {
|
||||
display: none;
|
||||
}
|
||||
@@ -221,29 +221,26 @@ export function HomeEditor({ docked = false }: { docked?: boolean; input?: Edito
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{/* Notes under the box don't take part in centring, so the box stays put as they come and go. */}
|
||||
<div className={styles.notes}>
|
||||
{probe && (!docked || probe.error) && (
|
||||
<p className={probe.error ? styles.warning : styles.note}>
|
||||
{probe.error
|
||||
? txTemplate(`${provider?.name ?? probe.provider} didn't start: ${probe.error}`)
|
||||
: [probe.name, probe.version, probe.protocol].filter(Boolean).join(" · ")}
|
||||
</p>
|
||||
)}
|
||||
{(error || (provider && !provider.installed) || (provider && !provider.config.length)) && (
|
||||
<p
|
||||
className={error || !provider?.installed ? styles.warning : styles.note}
|
||||
role={error ? "alert" : undefined}
|
||||
>
|
||||
{error ??
|
||||
(provider && !provider.installed ? (
|
||||
txTemplate(`${provider.command} was not found on PATH`)
|
||||
) : (
|
||||
<T>Models and modes appear after this agent's first task.</T>
|
||||
))}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{probe && (!docked || probe.error) && (
|
||||
<p className={probe.error ? styles.warning : styles.note}>
|
||||
{probe.error
|
||||
? txTemplate(`${provider?.name ?? probe.provider} didn't start: ${probe.error}`)
|
||||
: [probe.name, probe.version, probe.protocol].filter(Boolean).join(" · ")}
|
||||
</p>
|
||||
)}
|
||||
{(error || (provider && !provider.installed) || (provider && !provider.config.length)) && (
|
||||
<p
|
||||
className={error || !provider?.installed ? styles.warning : styles.note}
|
||||
role={error ? "alert" : undefined}
|
||||
>
|
||||
{error ??
|
||||
(provider && !provider.installed ? (
|
||||
txTemplate(`${provider.command} was not found on PATH`)
|
||||
) : (
|
||||
<T>Models and modes appear after this agent's first task.</T>
|
||||
))}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -43,27 +43,6 @@
|
||||
color: var(--fg-muted);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
/* In the composer: a × at the end removes the reference, as on the attached blocks. */
|
||||
.removable {
|
||||
padding-right: 2px;
|
||||
}
|
||||
.chipRemove {
|
||||
display: grid;
|
||||
flex: none;
|
||||
place-items: center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: var(--radius-small);
|
||||
background: none;
|
||||
color: var(--fg-muted);
|
||||
cursor: pointer;
|
||||
}
|
||||
.chipRemove:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--fg-strong);
|
||||
}
|
||||
/* The file is gone (renamed or deleted since it was referenced). */
|
||||
.missing {
|
||||
color: var(--fg-muted);
|
||||
|
||||
@@ -55,8 +55,8 @@ export function openReference(path: string, mention: Mention) {
|
||||
const nameOf = (m: Mention) => basename(m.rel.replace(/\/$/, "")) || m.rel;
|
||||
const iconOf = (m: Mention) => (m.dir ? "folder" : fileIconName(nameOf(m), m.rel));
|
||||
|
||||
/** The chip as DOM, for the composer's editor; `onRemove` adds its × button. */
|
||||
export function chipElement(path: string, mention: Mention, onRemove?: () => void): HTMLElement {
|
||||
/** The chip as DOM, for the composer's editor. */
|
||||
export function chipElement(path: string, mention: Mention): HTMLElement {
|
||||
const chip = document.createElement("span");
|
||||
chip.className = styles.chip!;
|
||||
chip.dataset.refPath = path;
|
||||
@@ -74,20 +74,6 @@ export function chipElement(path: string, mention: Mention, onRemove?: () => voi
|
||||
lines.textContent = linesLabel(mention.lines);
|
||||
chip.append(lines);
|
||||
}
|
||||
if (onRemove) {
|
||||
chip.classList.add(styles.removable!);
|
||||
const remove = document.createElement("button");
|
||||
remove.type = "button";
|
||||
remove.className = styles.chipRemove!;
|
||||
remove.setAttribute("aria-label", tx("Remove"));
|
||||
remove.append(iconNode("close", 10));
|
||||
remove.addEventListener("mousedown", (e) => e.preventDefault());
|
||||
remove.addEventListener("click", (e) => {
|
||||
e.stopPropagation();
|
||||
onRemove();
|
||||
});
|
||||
chip.append(remove);
|
||||
}
|
||||
if (!mention.dir)
|
||||
void fileExists(path).then((exists) => {
|
||||
if (!exists) chip.classList.add(styles.missing!);
|
||||
|
||||
@@ -41,11 +41,9 @@
|
||||
/* The task's state and its terminal and changes, just above the composer. */
|
||||
.statusBar {
|
||||
display: flex;
|
||||
/* What doesn't fit moves to the next line whole, instead of every fact shrinking to a letter. */
|
||||
flex-wrap: wrap;
|
||||
/* The changes chip sits above the line; the facts stay on that line's baseline. */
|
||||
align-items: flex-end;
|
||||
gap: 2px 6px;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
padding: 0 2px;
|
||||
overflow: hidden;
|
||||
@@ -56,7 +54,6 @@
|
||||
.agent {
|
||||
display: inline-flex;
|
||||
flex: 0 1 auto;
|
||||
max-width: 100%;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
height: 22px;
|
||||
@@ -73,7 +70,6 @@
|
||||
.where {
|
||||
display: inline-flex;
|
||||
flex: 0 1 auto;
|
||||
max-width: 100%;
|
||||
align-items: center;
|
||||
/* The chips' own padding spaces them. */
|
||||
gap: 2px;
|
||||
@@ -91,21 +87,20 @@
|
||||
height: 22px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
/* The rest of the line: the changes at its start, the meter, time and terminal at its end.
|
||||
On a line of its own (a narrow session) the changes line up with the facts above. */
|
||||
/* The changes sit above the meter, time and terminal; those keep their one row at the right. */
|
||||
.statusEnd {
|
||||
display: inline-flex;
|
||||
flex: 1 1 auto;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 2px 8px;
|
||||
flex: 0 1 auto;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
margin-left: auto;
|
||||
}
|
||||
/* Shrinks before the terminal buttons do: in a narrow docked session the meters clip, not the controls. */
|
||||
.statusMeters {
|
||||
display: inline-flex;
|
||||
flex: 0 1 auto;
|
||||
margin-left: auto;
|
||||
align-items: center;
|
||||
height: 22px;
|
||||
gap: 8px;
|
||||
|
||||
@@ -387,7 +387,7 @@ function SessionStatus({
|
||||
<T>{statusLabel(task.status)}</T>
|
||||
{task.status === "limited" && task.resetsMs != null && ` · ${tx`resets ${formatSentAt(task.resetsMs)}`}`}
|
||||
</span>
|
||||
{/* What changed sits before the meter, time and terminal, or above them when the row is full. */}
|
||||
{/* What changed sits above the meter, time and terminal; those keep their one row at the right. */}
|
||||
<span className={styles.statusEnd}>
|
||||
{(!!changes?.length || !!commits.length) && (
|
||||
<span className={styles.statusChips}>
|
||||
|
||||
@@ -79,16 +79,8 @@ class ChipWidget extends WidgetType {
|
||||
eq(other: ChipWidget) {
|
||||
return other.path === this.path && other.text === this.text;
|
||||
}
|
||||
toDOM(view: EditorView) {
|
||||
const chip = chipElement(this.path, this.mention, () => {
|
||||
const from = view.posAtDOM(chip);
|
||||
const at = view.state.field(painted).chips.find((c) => c.from === from);
|
||||
if (!at) return;
|
||||
// The space typed after the reference goes with it.
|
||||
const end = view.state.sliceDoc(at.to, at.to + 1) === " " ? at.to + 1 : at.to;
|
||||
view.dispatch({ changes: { from: at.from, to: end }, userEvent: "delete" });
|
||||
view.focus();
|
||||
});
|
||||
toDOM() {
|
||||
const chip = chipElement(this.path, this.mention);
|
||||
// Keep the editor's focus and caret; a click opens the file.
|
||||
chip.addEventListener("mousedown", (e) => e.preventDefault());
|
||||
chip.addEventListener("click", (e) => {
|
||||
|
||||
@@ -246,6 +246,12 @@
|
||||
margin: 0 4px;
|
||||
background: var(--border);
|
||||
}
|
||||
.treeFilter {
|
||||
flex: 1;
|
||||
min-width: 80px;
|
||||
max-width: 280px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
.treeHost {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
|
||||
@@ -41,6 +41,7 @@ beforeEach(() => {
|
||||
sequences: [],
|
||||
},
|
||||
},
|
||||
treeFilter: "",
|
||||
separateProceduresAndFunctions: false,
|
||||
treeExpanded: new Set(["pg", "pg/public", "pg/public/routines"]),
|
||||
});
|
||||
@@ -59,6 +60,9 @@ describe("routine grouping", () => {
|
||||
expect(tree.queryByText("functions")).toBeNull();
|
||||
fireEvent.mouseDown(tree.getAllByText("calculate")[1]!, { button: 0 });
|
||||
expect(useDatabase.getState().selectedNode?.key).toBe("pg/public/routines/calculate(text)");
|
||||
act(() => useDatabase.setState({ treeFilter: "refresh" }));
|
||||
expect(tree.queryAllByText("calculate")).toHaveLength(0);
|
||||
expect(tree.getByText("refresh_data")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("toggles through the action, persists the option, and restores the old expansion", async () => {
|
||||
@@ -87,7 +91,7 @@ describe("routine grouping", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it.each([false, true])("applies the object filter before grouping (separate: %s)", (separate) => {
|
||||
it.each([false, true])("applies object and quick filters before grouping (separate: %s)", (separate) => {
|
||||
const source = useDatabase.getState().sources[0]!;
|
||||
useDatabase.setState({
|
||||
separateProceduresAndFunctions: separate,
|
||||
@@ -101,6 +105,10 @@ describe("routine grouping", () => {
|
||||
expect(tree.getAllByText("calculate")).toHaveLength(2);
|
||||
const folder = tree.getByText(separate ? "functions" : "routines").closest('[role="treeitem"]')!;
|
||||
expect(within(folder as HTMLElement).getByText("2")).toBeInTheDocument();
|
||||
act(() => useDatabase.setState({ treeFilter: "refresh" }));
|
||||
expect(tree.queryByText("public")).toBeNull();
|
||||
expect(tree.queryByText("routines")).toBeNull();
|
||||
expect(tree.queryByText("functions")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -12,17 +12,25 @@ import { shortcutLabel } from "@/platform/keymap";
|
||||
import {
|
||||
Button,
|
||||
EmptyState,
|
||||
HighlightedText,
|
||||
Icon,
|
||||
IconButton,
|
||||
Menu,
|
||||
SearchField,
|
||||
Tree,
|
||||
showContextMenu,
|
||||
tooltipAttrs,
|
||||
type TreeHandle,
|
||||
T,
|
||||
} from "@/ui";
|
||||
import { databaseKey, passesObjectFilter, shownNames, sourceIcon, splitTarget, targetOf } from "./model";
|
||||
import {
|
||||
databaseKey,
|
||||
passesObjectFilter,
|
||||
passesTreeFilter,
|
||||
shownNames,
|
||||
sourceIcon,
|
||||
splitTarget,
|
||||
targetOf,
|
||||
} from "./model";
|
||||
import {
|
||||
nodeTarget,
|
||||
isOtherFolder,
|
||||
@@ -160,10 +168,25 @@ export function DatabaseView() {
|
||||
[st.sources],
|
||||
);
|
||||
|
||||
/** Schemas tab › Object filter of the data source of target `id`. */
|
||||
// While a quick filter is on, the schemas of expanded sources load their objects, so
|
||||
// tables / routines matching the filter show up without expanding every schema node.
|
||||
useEffect(() => {
|
||||
if (!st.treeFilter.trim()) return;
|
||||
const s = useDatabase.getState();
|
||||
for (const [target, list] of Object.entries(s.schemas)) {
|
||||
if (list.status !== "ok") continue;
|
||||
const { id, database } = splitTarget(target);
|
||||
if (!s.treeExpanded.has(database ? databaseKey(id, database) : id)) continue;
|
||||
for (const schema of list.value) {
|
||||
if (!s.tables[tablesKey(target, schema)]) void loadTables(target, schema);
|
||||
}
|
||||
}
|
||||
}, [st.treeFilter, st.treeExpanded, st.schemas]);
|
||||
|
||||
/** Schemas tab › Object filter, plus the toolbar's quick filter, of the data source of target `id`. */
|
||||
const shown = (id: string) => {
|
||||
const filter = sourceOf(id)?.introspection?.objectFilter;
|
||||
return (o: { name: string }) => passesObjectFilter(o.name, filter);
|
||||
return (o: { name: string }) => passesObjectFilter(o.name, filter) && passesTreeFilter(o.name, st.treeFilter);
|
||||
};
|
||||
const tablesOf = (id: string, schema: string) => {
|
||||
const t = st.tables[tablesKey(id, schema)];
|
||||
@@ -177,7 +200,7 @@ export function DatabaseView() {
|
||||
(st.objects[tablesKey(id, schema)]?.packages ?? []).filter(shown(id));
|
||||
const othersOf = (id: string, schema: string, folder: Folder) =>
|
||||
(st.objects[tablesKey(id, schema)]?.others ?? []).filter((o) => otherFolder(o.kind) === folder).filter(shown(id));
|
||||
/** Members of a schema folder, after object filtering. */
|
||||
/** Members of a schema folder, after object and quick filtering. */
|
||||
const folderSize = (id: string, schema: string, folder: Folder): number => {
|
||||
if (isOtherFolder(folder)) return othersOf(id, schema, folder).length;
|
||||
if (folder === "routines" || folder === "procedures" || folder === "functions")
|
||||
@@ -204,9 +227,19 @@ export function DatabaseView() {
|
||||
return shownNames(v.names, i?.allDatabases, i?.databases, v.current);
|
||||
};
|
||||
|
||||
/** Under a quick filter a schema shows when its name matches, or its loaded objects do. */
|
||||
const schemaVisible = (id: string, schema: string) =>
|
||||
passesTreeFilter(schema, st.treeFilter) ||
|
||||
!!tablesOf(id, schema)?.length ||
|
||||
routinesOf(id, schema).length > 0 ||
|
||||
packagesOf(id, schema).length > 0 ||
|
||||
sequencesOf(id, schema).length > 0;
|
||||
|
||||
const schemasOf = (key: string, id: string) =>
|
||||
status(key, st.schemas[id], (v) =>
|
||||
shownSchemas(id, v).map((schema) => ({ kind: "schema", key: `${id}/${schema}`, id, schema }) as Node),
|
||||
shownSchemas(id, v)
|
||||
.filter((schema) => schemaVisible(id, schema))
|
||||
.map((schema) => ({ kind: "schema", key: `${id}/${schema}`, id, schema }) as Node),
|
||||
);
|
||||
|
||||
const children = (n: Node): readonly Node[] | undefined => {
|
||||
@@ -530,8 +563,7 @@ export function DatabaseView() {
|
||||
const color = target ? sourceOf(target)?.color : null;
|
||||
return color ? `${styles.tintedRow} ${ROW_TINTS[color]}` : undefined;
|
||||
}}
|
||||
speedSearchField
|
||||
renderNode={(n: Node, state) => {
|
||||
renderNode={(n: Node) => {
|
||||
const i = icon(n);
|
||||
const d = detail(n);
|
||||
const counted = n.kind === "source" || n.kind === "database" || n.kind === "folder" || n.kind === "group";
|
||||
@@ -554,7 +586,7 @@ export function DatabaseView() {
|
||||
{live && <span className={styles.connectedDot} title={tx("Connected")} />}
|
||||
</span>
|
||||
)}
|
||||
<HighlightedText className={labelClass} text={label(n)} indices={state.matches} />
|
||||
<span className={labelClass}>{label(n)}</span>
|
||||
{n.kind === "source" && n.source.global && (
|
||||
<span className={styles.treeDetail} title={tx("Available in all projects")}>
|
||||
{tx("global")}
|
||||
@@ -611,6 +643,7 @@ function DatabaseToolbar() {
|
||||
const node = useDatabase((s) => s.selectedNode);
|
||||
const connected = useDatabase((s) => s.connected);
|
||||
const sources = useDatabase((s) => s.sources);
|
||||
const treeFilter = useDatabase((s) => s.treeFilter);
|
||||
const plus = useRef<HTMLButtonElement>(null);
|
||||
const newOpen = useDatabase((s) => s.newMenuOpen);
|
||||
const setNewOpen = (v: boolean) => useDatabase.setState({ newMenuOpen: v });
|
||||
@@ -656,6 +689,13 @@ function DatabaseToolbar() {
|
||||
>
|
||||
<T>DDL</T>
|
||||
</button>
|
||||
<SearchField
|
||||
className={styles.treeFilter}
|
||||
value={treeFilter}
|
||||
onChange={(treeFilter) => useDatabase.setState({ treeFilter })}
|
||||
placeholder={tx("Filter objects")}
|
||||
aria-label={tx("Filter objects")}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,16 +4,7 @@
|
||||
* a toolbar (re-run, export / copy as CSV, JSON, SQL…), the grid and a floating row count.
|
||||
*/
|
||||
import { copySelectionOnKeyDown } from "@/ui/selectableText";
|
||||
import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
useSyncExternalStore,
|
||||
type MouseEvent,
|
||||
} from "react";
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type MouseEvent } from "react";
|
||||
import clsx from "clsx";
|
||||
import { call, commands, type DbPlanNode, type DbQueryResult } from "@/platform/ipc";
|
||||
import { shortcutLabel } from "@/platform/keymap";
|
||||
@@ -207,32 +198,8 @@ function Pager({ tab }: { tab: ResultTab }) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubmitted edits by the rows they were made on, and the results whose edits are being
|
||||
* submitted. They live outside the pane, which remounts when another result tab is selected,
|
||||
* so a submit that ends while its pane is unmounted still clears what the remounted one shows.
|
||||
*/
|
||||
/** Unsubmitted edits by the rows they were made on, kept while another result tab is shown. */
|
||||
const keptEdits = new WeakMap<DbQueryResult, PendingEdits>();
|
||||
const submittingResults = new Set<DbQueryResult>();
|
||||
const NO_EDITS = emptyEdits();
|
||||
const resultListeners = new Set<() => void>();
|
||||
function notifyResults() {
|
||||
for (const listener of resultListeners) listener();
|
||||
}
|
||||
function subscribeResults(listener: () => void) {
|
||||
resultListeners.add(listener);
|
||||
return () => void resultListeners.delete(listener);
|
||||
}
|
||||
function setKeptEdits(result: DbQueryResult, edits: PendingEdits) {
|
||||
if (hasEdits(edits)) keptEdits.set(result, edits);
|
||||
else keptEdits.delete(result);
|
||||
notifyResults();
|
||||
}
|
||||
function setSubmittingResult(result: DbQueryResult, on: boolean) {
|
||||
if (on) submittingResults.add(result);
|
||||
else submittingResults.delete(result);
|
||||
notifyResults();
|
||||
}
|
||||
|
||||
function Result({ tab }: { tab: ResultTab }) {
|
||||
const [view, setView] = useState<"table" | "chart">("table");
|
||||
@@ -308,12 +275,20 @@ function Result({ tab }: { tab: ResultTab }) {
|
||||
driver !== "clickhouse" &&
|
||||
sources.some((s) => s !== null);
|
||||
|
||||
// The pending edits belong to the result they were made on: fresh rows (a re-run,
|
||||
// another page) start over.
|
||||
const edits = useSyncExternalStore(subscribeResults, () => (r && keptEdits.get(r)) ?? NO_EDITS);
|
||||
const setEdits = (f: (e: PendingEdits) => PendingEdits) => {
|
||||
if (r) setKeptEdits(r, f(keptEdits.get(r) ?? NO_EDITS));
|
||||
};
|
||||
// The pending edits belong to the result they were made on: fresh rows (a
|
||||
// re-run, another page) start over, without an effect. They outlive the pane,
|
||||
// which remounts when another result tab is selected.
|
||||
const [pending, setPending] = useState<{ outcome: DbQueryResult | null; edits: PendingEdits }>(() => ({
|
||||
outcome: r ?? null,
|
||||
edits: (r && keptEdits.get(r)) ?? emptyEdits(),
|
||||
}));
|
||||
const edits = pending.outcome === r ? pending.edits : emptyEdits();
|
||||
const setEdits = (f: (e: PendingEdits) => PendingEdits) =>
|
||||
setPending((previous) => {
|
||||
const next = f(previous.outcome === r ? previous.edits : emptyEdits());
|
||||
if (r) keptEdits.set(r, next);
|
||||
return { outcome: r ?? null, edits: next };
|
||||
});
|
||||
const loaded = r?.rows.length ?? 0;
|
||||
const rowCount = loaded + edits.inserts.length;
|
||||
const value = useCallback(
|
||||
@@ -366,12 +341,14 @@ function Result({ tab }: { tab: ResultTab }) {
|
||||
});
|
||||
|
||||
const dirty = hasEdits(edits);
|
||||
const submitting = useSyncExternalStore(subscribeResults, () => !!r && submittingResults.has(r));
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const submitGuard = useRef(false);
|
||||
const busy = submitting || !!tab.busy;
|
||||
|
||||
const submit = async () => {
|
||||
if (!r || !target || !pk || !editable || busy || submittingResults.has(r)) return;
|
||||
setSubmittingResult(r, true);
|
||||
if (!r || !target || !pk || !editable || busy || submitGuard.current) return;
|
||||
submitGuard.current = true;
|
||||
setSubmitting(true);
|
||||
const list = buildRowEdits(resultNames, r.rows, pk, edits);
|
||||
try {
|
||||
// The Output log shows what the submit is about to change.
|
||||
@@ -381,8 +358,7 @@ function Result({ tab }: { tab: ResultTab }) {
|
||||
);
|
||||
log("result", `${target.table}: ${n} row(s) changed`);
|
||||
notifications().notify({ level: "info", title: `${target.table}: ${n} row(s) changed`, key: "db-submit" });
|
||||
// Also when this pane was unmounted meanwhile: the applied edits must not come back.
|
||||
setKeptEdits(r, NO_EDITS);
|
||||
setEdits(() => emptyEdits());
|
||||
await rerunResult(tab.id);
|
||||
} catch (e) {
|
||||
log("error", e instanceof Error ? e.message : String(e));
|
||||
@@ -393,7 +369,8 @@ function Result({ tab }: { tab: ResultTab }) {
|
||||
key: "db-submit",
|
||||
});
|
||||
} finally {
|
||||
setSubmittingResult(r, false);
|
||||
submitGuard.current = false;
|
||||
setSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,18 +3,10 @@ import { describe, expect, it, vi } from "vitest";
|
||||
import { SourceDialog } from "./SourceDialog";
|
||||
|
||||
const ipc = vi.hoisted(() => ({ call: vi.fn() }));
|
||||
vi.mock("@/platform/ipc", async (importOriginal) => {
|
||||
const real = await importOriginal<typeof import("@/platform/ipc")>();
|
||||
// The commands `call` receives must not reach Tauri's invoke, which jsdom lacks.
|
||||
const request =
|
||||
(name: string) =>
|
||||
(...args: unknown[]) => [name, ...args];
|
||||
return {
|
||||
...real,
|
||||
call: ipc.call,
|
||||
commands: { ...real.commands, dbTest: request("dbTest"), dbTestTunnel: request("dbTestTunnel") },
|
||||
};
|
||||
});
|
||||
vi.mock("@/platform/ipc", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("@/platform/ipc")>()),
|
||||
call: ipc.call,
|
||||
}));
|
||||
|
||||
const savePassword = () => screen.getByRole("checkbox", { name: "Save password" }) as HTMLInputElement;
|
||||
|
||||
@@ -71,7 +63,6 @@ describe("Test SSH Tunnel", () => {
|
||||
await waitFor(() =>
|
||||
expect(screen.getByRole("status").textContent).toBe("SSH tunnel works: dev@bastion:22 reaches 127.0.0.1:5432"),
|
||||
);
|
||||
expect(ipc.call.mock.calls[0]?.[0]?.[0]).toBe("dbTestTunnel");
|
||||
ipc.call.mockClear();
|
||||
});
|
||||
});
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
idleTargets,
|
||||
matchesPattern,
|
||||
parseSourceUrl,
|
||||
passesTreeFilter,
|
||||
schemaSwitchable,
|
||||
shownNames,
|
||||
sourceLabel,
|
||||
@@ -391,6 +392,16 @@ describe("Schemas tab", () => {
|
||||
expect(shownNames(names, false, ["app*"], "postgres")).toEqual(["app", "app_test", "postgres"]);
|
||||
expect(shownNames(names, false, [])).toEqual([]);
|
||||
});
|
||||
|
||||
it("quick-filters tree objects by a case-insensitive substring", () => {
|
||||
expect(passesTreeFilter("users", "user")).toBe(true);
|
||||
expect(passesTreeFilter("Users", "user")).toBe(true);
|
||||
expect(passesTreeFilter("order_items", " IT ")).toBe(true);
|
||||
expect(passesTreeFilter("users", "orders")).toBe(false);
|
||||
expect(passesTreeFilter("users", "")).toBe(true);
|
||||
expect(passesTreeFilter("users", " ")).toBe(true);
|
||||
expect(passesTreeFilter("users", null)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("active schema", () => {
|
||||
|
||||
@@ -205,6 +205,15 @@ export function passesObjectFilter(name: string, filter: string | null | undefin
|
||||
return !patterns.length || patterns.some((p) => matchesPattern(name.toLowerCase(), p.toLowerCase()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The tree's quick filter (the toolbar's field): `name` contains it,
|
||||
* case-insensitively (`*` / `?` still work through `matchesPattern` callers).
|
||||
*/
|
||||
export function passesTreeFilter(name: string, filter: string | null | undefined): boolean {
|
||||
const q = (filter ?? "").trim().toLowerCase();
|
||||
return !q || name.toLowerCase().includes(q);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a console of `driver` gets the active-schema dropdown (a server with
|
||||
* several schemas / databases to switch between; SQLite has one database only).
|
||||
|
||||
@@ -231,66 +231,6 @@ describe("editable result grid", () => {
|
||||
await act(async () => finish({ status: "ok", data: 1 }));
|
||||
});
|
||||
|
||||
it("keeps a submission in flight from being repeated after switching result tabs", async () => {
|
||||
let finish!: (value: { status: string; data: number }) => void;
|
||||
backend.applyEdits.mockImplementation(
|
||||
() =>
|
||||
new Promise((resolve) => {
|
||||
finish = resolve;
|
||||
}),
|
||||
);
|
||||
backend.execute.mockImplementation(() => new Promise(() => {}));
|
||||
const first = show("SELECT * FROM users", [{ name: "id" }, { name: "name" }], [["1", "Ann"]]);
|
||||
const second: ResultTab = {
|
||||
...first,
|
||||
id: nextId++,
|
||||
title: "Result 2",
|
||||
outcome: { ...first.outcome, result: { ...first.outcome.result! } },
|
||||
};
|
||||
useDatabase.setState((s) => ({ results: [...s.results, second] }));
|
||||
await act(async () => render(<ResultsView />));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Add Row" }));
|
||||
await act(async () => fireEvent.click(screen.getByRole("button", { name: "Submit" })));
|
||||
|
||||
await act(async () => useDatabase.setState({ activeResult: second.id }));
|
||||
await act(async () => useDatabase.setState({ activeResult: first.id }));
|
||||
expect(screen.getByRole("button", { name: "Submit" })).toBeDisabled();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Submit" }));
|
||||
expect(backend.applyEdits).toHaveBeenCalledTimes(1);
|
||||
|
||||
await act(async () => finish({ status: "ok", data: 1 }));
|
||||
// The applied row is not offered again while the result re-runs.
|
||||
expect(screen.getByRole("button", { name: "Submit" })).toBeDisabled();
|
||||
});
|
||||
|
||||
it("drops applied edits from a remounted pane even when the refresh fails", async () => {
|
||||
let finish!: (value: { status: string; data: number }) => void;
|
||||
backend.applyEdits.mockImplementation(
|
||||
() =>
|
||||
new Promise((resolve) => {
|
||||
finish = resolve;
|
||||
}),
|
||||
);
|
||||
backend.execute.mockResolvedValue({ status: "error", error: { kind: "invalid", message: "gone" } });
|
||||
const first = show("SELECT * FROM users", [{ name: "id" }, { name: "name" }], [["1", "Ann"]]);
|
||||
const second: ResultTab = {
|
||||
...first,
|
||||
id: nextId++,
|
||||
title: "Result 2",
|
||||
outcome: { ...first.outcome, result: { ...first.outcome.result! } },
|
||||
};
|
||||
useDatabase.setState((s) => ({ results: [...s.results, second] }));
|
||||
await act(async () => render(<ResultsView />));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Add Row" }));
|
||||
await act(async () => fireEvent.click(screen.getByRole("button", { name: "Submit" })));
|
||||
await act(async () => useDatabase.setState({ activeResult: second.id }));
|
||||
await act(async () => useDatabase.setState({ activeResult: first.id }));
|
||||
|
||||
await act(async () => finish({ status: "ok", data: 1 }));
|
||||
expect(screen.getByRole("button", { name: "Submit" })).toBeDisabled();
|
||||
expect(backend.applyEdits).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("uses the execution schema even after the console selection changes", async () => {
|
||||
const tab = show("SELECT * FROM users", [{ name: "id" }, { name: "name" }], [["1", "Ann"]]);
|
||||
Object.assign(tab, { schema: "s2" });
|
||||
|
||||
@@ -164,6 +164,8 @@ interface DatabaseState {
|
||||
consoles: Record<string, string>;
|
||||
/** Console path → its active schema (unqualified names resolve there; see `consoleSchema`). */
|
||||
consoleSchemas: Record<string, string>;
|
||||
/** The Database tree's quick object filter (empty: everything shows). */
|
||||
treeFilter: string;
|
||||
separateProceduresAndFunctions: boolean;
|
||||
completion: Record<string, DbCompletion>;
|
||||
results: ResultTab[];
|
||||
@@ -231,6 +233,7 @@ export const useDatabase = create<DatabaseState>(() => ({
|
||||
objects: {},
|
||||
consoles: readBindings(),
|
||||
consoleSchemas: readConsoleSchemas(),
|
||||
treeFilter: "",
|
||||
separateProceduresAndFunctions: readSeparateProceduresAndFunctions(),
|
||||
completion: {},
|
||||
results: [],
|
||||
|
||||
@@ -66,24 +66,6 @@ beforeEach(() => {
|
||||
});
|
||||
});
|
||||
|
||||
/** Where the page goes when it runs `expression`; null when it stays. Tracks the address. */
|
||||
let pageAt = "http://localhost:5173/";
|
||||
function run(expression: string): string | null {
|
||||
let went: string | null = null;
|
||||
const location = {
|
||||
get href() {
|
||||
return pageAt;
|
||||
},
|
||||
assign: (url: string) => {
|
||||
went = url;
|
||||
pageAt = url;
|
||||
},
|
||||
};
|
||||
// The page's own globals may shadow the browser's (`const URL = "/api"`).
|
||||
new Function("location", "URL", `return ${expression}`)(location, "/api");
|
||||
return went;
|
||||
}
|
||||
|
||||
describe("the browser of a project under the debugger", () => {
|
||||
it("is started once: a second launch sends its page to the new address and selects it", async () => {
|
||||
const first = await startBrowserSession(browserLaunch("a", "http://localhost:5173/", "chrome", "/p"));
|
||||
@@ -94,18 +76,13 @@ describe("the browser of a project under the debugger", () => {
|
||||
const again = await startBrowserSession(browserLaunch("b", "http://localhost:5173/cart", "chrome", "/p"));
|
||||
expect(again).toBe(first);
|
||||
expect(ipc.debugStart).toHaveBeenCalledTimes(1);
|
||||
const sentTo = () => ipc.debugEvaluateIn.mock.calls.map(([, , expression]) => run(String(expression)));
|
||||
expect(sentTo()).toEqual(["http://localhost:5173/cart"]);
|
||||
expect(ipc.debugEvaluateIn).toHaveBeenCalledWith(2, null, 'location.assign("http://localhost:5173/cart")', "repl");
|
||||
expect(useDebug.getState().active).toBe(2);
|
||||
|
||||
// Back to the address it was started on: the page is at /cart now, so it goes back.
|
||||
// The address it was started on: the page is where it is.
|
||||
ipc.debugEvaluateIn.mockClear();
|
||||
await startBrowserSession(browserLaunch("a", "http://localhost:5173/", "chrome", "/p"));
|
||||
expect(sentTo()).toEqual(["http://localhost:5173/"]);
|
||||
// A page already at the address stays as it is.
|
||||
ipc.debugEvaluateIn.mockClear();
|
||||
await startBrowserSession(browserLaunch("a", "http://localhost:5173/", "chrome", "/p"));
|
||||
expect(sentTo()).toEqual([null]);
|
||||
expect(ipc.debugEvaluateIn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is another one for another browser, another project, or after the first has ended", async () => {
|
||||
|
||||
@@ -52,13 +52,6 @@ describe("watches while the program runs", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("evaluates a multi-line watch as one expression", async () => {
|
||||
const multiline = "items\n .filter((i) => i.done)\n .length";
|
||||
renderHook(() => useLiveWatches(session(), [multiline, "b"], true));
|
||||
await settle();
|
||||
expect(asked.map((a) => a[2])).toEqual([multiline, "b"]);
|
||||
});
|
||||
|
||||
it("refreshes every second and not faster", async () => {
|
||||
expect(LIVE_WATCH_INTERVAL_MS).toBe(1000);
|
||||
renderHook(() => useLiveWatches(session(), ["a"], true));
|
||||
|
||||
@@ -42,8 +42,7 @@ export function useLiveWatches(
|
||||
const [data, setData] = useState<{ session: number; rows: LiveWatch[] }>({ session: -1, rows: NONE });
|
||||
const apply = visible && watches.length > 0 && liveWatchesApply(session);
|
||||
const id = session?.id ?? -1;
|
||||
// A stable dependency for the list; a watch may span several lines.
|
||||
const expressions = JSON.stringify(watches);
|
||||
const expressions = watches.join("\n");
|
||||
useEffect(() => {
|
||||
if (!apply) return;
|
||||
let current = true;
|
||||
@@ -52,7 +51,7 @@ export function useLiveWatches(
|
||||
if (evaluating.has(id)) return;
|
||||
evaluating.add(id);
|
||||
const rows = await Promise.all(
|
||||
(JSON.parse(expressions) as string[]).map(async (expression): Promise<LiveWatch> => {
|
||||
expressions.split("\n").map(async (expression): Promise<LiveWatch> => {
|
||||
try {
|
||||
return {
|
||||
expression,
|
||||
|
||||
@@ -510,15 +510,6 @@ function selectBrowserPage(launch: DebugSessionId) {
|
||||
publishContext();
|
||||
}
|
||||
|
||||
/** `url` as `location.href` spells it (`http://localhost:5173` → `http://localhost:5173/`). */
|
||||
function canonicalUrl(url: string): string {
|
||||
try {
|
||||
return new URL(url).href;
|
||||
} catch {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Debugs the page `launch` opens. A project has one browser of a kind under the debugger (a
|
||||
* second one can't share its profile), so when it is already running its page goes to the URL
|
||||
@@ -538,12 +529,8 @@ export async function startBrowserSession(
|
||||
if (!page) return running.id;
|
||||
selectSession(page.id);
|
||||
const url = launchedUrl(launch);
|
||||
if (url) {
|
||||
// The page may have moved on since the browser started (an earlier launch, a link): it
|
||||
// compares its own address, so a page already there isn't reloaded. The address is made
|
||||
// canonical here, the page's own `URL` may be anything.
|
||||
const target = JSON.stringify(canonicalUrl(url));
|
||||
const go = `location.href !== ${target} && location.assign(${target})`;
|
||||
if (url && url !== launchedUrl(running.launch!)) {
|
||||
const go = `location.assign(${JSON.stringify(url)})`;
|
||||
await call(commands.debugEvaluateIn(page.id, null, go, "repl")).catch(() => undefined);
|
||||
}
|
||||
return running.id;
|
||||
|
||||
@@ -173,14 +173,6 @@ describe("Settings dialog", () => {
|
||||
expect(within(dialog).getByLabelText("Toolchains file")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("selects the page a search names over pages that mention it", async () => {
|
||||
const dialog = await openDialog("appearance");
|
||||
fireEvent.change(within(dialog).getByLabelText("Search settings"), { target: { value: "Font" } });
|
||||
const tree = within(dialog).getByRole("tree", { name: "Settings pages" });
|
||||
expect(within(tree).getAllByRole("treeitem").length).toBeGreaterThan(1);
|
||||
expect(within(tree).getByRole("treeitem", { selected: true }).textContent).toBe("Font");
|
||||
});
|
||||
|
||||
it("searches pages and highlights matching option labels", async () => {
|
||||
const dialog = await openDialog("appearance");
|
||||
fireEvent.change(within(dialog).getByLabelText("Search settings"), { target: { value: "soft wrap" } });
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
highlightIndices,
|
||||
matchesTerms,
|
||||
queryTerms,
|
||||
titledPage,
|
||||
} from "../model/pages";
|
||||
import { BEHAVIOR_PAGES } from "../pages/behavior";
|
||||
import { EDITOR_PAGES } from "../pages/editor";
|
||||
@@ -91,24 +90,3 @@ it("indexes toolbar and status bar visibility in Appearance settings", () => {
|
||||
expect(labels).toContain("Show main toolbar");
|
||||
expect(labels).toContain("Show status bar");
|
||||
});
|
||||
|
||||
describe("the page a search names", () => {
|
||||
const notifications = page({
|
||||
id: "notifications",
|
||||
title: "Notifications",
|
||||
keywords: ["Plugins", "Language Servers"],
|
||||
});
|
||||
const tree = buildPageTree([...pages, notifications]);
|
||||
const named = (q: string) => titledPage(filterPageTree(tree, q), q)?.key ?? null;
|
||||
|
||||
it("is the page titled like the query, not one that only mentions it", () => {
|
||||
expect(named("Plugins")).toBe("plugins");
|
||||
expect(named("language servers")).toBe("languages.servers");
|
||||
expect(named("Plu")).toBe("plugins");
|
||||
});
|
||||
|
||||
it("is none when no title starts with the query", () => {
|
||||
expect(named("shortcut")).toBeNull();
|
||||
expect(named("")).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -28,16 +28,7 @@ import {
|
||||
} from "@/ui";
|
||||
import { PageContext, useSettingsFormFor } from "../components/context";
|
||||
import { SearchLabel } from "../components/Form";
|
||||
import {
|
||||
breadcrumb,
|
||||
buildPageTree,
|
||||
filterPageTree,
|
||||
flatten,
|
||||
groupKey,
|
||||
titledPage,
|
||||
titleRank,
|
||||
type PageNode,
|
||||
} from "../model/pages";
|
||||
import { breadcrumb, buildPageTree, filterPageTree, flatten, groupKey, type PageNode } from "../model/pages";
|
||||
import {
|
||||
applySettings,
|
||||
closeSettings,
|
||||
@@ -273,15 +264,7 @@ export function SettingsLayout() {
|
||||
|
||||
const onQuery = (q: string) => {
|
||||
setQuery(q);
|
||||
const filtered = filterPageTree(tree, q, pageLabels);
|
||||
const next = flatten(filtered);
|
||||
// A page named like the query wins over pages that only mention it.
|
||||
const titled = titledPage(filtered, q);
|
||||
const rank = (n: PageNode | undefined) => (n ? (titleRank(n, q) ?? 2) : 2);
|
||||
if (titled && titled.key !== current?.key && rank(titled) < rank(current)) {
|
||||
selectPage(titled.key);
|
||||
return;
|
||||
}
|
||||
const next = flatten(filterPageTree(tree, q, pageLabels));
|
||||
if (q && current && !next.some((n) => n.key === current.key && n.matched)) {
|
||||
const first = firstPage(next);
|
||||
if (first) selectPage(first);
|
||||
|
||||
@@ -94,33 +94,6 @@ export function matchesTerms(texts: readonly string[], terms: readonly string[])
|
||||
return terms.every((term) => hay.some((h) => h.includes(term)));
|
||||
}
|
||||
|
||||
/**
|
||||
* How well a page's title answers the query: 0 when it is the query, 1 when it starts with
|
||||
* it, null otherwise (English or translated title).
|
||||
*/
|
||||
export function titleRank(node: PageNode, query: string): number | null {
|
||||
const q = query.trim().toLowerCase();
|
||||
if (!q || !node.page) return null;
|
||||
const titles = [node.title.toLowerCase(), tx(node.title).toLowerCase()];
|
||||
if (titles.includes(q)) return 0;
|
||||
if (titles.some((title) => title.startsWith(q))) return 1;
|
||||
return null;
|
||||
}
|
||||
|
||||
/** The matching page whose title answers the query best (see {@link titleRank}), if any. */
|
||||
export function titledPage(nodes: readonly PageNode[], query: string): PageNode | null {
|
||||
let best: PageNode | null = null;
|
||||
let bestRank = Infinity;
|
||||
for (const n of flatten(nodes)) {
|
||||
const rank = n.matched ? titleRank(n, query) : null;
|
||||
if (rank !== null && rank < bestRank) {
|
||||
best = n;
|
||||
bestRank = rank;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
/** Indices of `text` covered by any term (for highlighting option labels), or null. */
|
||||
export function highlightIndices(text: string, query: string): number[] | null {
|
||||
const terms = queryTerms(query);
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import zh from "@/platform/locales/text/zh.json";
|
||||
import { BUILTIN_CODE_TEMPLATES, BUILTIN_FILE_TEMPLATES } from "../files/builtins";
|
||||
|
||||
/** Names that read the same in Chinese. */
|
||||
const AS_WRITTEN = new Set(["Dockerfile", "Jupyter Notebook"]);
|
||||
|
||||
describe("built-in template names", () => {
|
||||
it("are translated where the New menu and dialog show them", () => {
|
||||
const texts = zh as Record<string, string>;
|
||||
const names = [...BUILTIN_FILE_TEMPLATES, ...BUILTIN_CODE_TEMPLATES].map((t) => t.name);
|
||||
expect(names.filter((name) => !AS_WRITTEN.has(name) && !texts[name])).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -99,7 +99,7 @@ function TemplateStep({
|
||||
renderItem={(t) => (
|
||||
<span className={styles.templateRow}>
|
||||
<Icon name={t.icon} size={16} className={styles.icon} />
|
||||
{tx(t.name)}
|
||||
{t.name}
|
||||
</span>
|
||||
)}
|
||||
/>
|
||||
@@ -230,10 +230,10 @@ function NameStep({
|
||||
<Dialog
|
||||
open
|
||||
onClose={close}
|
||||
title={tx`New ${tx(template.name)}`}
|
||||
title={tx`New ${template.name}`}
|
||||
width={380}
|
||||
position="top"
|
||||
aria-label={tx`New ${tx(template.name)}`}
|
||||
aria-label={tx`New ${template.name}`}
|
||||
className={variables.length ? styles.variableDialog : undefined}
|
||||
buttons={
|
||||
variables.length
|
||||
@@ -293,7 +293,7 @@ function NameStep({
|
||||
onDoubleClick={() => void submit()}
|
||||
>
|
||||
<Icon name={template.icon} size={14} className={styles.icon} />
|
||||
{tx(k.label)}
|
||||
{k.label}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -78,7 +78,7 @@ function directoryOf(arg: unknown): string | null {
|
||||
function newFileAction(t: FileTemplate): Action {
|
||||
return {
|
||||
id: `templates.new.${t.id}`,
|
||||
title: t.id === "file" ? "New Empty File…" : tx`New ${tx(t.name)}…`,
|
||||
title: t.id === "file" ? "New Empty File…" : tx`New ${t.name}…`,
|
||||
category: "File",
|
||||
icon: t.icon,
|
||||
when: "projectOpen",
|
||||
|
||||
@@ -188,7 +188,6 @@
|
||||
}
|
||||
.stashList {
|
||||
flex: 1;
|
||||
container: stash-list / inline-size;
|
||||
}
|
||||
.stashRow {
|
||||
flex: 1;
|
||||
@@ -197,25 +196,16 @@
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
/* The message identifies a stash: the branch gives way first, the time stays whole. */
|
||||
.stashRow > .detail {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.stashRow > .stashTime {
|
||||
flex: none;
|
||||
flex-shrink: 1;
|
||||
}
|
||||
.stashMessage {
|
||||
flex: 1 1 auto;
|
||||
min-width: 4em;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
@container stash-list (max-width: 320px) {
|
||||
.stashBranch {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
/* Settings › Commit › Show right margin off. */
|
||||
.noMargin {
|
||||
background: var(--bg-island, var(--bg-app));
|
||||
|
||||
@@ -1309,8 +1309,8 @@ export function StashesPanel() {
|
||||
{repos.length > 1 && s.repo ? `${repoName(s.repo)} · ` : ""}
|
||||
{text}
|
||||
</span>
|
||||
{branch && <span className={clsx(styles.detail, styles.stashBranch)}>{branch}</span>}
|
||||
<span className={clsx(styles.detail, styles.stashTime)}>{formatTime(s.timeMs)}</span>
|
||||
{branch && <span className={styles.detail}>{branch}</span>}
|
||||
<span className={styles.detail}>{formatTime(s.timeMs)}</span>
|
||||
</span>
|
||||
);
|
||||
}}
|
||||
|
||||
@@ -35,7 +35,7 @@ it.each(resizeObserverMessages)("keeps waiting for boot-ready after %s", (messag
|
||||
expect(document.getElementById("boot-error")).toBeNull();
|
||||
expect(document.documentElement.dataset.boot).toBeUndefined();
|
||||
window.dispatchEvent(new Event("openidea:boot-ready"));
|
||||
vi.advanceTimersByTime(60_000);
|
||||
vi.advanceTimersByTime(30_000);
|
||||
expect(document.getElementById("boot-error")).toBeNull();
|
||||
});
|
||||
|
||||
@@ -48,10 +48,10 @@ it.each(resizeObserverMessages)("still reports a real failure after %s", (messag
|
||||
});
|
||||
|
||||
it.each(resizeObserverMessages)("still times out an unresolved startup after %s", (message) => {
|
||||
vi.advanceTimersByTime(30_000);
|
||||
vi.advanceTimersByTime(15_000);
|
||||
window.dispatchEvent(new ErrorEvent("error", { message }));
|
||||
vi.advanceTimersByTime(30_000);
|
||||
expect(document.querySelector("textarea")?.value).toContain("Startup did not finish within 60 seconds.");
|
||||
vi.advanceTimersByTime(15_000);
|
||||
expect(document.querySelector("textarea")?.value).toContain("Startup did not finish within 30 seconds.");
|
||||
});
|
||||
|
||||
it.each(resizeObserverMessages)("ignores the loop notification delivered as an Error: %s", (message) => {
|
||||
@@ -62,7 +62,7 @@ it.each(resizeObserverMessages)("ignores the loop notification delivered as an E
|
||||
expect(document.getElementById("boot-error")).toBeNull();
|
||||
expect(document.documentElement.dataset.boot).toBeUndefined();
|
||||
window.dispatchEvent(new Event("openidea:boot-ready"));
|
||||
vi.advanceTimersByTime(60_000);
|
||||
vi.advanceTimersByTime(30_000);
|
||||
expect(document.getElementById("boot-error")).toBeNull();
|
||||
});
|
||||
|
||||
@@ -78,7 +78,7 @@ it("keeps starting after an unhandled rejection", () => {
|
||||
expect(document.getElementById("boot-error")).toBeNull();
|
||||
expect(document.documentElement.dataset.boot).toBeUndefined();
|
||||
window.dispatchEvent(new Event("openidea:boot-ready"));
|
||||
vi.advanceTimersByTime(60_000);
|
||||
vi.advanceTimersByTime(30_000);
|
||||
expect(document.getElementById("boot-error")).toBeNull();
|
||||
});
|
||||
|
||||
@@ -88,9 +88,9 @@ it("reports the first rejection when startup then times out", () => {
|
||||
Object.defineProperty(error, "stack", { value: undefined });
|
||||
reject(error);
|
||||
reject({ message: "later rejection" });
|
||||
vi.advanceTimersByTime(60_000);
|
||||
vi.advanceTimersByTime(30_000);
|
||||
const details = document.querySelector("textarea")?.value;
|
||||
expect(details).toContain("Startup did not finish within 60 seconds.");
|
||||
expect(details).toContain("Startup did not finish within 30 seconds.");
|
||||
expect(details).toContain("TypeError: Load failed");
|
||||
expect(details).not.toContain("later rejection");
|
||||
});
|
||||
@@ -101,7 +101,7 @@ it("counts the startup timeout only while the window shows", () => {
|
||||
document.dispatchEvent(new Event("visibilitychange"));
|
||||
};
|
||||
try {
|
||||
vi.advanceTimersByTime(50_000);
|
||||
vi.advanceTimersByTime(20_000);
|
||||
// Behind another window: no frames, so the splash can't finish; that isn't a failure.
|
||||
hidden(true);
|
||||
vi.advanceTimersByTime(60_000);
|
||||
@@ -110,7 +110,7 @@ it("counts the startup timeout only while the window shows", () => {
|
||||
vi.advanceTimersByTime(9_000);
|
||||
expect(document.getElementById("boot-error")).toBeNull();
|
||||
vi.advanceTimersByTime(1_000);
|
||||
expect(document.querySelector("textarea")?.value).toContain("Startup did not finish within 60 seconds.");
|
||||
expect(document.querySelector("textarea")?.value).toContain("Startup did not finish within 30 seconds.");
|
||||
} finally {
|
||||
Object.defineProperty(document, "hidden", { configurable: true, value: false });
|
||||
}
|
||||
@@ -156,14 +156,14 @@ it("surfaces initial React render failures through the boot error event", () =>
|
||||
});
|
||||
|
||||
it("reports an unresolved startup instead of waiting forever", () => {
|
||||
vi.advanceTimersByTime(60_000);
|
||||
expect(document.querySelector("textarea")?.value).toContain("Startup did not finish within 60 seconds.");
|
||||
vi.advanceTimersByTime(30_000);
|
||||
expect(document.querySelector("textarea")?.value).toContain("Startup did not finish within 30 seconds.");
|
||||
});
|
||||
|
||||
it("stops intercepting failures after a successful startup", () => {
|
||||
window.dispatchEvent(new Event("openidea:boot-ready"));
|
||||
window.dispatchEvent(new ErrorEvent("error", { message: "runtime failure" }));
|
||||
vi.advanceTimersByTime(60_000);
|
||||
vi.advanceTimersByTime(30_000);
|
||||
expect(document.getElementById("boot-error")).toBeNull();
|
||||
});
|
||||
|
||||
|
||||
@@ -193,35 +193,9 @@
|
||||
"menu.file.closeProject": "Close Project",
|
||||
"menu.remote.reopenInContainer": "Reopen in Container",
|
||||
"menu.remote.reloadEnvironment": "Reload Environment",
|
||||
"menu.file.new": "File…",
|
||||
"menu.file.newScratchFile": "Scratch File",
|
||||
"menu.new": "New",
|
||||
"menu.workspace.create": "Workspace…",
|
||||
"menu.workspace.open": "Open Workspace…",
|
||||
"menu.workspace.manage": "Manage Workspace…",
|
||||
"menu.file.new": "New…",
|
||||
"menu.file.newScratchFile": "New Scratch File…",
|
||||
"menu.file.openInNewWindow": "Open in New Window…",
|
||||
"menu.file.openFile": "Open File…",
|
||||
"menu.remote.connect": "Remote Development…",
|
||||
"menu.remote.disconnect": "Disconnect from Remote Host",
|
||||
"menu.navigationBar": "Navigation Bar",
|
||||
"menu.run.updateApplication": "Update Application",
|
||||
"menu.ssh.startSession": "Start SSH Session…",
|
||||
"menu.ssh.configurations": "SSH Configurations…",
|
||||
"menu.deployment": "Deployment",
|
||||
"menu.deployment.uploadToDefault": "Upload to Default Server",
|
||||
"menu.deployment.uploadTo": "Upload to…",
|
||||
"menu.deployment.downloadFromDefault": "Download from Default Server",
|
||||
"menu.deployment.downloadFrom": "Download from…",
|
||||
"menu.deployment.syncWith": "Sync with Deployed…",
|
||||
"menu.deployment.deleteFromServer": "Delete from Server",
|
||||
"menu.deployment.toggleAutoUpload": "Automatic Upload",
|
||||
"menu.deployment.browseRemoteHost": "Browse Remote Host",
|
||||
"menu.deployment.openInBrowser": "Open in Browser",
|
||||
"menu.deployment.configure": "Configuration…",
|
||||
"menu.window.mergeAllWindows": "Merge All Project Windows",
|
||||
"menu.window.detachTab": "Move Tab to New Window",
|
||||
"menu.window.nextTab": "Next Project Tab",
|
||||
"menu.window.previousTab": "Previous Project Tab",
|
||||
"menu.project.attach": "Attach Project…",
|
||||
"menu.file.openProject": "Open…",
|
||||
"menu.file.save": "Save All",
|
||||
@@ -415,7 +389,7 @@
|
||||
"menu.github.createPullRequest": "Create Pull Request…",
|
||||
"menu.github.checkoutPullRequest": "Checkout Pull Request…",
|
||||
"menu.github.openInBrowser": "Open on GitHub",
|
||||
"menu.file.newProject": "Project…",
|
||||
"menu.file.newProject": "New Project…",
|
||||
"menu.file.renameProject": "Rename Project…",
|
||||
"menu.file.reloadAllFromDisk": "Reload All from Disk",
|
||||
"menu.file.invalidateCaches": "Invalidate Caches…",
|
||||
|
||||
@@ -165,9 +165,8 @@
|
||||
"menu.file.toggleReadOnly": "Alternar archivo entre solo lectura y escritura",
|
||||
"menu.file.closeProject": "Cerrar proyecto",
|
||||
"menu.remote.reloadEnvironment": "Recargar entorno",
|
||||
"menu.file.new": "Archivo…",
|
||||
"menu.file.newScratchFile": "Archivo borrador (Scratch)",
|
||||
"menu.new": "Nuevo",
|
||||
"menu.file.new": "Nuevo…",
|
||||
"menu.file.newScratchFile": "Nuevo archivo borrador (Scratch)…",
|
||||
"menu.file.openInNewWindow": "Abrir en una ventana nueva…",
|
||||
"menu.file.openProject": "Abrir…",
|
||||
"menu.file.save": "Guardar todo",
|
||||
@@ -360,7 +359,7 @@
|
||||
"menu.github.createPullRequest": "Crear pull request…",
|
||||
"menu.github.checkoutPullRequest": "Hacer checkout de pull request…",
|
||||
"menu.github.openInBrowser": "Abrir en GitHub",
|
||||
"menu.file.newProject": "Proyecto…",
|
||||
"menu.file.newProject": "Nuevo proyecto…",
|
||||
"menu.file.renameProject": "Renombrar proyecto…",
|
||||
"menu.file.reloadAllFromDisk": "Recargar todo desde el disco",
|
||||
"menu.file.invalidateCaches": "Invalidar cachés…",
|
||||
|
||||
@@ -164,9 +164,8 @@
|
||||
"menu.file.toggleReadOnly": "Rendre le fichier en lecture seule / modifiable",
|
||||
"menu.file.closeProject": "Fermer le projet",
|
||||
"menu.remote.reloadEnvironment": "Recharger l'environnement",
|
||||
"menu.file.new": "Fichier…",
|
||||
"menu.file.newScratchFile": "Fichier brouillon",
|
||||
"menu.new": "Nouveau",
|
||||
"menu.file.new": "Nouveau…",
|
||||
"menu.file.newScratchFile": "Nouveau fichier brouillon…",
|
||||
"menu.file.openInNewWindow": "Ouvrir dans une nouvelle fenêtre…",
|
||||
"menu.file.openProject": "Ouvrir…",
|
||||
"menu.file.save": "Tout enregistrer",
|
||||
@@ -358,7 +357,7 @@
|
||||
"menu.github.createPullRequest": "Créer une pull request…",
|
||||
"menu.github.checkoutPullRequest": "Extraire une pull request…",
|
||||
"menu.github.openInBrowser": "Ouvrir sur GitHub",
|
||||
"menu.file.newProject": "Projet…",
|
||||
"menu.file.newProject": "Nouveau projet…",
|
||||
"menu.file.renameProject": "Renommer le projet…",
|
||||
"menu.file.reloadAllFromDisk": "Tout recharger depuis le disque",
|
||||
"menu.file.invalidateCaches": "Invalider les caches…",
|
||||
|
||||
@@ -171,9 +171,8 @@
|
||||
"menu.file.toggleReadOnly": "파일을 읽기 전용/쓰기 가능으로 설정",
|
||||
"menu.file.closeProject": "프로젝트 닫기",
|
||||
"menu.remote.reloadEnvironment": "환경 다시 로드",
|
||||
"menu.file.new": "파일…",
|
||||
"menu.file.newScratchFile": "스크래치 파일",
|
||||
"menu.new": "새로 만들기",
|
||||
"menu.file.new": "새로 만들기…",
|
||||
"menu.file.newScratchFile": "새 스크래치 파일…",
|
||||
"menu.file.openInNewWindow": "새 창에서 열기…",
|
||||
"menu.file.openProject": "열기…",
|
||||
"menu.file.save": "모두 저장",
|
||||
@@ -366,7 +365,7 @@
|
||||
"menu.github.createPullRequest": "풀 리퀘스트 생성…",
|
||||
"menu.github.checkoutPullRequest": "풀 리퀘스트 체크아웃…",
|
||||
"menu.github.openInBrowser": "GitHub에서 열기",
|
||||
"menu.file.newProject": "프로젝트…",
|
||||
"menu.file.newProject": "새 프로젝트…",
|
||||
"menu.file.renameProject": "프로젝트 이름 변경…",
|
||||
"menu.file.reloadAllFromDisk": "디스크에서 모두 다시 로드",
|
||||
"menu.file.invalidateCaches": "캐시 무효화…",
|
||||
|
||||
@@ -165,9 +165,8 @@
|
||||
"menu.file.toggleReadOnly": "Przełącz tryb tylko do odczytu / edycji pliku",
|
||||
"menu.file.closeProject": "Zamknij projekt",
|
||||
"menu.remote.reloadEnvironment": "Załaduj ponownie środowisko",
|
||||
"menu.file.new": "Plik…",
|
||||
"menu.file.newScratchFile": "Plik tymczasowy (Scratch)",
|
||||
"menu.new": "Nowy",
|
||||
"menu.file.new": "Nowy…",
|
||||
"menu.file.newScratchFile": "Nowy plik tymczasowy (Scratch)…",
|
||||
"menu.file.openInNewWindow": "Otwórz w nowym oknie…",
|
||||
"menu.file.openProject": "Otwórz…",
|
||||
"menu.file.save": "Zapisz wszystko",
|
||||
@@ -360,7 +359,7 @@
|
||||
"menu.github.createPullRequest": "Utwórz pull request…",
|
||||
"menu.github.checkoutPullRequest": "Przełącz (checkout) pull request…",
|
||||
"menu.github.openInBrowser": "Otwórz w GitHubie",
|
||||
"menu.file.newProject": "Projekt…",
|
||||
"menu.file.newProject": "Nowy projekt…",
|
||||
"menu.file.renameProject": "Zmień nazwę projektu…",
|
||||
"menu.file.reloadAllFromDisk": "Załaduj wszystko ponownie z dysku",
|
||||
"menu.file.invalidateCaches": "Unieważnij pamięć podręczną (Caches)…",
|
||||
|
||||
@@ -165,9 +165,8 @@
|
||||
"menu.file.toggleReadOnly": "Tornar arquivo somente leitura / gravável",
|
||||
"menu.file.closeProject": "Fechar projeto",
|
||||
"menu.remote.reloadEnvironment": "Recarregar ambiente",
|
||||
"menu.file.new": "Arquivo…",
|
||||
"menu.file.newScratchFile": "Arquivo temporário (Scratch)",
|
||||
"menu.new": "Novo",
|
||||
"menu.file.new": "Novo…",
|
||||
"menu.file.newScratchFile": "Novo arquivo temporário (Scratch)…",
|
||||
"menu.file.openInNewWindow": "Abrir em nova janela…",
|
||||
"menu.file.openProject": "Abrir…",
|
||||
"menu.file.save": "Salvar tudo",
|
||||
@@ -357,7 +356,7 @@
|
||||
"menu.github.createPullRequest": "Criar pull request…",
|
||||
"menu.github.checkoutPullRequest": "Fazer checkout de pull request…",
|
||||
"menu.github.openInBrowser": "Abrir no GitHub",
|
||||
"menu.file.newProject": "Projeto…",
|
||||
"menu.file.newProject": "Novo projeto…",
|
||||
"menu.file.renameProject": "Renomear projeto…",
|
||||
"menu.file.reloadAllFromDisk": "Recarregar tudo do disco",
|
||||
"menu.file.invalidateCaches": "Invalidar caches…",
|
||||
|
||||
@@ -826,7 +826,7 @@
|
||||
"Copied": "Copied",
|
||||
"Could not copy. Select the details below and copy them.": "Could not copy. Select the details below and copy them.",
|
||||
"Startup error details": "Startup error details",
|
||||
"Startup did not finish within 60 seconds.": "Startup did not finish within 60 seconds.",
|
||||
"Startup did not finish within 30 seconds.": "Startup did not finish within 30 seconds.",
|
||||
"Run All": "Run All",
|
||||
"Restart All": "Restart All",
|
||||
"Stop All": "Stop All",
|
||||
@@ -1685,33 +1685,5 @@
|
||||
"Evaluate watches while the program runs": "Evaluate watches while the program runs",
|
||||
"Where the debugger can do it without suspending (JavaScript). A watch with side effects runs again on each refresh.": "Where the debugger can do it without suspending (JavaScript). A watch with side effects runs again on each refresh.",
|
||||
"Stash Selected Files…": "Stash Selected Files…",
|
||||
"Select the files to stash in the Commit view first": "Select the files to stash in the Commit view first",
|
||||
"Show Only Matches": "Show Only Matches",
|
||||
"JUnit5 Test Method": "JUnit5 Test Method",
|
||||
"Kotlin JUnit5 Test Method": "Kotlin JUnit5 Test Method",
|
||||
"Go Test Function": "Go Test Function",
|
||||
"Rust Test Function": "Rust Test Function",
|
||||
"Vitest Test": "Vitest Test",
|
||||
"PHPUnit Test Method": "PHPUnit Test Method",
|
||||
"pytest Test Function": "pytest Test Function",
|
||||
"Rust File": "Rust File",
|
||||
"TypeScript File": "TypeScript File",
|
||||
"React Component": "React Component",
|
||||
"JavaScript File": "JavaScript File",
|
||||
"Python File": "Python File",
|
||||
"Go File": "Go File",
|
||||
"Go Module": "Go Module",
|
||||
"PHP File": "PHP File",
|
||||
"PHP Class": "PHP Class",
|
||||
"Java Class": "Java Class",
|
||||
"C# Class": "C# Class",
|
||||
"Kotlin Class/File": "Kotlin Class/File",
|
||||
"HTML File": "HTML File",
|
||||
"Markdown File": "Markdown File",
|
||||
"Stylesheet": "Stylesheet",
|
||||
"JSON File": "JSON File",
|
||||
"YAML File": "YAML File",
|
||||
"TOML File": "TOML File",
|
||||
"EditorConfig File": "EditorConfig File",
|
||||
".gitignore File": ".gitignore File"
|
||||
"Select the files to stash in the Commit view first": "Select the files to stash in the Commit view first"
|
||||
}
|
||||
@@ -1310,6 +1310,7 @@
|
||||
"Filter by User": "按用户过滤",
|
||||
"Filter by message": "按消息过滤",
|
||||
"Filter by name, PID or command line": "按名称、PID 或命令行过滤",
|
||||
"Filter objects": "过滤对象",
|
||||
"Filter plugins": "过滤插件",
|
||||
"Filter processes": "过滤进程",
|
||||
"Filter recent files": "过滤最近的文件",
|
||||
@@ -7209,7 +7210,7 @@
|
||||
"Copy details": "复制详情",
|
||||
"Could not copy. Select the details below and copy them.": "无法复制。请选择下方详情并手动复制。",
|
||||
"Startup error details": "启动错误详情",
|
||||
"Startup did not finish within 60 seconds.": "启动未在 60 秒内完成。",
|
||||
"Startup did not finish within 30 seconds.": "启动未在 30 秒内完成。",
|
||||
"Restart All": "全部重启",
|
||||
"Build Module '{target}'": "构建模块“{target}”",
|
||||
"Build cancelled": "构建已取消",
|
||||
@@ -8067,33 +8068,5 @@
|
||||
"This version of the JavaScript debugger does not report a page's requests.": "此版本的 JavaScript 调试器不报告页面的请求。",
|
||||
"No requests yet. Reload the page to see the requests of its load.": "还没有请求。重新加载页面即可看到加载时的请求。",
|
||||
"Evaluate watches while the program runs": "程序运行时计算监视表达式",
|
||||
"Where the debugger can do it without suspending (JavaScript). A watch with side effects runs again on each refresh.": "仅适用于无需暂停即可计算的调试器(JavaScript)。带副作用的监视表达式在每次刷新时都会再次执行。",
|
||||
"Show Only Matches": "仅显示匹配项",
|
||||
"JUnit5 Test Method": "JUnit5 测试方法",
|
||||
"Kotlin JUnit5 Test Method": "Kotlin JUnit5 测试方法",
|
||||
"Go Test Function": "Go 测试函数",
|
||||
"Rust Test Function": "Rust 测试函数",
|
||||
"Vitest Test": "Vitest 测试",
|
||||
"PHPUnit Test Method": "PHPUnit 测试方法",
|
||||
"pytest Test Function": "pytest 测试函数",
|
||||
"Rust File": "Rust 文件",
|
||||
"TypeScript File": "TypeScript 文件",
|
||||
"React Component": "React 组件",
|
||||
"JavaScript File": "JavaScript 文件",
|
||||
"Python File": "Python 文件",
|
||||
"Go File": "Go 文件",
|
||||
"Go Module": "Go 模块",
|
||||
"PHP File": "PHP 文件",
|
||||
"PHP Class": "PHP 类",
|
||||
"Java Class": "Java 类",
|
||||
"C# Class": "C# 类",
|
||||
"Kotlin Class/File": "Kotlin 类/文件",
|
||||
"HTML File": "HTML 文件",
|
||||
"Markdown File": "Markdown 文件",
|
||||
"Stylesheet": "样式表",
|
||||
"JSON File": "JSON 文件",
|
||||
"YAML File": "YAML 文件",
|
||||
"TOML File": "TOML 文件",
|
||||
"EditorConfig File": "EditorConfig 文件",
|
||||
".gitignore File": ".gitignore 文件"
|
||||
"Where the debugger can do it without suspending (JavaScript). A watch with side effects runs again on each refresh.": "仅适用于无需暂停即可计算的调试器(JavaScript)。带副作用的监视表达式在每次刷新时都会再次执行。"
|
||||
}
|
||||
@@ -193,35 +193,9 @@
|
||||
"menu.file.closeProject": "关闭项目",
|
||||
"menu.remote.reopenInContainer": "在容器中重新打开",
|
||||
"menu.remote.reloadEnvironment": "重新加载环境",
|
||||
"menu.file.new": "文件…",
|
||||
"menu.file.newScratchFile": "临时文件",
|
||||
"menu.new": "新建",
|
||||
"menu.workspace.create": "工作区…",
|
||||
"menu.workspace.open": "打开工作区…",
|
||||
"menu.workspace.manage": "管理工作区…",
|
||||
"menu.file.new": "新建…",
|
||||
"menu.file.newScratchFile": "新建临时文件…",
|
||||
"menu.file.openInNewWindow": "在新窗口中打开…",
|
||||
"menu.file.openFile": "打开文件…",
|
||||
"menu.remote.connect": "远程开发…",
|
||||
"menu.remote.disconnect": "断开与远程主机的连接",
|
||||
"menu.navigationBar": "导航栏",
|
||||
"menu.run.updateApplication": "更新应用",
|
||||
"menu.ssh.startSession": "启动 SSH 会话…",
|
||||
"menu.ssh.configurations": "SSH 配置…",
|
||||
"menu.deployment": "部署",
|
||||
"menu.deployment.uploadToDefault": "上传到默认服务器",
|
||||
"menu.deployment.uploadTo": "上传到…",
|
||||
"menu.deployment.downloadFromDefault": "从默认服务器下载",
|
||||
"menu.deployment.downloadFrom": "下载自…",
|
||||
"menu.deployment.syncWith": "与已部署版本同步…",
|
||||
"menu.deployment.deleteFromServer": "从服务器删除",
|
||||
"menu.deployment.toggleAutoUpload": "自动上传",
|
||||
"menu.deployment.browseRemoteHost": "浏览远程主机",
|
||||
"menu.deployment.openInBrowser": "在浏览器中打开",
|
||||
"menu.deployment.configure": "配置…",
|
||||
"menu.window.mergeAllWindows": "合并所有项目窗口",
|
||||
"menu.window.detachTab": "将标签页移到新窗口",
|
||||
"menu.window.nextTab": "下一个项目标签页",
|
||||
"menu.window.previousTab": "上一个项目标签页",
|
||||
"menu.project.attach": "附加项目…",
|
||||
"menu.file.openProject": "打开…",
|
||||
"menu.file.save": "全部保存",
|
||||
@@ -415,7 +389,7 @@
|
||||
"menu.github.createPullRequest": "创建拉取请求…",
|
||||
"menu.github.checkoutPullRequest": "签出拉取请求…",
|
||||
"menu.github.openInBrowser": "在 GitHub 上打开",
|
||||
"menu.file.newProject": "项目…",
|
||||
"menu.file.newProject": "新建项目…",
|
||||
"menu.file.renameProject": "重命名项目…",
|
||||
"menu.file.reloadAllFromDisk": "从磁盘全部重新加载",
|
||||
"menu.file.invalidateCaches": "清除缓存…",
|
||||
|
||||
@@ -156,42 +156,6 @@
|
||||
font-size: var(--fs-ui);
|
||||
pointer-events: none;
|
||||
}
|
||||
/* The field variant sits on the 32px toolbar row above the tree, covering its first buttons. */
|
||||
.speedField {
|
||||
top: auto;
|
||||
bottom: calc(100% + 2px);
|
||||
left: 6px;
|
||||
gap: 4px;
|
||||
height: 28px;
|
||||
min-width: 160px;
|
||||
padding: 0 2px 0 8px;
|
||||
box-shadow: none;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.speedField .speedQuery {
|
||||
margin-left: 2px;
|
||||
}
|
||||
.caret {
|
||||
flex-shrink: 0;
|
||||
width: 1px;
|
||||
height: 16px;
|
||||
margin: 0 auto 0 -2px;
|
||||
background: var(--fg-strong);
|
||||
animation: caret-blink 1s steps(1) infinite;
|
||||
}
|
||||
@keyframes caret-blink {
|
||||
50% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.caret {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
.onlyMatches {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.speedQuery {
|
||||
color: var(--fg-strong);
|
||||
overflow: hidden;
|
||||
|
||||
@@ -283,19 +283,6 @@ describe("Tree speed search", () => {
|
||||
for (const c of "App") key(c);
|
||||
expect(labels(tree)).toEqual(["src", "main", "App.tsx"]);
|
||||
});
|
||||
|
||||
it("the field's toggle switches to showing only matches without ending the search", () => {
|
||||
const { tree, key } = setup({ defaultExpanded: ["src", "main"], speedSearchField: true });
|
||||
for (const c of "App") key(c);
|
||||
expect(labels(tree)).toEqual(["src", "main", "App.tsx", "index.ts", "util.ts", "README.md"]);
|
||||
const toggle = screen.getByRole("button", { name: "Show Only Matches" });
|
||||
expect(fireEvent.mouseDown(toggle)).toBe(false);
|
||||
fireEvent.click(toggle);
|
||||
expect(toggle).toHaveAttribute("aria-pressed", "true");
|
||||
expect(labels(tree)).toEqual(["src", "main", "App.tsx"]);
|
||||
fireEvent.click(toggle);
|
||||
expect(labels(tree)).toHaveLength(6);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Tree occurrences", () => {
|
||||
|
||||
+8
-38
@@ -26,7 +26,6 @@ import { useVirtualizer } from "@tanstack/react-virtual";
|
||||
import { Icon, type IconName } from "./icons";
|
||||
import { HighlightedText } from "./HighlightedText";
|
||||
import { Spinner } from "./Feedback";
|
||||
import { IconButton } from "./Button";
|
||||
import { fuzzyMatch } from "./match";
|
||||
import { acquirePopup } from "./popupState";
|
||||
import styles from "./Tree.module.css";
|
||||
@@ -119,11 +118,6 @@ export interface TreeProps<T> {
|
||||
|
||||
speedSearch?: boolean;
|
||||
speedSearchMode?: "highlight" | "filter";
|
||||
/**
|
||||
* Speed search shows as a field over the bar right above the tree (a tool window's toolbar)
|
||||
* instead of a popup over its first rows, with a toggle to show only the matches.
|
||||
*/
|
||||
speedSearchField?: boolean;
|
||||
rowHeight?: number;
|
||||
indent?: number;
|
||||
className?: string;
|
||||
@@ -268,7 +262,6 @@ export function Tree<T>(props: TreeProps<T>) {
|
||||
onContextMenu,
|
||||
speedSearch = true,
|
||||
speedSearchMode = "highlight",
|
||||
speedSearchField = false,
|
||||
rowHeight: fixedRowHeight,
|
||||
indent = 20,
|
||||
className,
|
||||
@@ -282,8 +275,6 @@ export function Tree<T>(props: TreeProps<T>) {
|
||||
const [lead, setLead] = useState<string | null>(() => [...selected][0] ?? null);
|
||||
const [anchor, setAnchor] = useState<string | null>(null);
|
||||
const [query, setQuery] = useState("");
|
||||
const [onlyMatches, setOnlyMatches] = useState(false);
|
||||
const filterMatches = speedSearchMode === "filter" || (speedSearchField && onlyMatches);
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
const baseId = useId();
|
||||
|
||||
@@ -329,14 +320,14 @@ export function Tree<T>(props: TreeProps<T>) {
|
||||
}, [allRows, query, getLabel]);
|
||||
|
||||
const rows = useMemo(() => {
|
||||
if (!query || !filterMatches) return allRows;
|
||||
if (!query || speedSearchMode !== "filter") return allRows;
|
||||
const keep = new Set<number>();
|
||||
allRows.forEach((r, i) => {
|
||||
if (!matchMap.has(r.key)) return;
|
||||
for (let j = i; j >= 0 && !keep.has(j); j = allRows[j]!.parent) keep.add(j);
|
||||
});
|
||||
return allRows.filter((_, i) => keep.has(i));
|
||||
}, [allRows, matchMap, query, filterMatches]);
|
||||
}, [allRows, matchMap, query, speedSearchMode]);
|
||||
|
||||
const byKey = useMemo(() => new Map(allRows.map((r) => [r.key, r])), [allRows]);
|
||||
const emptyState = !rows.length && !!empty && !query;
|
||||
@@ -815,33 +806,12 @@ export function Tree<T>(props: TreeProps<T>) {
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
{query &&
|
||||
(speedSearchField ? (
|
||||
// Typing stays in the tree: a press here must not take its focus, which would end the search.
|
||||
<div
|
||||
className={clsx(styles.speedSearch, styles.speedField, noMatch && styles.noMatch)}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
>
|
||||
<Icon name="search" size={14} />
|
||||
<span className={styles.speedQuery} role="status" aria-live="polite">
|
||||
{query}
|
||||
</span>
|
||||
<span className={styles.caret} aria-hidden="true" />
|
||||
<IconButton
|
||||
icon="filter"
|
||||
size="small"
|
||||
className={styles.onlyMatches}
|
||||
title="Show Only Matches"
|
||||
pressed={onlyMatches}
|
||||
onClick={() => setOnlyMatches(!onlyMatches)}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className={clsx(styles.speedSearch, noMatch && styles.noMatch)} role="status" aria-live="polite">
|
||||
<Icon name="search" size={12} />
|
||||
<span className={styles.speedQuery}>{query}</span>
|
||||
</div>
|
||||
))}
|
||||
{query && (
|
||||
<div className={clsx(styles.speedSearch, noMatch && styles.noMatch)} role="status" aria-live="polite">
|
||||
<Icon name="search" size={12} />
|
||||
<span className={styles.speedQuery}>{query}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ import {
|
||||
} from "./store";
|
||||
import { contentTabRegistry } from "./content";
|
||||
import styles from "./ToolWindows.module.css";
|
||||
import { tx, useI18n } from "@/platform/i18n";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
/** The window's title in the UI language; a plugin's stays as written. */
|
||||
function titleOf(tw: ToolWindowContribution): string {
|
||||
@@ -756,8 +756,6 @@ function HeaderRow({
|
||||
const [titleOpen, setTitleOpen] = useState(false);
|
||||
const titleRef = useRef<HTMLButtonElement>(null);
|
||||
const showTitle = title && !(tw.headerContent && tw.tabsReplaceTitle);
|
||||
// The title is translated here: show it in a language chosen while the window is open.
|
||||
useI18n((s) => s.texts);
|
||||
|
||||
const useHeaderMenu = typeof tw.headerMenu === "function" ? tw.headerMenu : staticHeaderMenu(tw.headerMenu);
|
||||
const own = useHeaderMenu(tw.id);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { act, fireEvent, render, screen } from "@testing-library/react";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { afterEach, beforeEach, expect, it, vi } from "vitest";
|
||||
import { Tabs } from "@/ui";
|
||||
import { useI18n } from "@/platform/i18n";
|
||||
import { registerToolWindow } from "../contributions";
|
||||
import { installToolWindowActions } from "./actions";
|
||||
import { isToolWindowVisible, resetToolWindowLayout, showToolWindow, useToolWindowLayout, viewModeOf } from "./store";
|
||||
@@ -119,16 +118,3 @@ it("a menu opened from the header returns focus to the window, not the editor",
|
||||
expect(screen.queryByRole("menu")).toBeNull();
|
||||
expect(document.activeElement).toBe(options);
|
||||
});
|
||||
|
||||
it("shows the header title in a language chosen while the window is open", () => {
|
||||
showToolWindow("run");
|
||||
render(<ToolWindowLayout editor={null} />);
|
||||
expect(header("run").textContent).toContain("Run");
|
||||
const before = useI18n.getState().texts;
|
||||
try {
|
||||
act(() => useI18n.setState({ texts: { Run: "运行" } }));
|
||||
expect(header("run").textContent).toContain("运行");
|
||||
} finally {
|
||||
act(() => useI18n.setState({ texts: before }));
|
||||
}
|
||||
});
|
||||
Reference in new issue
Заблокувати користувача