Порівняти коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
bcb2728bcd | ||
|
|
5c50215d39 | ||
|
|
03ed6be82d | ||
|
|
beee4cb633 | ||
|
|
21c2934a36 | ||
|
|
d9ff048a14 | ||
|
|
a8ce8048f8 | ||
|
|
831cd59ab0 | ||
|
|
ec41d3c4a0 | ||
|
|
6bcf99778a | ||
|
|
6d59cf377c | ||
|
|
0217586e2e | ||
|
|
db3b17d863 | ||
|
|
f0261719b8 | ||
|
|
b556a064e3 | ||
|
|
feb882ed10 | ||
|
|
e82d766804 | ||
|
|
5e099ecb5b | ||
|
|
7531834b3c | ||
|
|
0ab50e0dd4 |
No files matched your search
@@ -33,6 +33,3 @@ playwright-report/
|
||||
# Local AI agent files
|
||||
CLAUDE.md
|
||||
.claude/
|
||||
|
||||
# Local reference screenshots
|
||||
pycharm-screenshots/
|
||||
@@ -3974,7 +3974,7 @@ checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
|
||||
|
||||
[[package]]
|
||||
name = "ide-agent"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-jsonrpc",
|
||||
@@ -3992,7 +3992,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-analysis"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"ast-grep-core",
|
||||
"ide-core",
|
||||
@@ -4006,7 +4006,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-build"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"dunce",
|
||||
@@ -4021,24 +4021,23 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-clipboard"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
|
||||
[[package]]
|
||||
name = "ide-core"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"specta",
|
||||
"specta-typescript",
|
||||
"thiserror 2.0.21",
|
||||
"tokio-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ide-coverage"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-run",
|
||||
@@ -4052,7 +4051,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-dap"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-jsonrpc",
|
||||
@@ -4069,7 +4068,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-db"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"futures",
|
||||
@@ -4088,7 +4087,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-docker"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"libc",
|
||||
@@ -4102,7 +4101,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-github"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-vcs",
|
||||
@@ -4116,7 +4115,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-host"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"dunce",
|
||||
@@ -4157,7 +4156,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-http"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"parking_lot",
|
||||
@@ -4175,7 +4174,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-index"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"criterion",
|
||||
@@ -4197,7 +4196,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-jsonrpc"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"futures",
|
||||
@@ -4213,7 +4212,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-language"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"criterion",
|
||||
@@ -4222,7 +4221,6 @@ dependencies = [
|
||||
"parking_lot",
|
||||
"regex-lite",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"specta",
|
||||
"toml 0.9.12+spec-1.1.0",
|
||||
"tracing",
|
||||
@@ -4267,7 +4265,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-lsp"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"globset",
|
||||
@@ -4290,7 +4288,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-plugin"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-language",
|
||||
@@ -4308,7 +4306,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-profiler"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-run",
|
||||
@@ -4321,7 +4319,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-remote"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"globset",
|
||||
"ide-core",
|
||||
@@ -4338,7 +4336,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-run"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"ide-core",
|
||||
@@ -4358,7 +4356,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-sdk"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"ide-core",
|
||||
@@ -4377,7 +4375,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-search"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"globset",
|
||||
@@ -4397,7 +4395,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-spell"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"parking_lot",
|
||||
@@ -4410,7 +4408,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-ssh"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"flate2",
|
||||
@@ -4429,7 +4427,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-syntax"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-language",
|
||||
@@ -4444,7 +4442,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-terminal"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"libc",
|
||||
@@ -4457,7 +4455,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-text"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"ide-core",
|
||||
@@ -4469,7 +4467,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-tools"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"hex",
|
||||
@@ -4489,7 +4487,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-vcs"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"gix",
|
||||
@@ -4506,7 +4504,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-vfs"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"chardetng",
|
||||
"dunce",
|
||||
@@ -4527,7 +4525,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-web"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"open",
|
||||
@@ -4543,7 +4541,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-workspace"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"dunce",
|
||||
@@ -5968,7 +5966,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openidea"
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"dirs 6.0.0",
|
||||
|
||||
@@ -3,7 +3,7 @@ resolver = "3"
|
||||
members = ["crates/*", "src-tauri"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.19"
|
||||
version = "0.1.18"
|
||||
edition = "2024"
|
||||
rust-version = "1.96"
|
||||
license = "Apache-2.0"
|
||||
@@ -46,7 +46,6 @@ serde_json = "1"
|
||||
toml = "0.9"
|
||||
toml_edit = "0.25"
|
||||
specta = { version = "=2.0.0-rc.25", features = ["derive"] }
|
||||
specta-typescript = "0.0.12"
|
||||
|
||||
# async & concurrency
|
||||
tokio = { version = "1", features = ["rt-multi-thread", "macros", "sync", "time", "process", "io-util", "fs"] }
|
||||
|
||||
@@ -79,25 +79,15 @@ user's app-data directory only when the user asks; none of them ships with OpenI
|
||||
unmodified, and its source is available from the repository above.
|
||||
- **Eclipse JDT Language Server** (jdtls): EPL-2.0, from download.eclipse.org.
|
||||
|
||||
## en_US / en_GB Hunspell dictionaries
|
||||
## en_US Hunspell dictionary
|
||||
|
||||
`crates/ide-spell/src/dict/en_US.{aff,dic}` (the spell checker's bundled dictionary) is the
|
||||
SCOWL-derived en_US Hunspell dictionary (version 2020.12.07, from the `dictionary-en` npm
|
||||
package 4.0.0), copied unmodified. Copyright Kevin Atkinson and the SCOWL / Hunspell
|
||||
dictionary contributors; MIT- and BSD-style licences, full text in
|
||||
`crates/ide-spell/src/dict/LICENSE-en_US`. `crates/ide-spell/src/dict/en_GB-extra.dic` holds the
|
||||
entries of the matching en_GB dictionary (`dictionary-en-gb` npm package 3.0.0, same SCOWL
|
||||
version, licence and affix file) that en_US lacks. They are checked with the
|
||||
`crates/ide-spell/src/dict/LICENSE-en_US`. It is checked with the
|
||||
[spellbook](https://github.com/helix-editor/spellbook) crate (MPL-2.0).
|
||||
|
||||
## cspell-dicts word lists
|
||||
|
||||
`crates/ide-spell/src/dict/cspell-terms.txt` (programming terms the spell checker accepts)
|
||||
is derived from the software-terms, typescript, node, rust, fullstack, golang, java, cpp,
|
||||
shell and css dictionaries of [cspell-dicts](https://github.com/streetsidesoftware/cspell-dicts)
|
||||
(October 2026): lowercased, filtered and merged by OpenIDEA. Copyright Street Side Software;
|
||||
MIT licence, full text in `crates/ide-spell/src/dict/LICENSE-cspell-dicts`.
|
||||
|
||||
## nvim-treesitter queries
|
||||
|
||||
`crates/ide-syntax/queries/<grammar>/locals.scm` are derived from the `locals.scm`
|
||||
|
||||
@@ -191,7 +191,7 @@ struct Task {
|
||||
dirty: Mutex<BTreeSet<usize>>,
|
||||
flush_scheduled: AtomicBool,
|
||||
stderr: Mutex<VecDeque<String>>,
|
||||
/// Set by `delete`; held while saving.
|
||||
/// Set by `delete`; held while saving, so a late save can't bring the file back.
|
||||
deleted: Mutex<bool>,
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ impl AgentManager {
|
||||
if matches!(f.task.status, AgentStatus::Running | AgentStatus::NeedsInput | AgentStatus::Starting) {
|
||||
f.task.status = AgentStatus::Ready;
|
||||
let mut timeline = Timeline::from_entries(std::mem::take(&mut f.entries));
|
||||
timeline.end_turn(None);
|
||||
timeline.end_turn();
|
||||
f.entries = timeline.entries;
|
||||
}
|
||||
let task = Task::restore(f, shared.clone());
|
||||
@@ -577,13 +577,7 @@ impl Task {
|
||||
|
||||
fn cwd_and_base(&self) -> (PathBuf, String) {
|
||||
let s = self.state.lock();
|
||||
// In the project's own checkout the user commits too: compare against the current HEAD,
|
||||
// as the Commit tool window does, so commits made since the task started drop out.
|
||||
let base = match s.task.isolation {
|
||||
Isolation::Local => None,
|
||||
Isolation::Worktree => s.task.base_commit.clone(),
|
||||
};
|
||||
(s.task.cwd.0.clone(), base.unwrap_or_else(|| "HEAD".into()))
|
||||
(s.task.cwd.0.clone(), s.task.base_commit.clone().unwrap_or_else(|| "HEAD".into()))
|
||||
}
|
||||
|
||||
fn emit_task(&self) {
|
||||
@@ -604,11 +598,6 @@ impl Task {
|
||||
}
|
||||
|
||||
fn persist(&self) {
|
||||
// Held from snapshot to rename, so saves land in order and none follows a delete.
|
||||
let deleted = self.deleted.lock();
|
||||
if *deleted {
|
||||
return;
|
||||
}
|
||||
let bytes = {
|
||||
let s = self.state.lock();
|
||||
serde_json::to_vec(&TaskFile {
|
||||
@@ -619,6 +608,10 @@ impl Task {
|
||||
})
|
||||
};
|
||||
let path = self.shared.paths.store_dir.join(format!("{}.json", self.id));
|
||||
let deleted = self.deleted.lock();
|
||||
if *deleted {
|
||||
return;
|
||||
}
|
||||
if let Err(e) = bytes.map_err(|e| e.to_string()).and_then(|b| write_file(&path, &b)) {
|
||||
tracing::warn!("saving agent task {}: {e}", self.id);
|
||||
}
|
||||
@@ -665,7 +658,7 @@ impl Task {
|
||||
loop {
|
||||
let result = self.turn(&prompt).await;
|
||||
tokio::time::sleep(TURN_GRACE).await;
|
||||
let changed = self.state.lock().timeline.end_turn(Some(now_ms()));
|
||||
let changed = self.state.lock().timeline.end_turn();
|
||||
self.mark_dirty(changed);
|
||||
let send_now = self.send_now.swap(false, Ordering::AcqRel);
|
||||
let next = {
|
||||
@@ -709,12 +702,7 @@ impl Task {
|
||||
.map(|f| file_name(&f.0))
|
||||
.chain(prompt.images.iter().map(|i| i.name.clone().unwrap_or_else(|| "image".into())))
|
||||
.collect();
|
||||
self.push_entry(AgentEntry::User {
|
||||
text: prompt.text.clone(),
|
||||
attachments,
|
||||
sent_ms: Some(now_ms()),
|
||||
done_ms: None,
|
||||
});
|
||||
self.push_entry(AgentEntry::User { text: prompt.text.clone(), attachments });
|
||||
// Launching the agent can take a while (`npx` fetches its adapter on first use).
|
||||
let starting = self.live.lock().as_ref().is_none_or(|l| l.peer.is_closed());
|
||||
self.set_status(if starting { AgentStatus::Starting } else { AgentStatus::Running }, None);
|
||||
@@ -882,16 +870,6 @@ impl Task {
|
||||
|
||||
fn on_update(self: &Arc<Self>, update: &Value) {
|
||||
let kind = update.get("sessionUpdate").and_then(Value::as_str).unwrap_or_default();
|
||||
if kind == "session_info_update" {
|
||||
// The agent's own title for the session replaces the first line of the prompt.
|
||||
let title = update.get("title").and_then(Value::as_str).map(str::trim).filter(|t| !t.is_empty());
|
||||
if let Some(title) = title {
|
||||
self.state.lock().task.title = title.to_owned();
|
||||
self.persist();
|
||||
self.emit_task();
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Session state (also while `session/load` replays history).
|
||||
let provider = self.state.lock().task.provider.clone();
|
||||
let task_changed = {
|
||||
|
||||
@@ -44,7 +44,7 @@ pub struct AgentTask {
|
||||
pub branch: Option<String>,
|
||||
/// Branch (or revision) the worktree was created from.
|
||||
pub base: Option<String>,
|
||||
/// Commit the task's changes are compared against (worktree tasks; local ones use `HEAD`).
|
||||
/// Commit the task's changes are compared against.
|
||||
pub base_commit: Option<String>,
|
||||
/// Why the task failed, when it did.
|
||||
pub error: Option<String>,
|
||||
@@ -194,12 +194,6 @@ pub enum AgentEntry {
|
||||
text: String,
|
||||
/// Names of the files and images sent with it.
|
||||
attachments: Vec<String>,
|
||||
/// When it was sent (ms since the epoch); `None` in tasks saved before this was kept.
|
||||
#[serde(default)]
|
||||
sent_ms: Option<f64>,
|
||||
/// When the turn it started ended; `None` while it runs or when it was cut off.
|
||||
#[serde(default)]
|
||||
done_ms: Option<f64>,
|
||||
},
|
||||
Agent {
|
||||
text: String,
|
||||
|
||||
@@ -66,7 +66,6 @@ impl Handler for FakeAgent {
|
||||
"availableCommands": [{"name": "review", "description": "Review", "input": {"hint": "focus"}}]}),
|
||||
);
|
||||
self.update(&session, json!({"sessionUpdate": "usage_update", "used": 50, "size": 1000}));
|
||||
self.update(&session, json!({"sessionUpdate": "session_info_update", "title": "Lexer fix"}));
|
||||
self.say(&session, "Hi");
|
||||
self.update(
|
||||
&session,
|
||||
@@ -227,7 +226,6 @@ async fn a_task_runs_asks_for_permission_and_survives_a_restart() {
|
||||
assert_eq!((modes.via, modes.current.as_deref()), (AgentConfigVia::Mode, Some("ask")));
|
||||
assert_eq!(t.commands.iter().map(|c| c.name.as_str()).collect::<Vec<_>>(), ["review"]);
|
||||
assert_eq!(t.usage.as_ref().map(|u| (u.used, u.size)), Some((50, 1000)));
|
||||
assert_eq!(t.title, "Lexer fix", "the agent's title replaces the prompt's first line");
|
||||
}
|
||||
mgr.set_config(&task.id, "mode", "code".into()).await.unwrap();
|
||||
assert!(agent.calls.lock().contains(&"session/set_mode \"code\"".to_owned()));
|
||||
@@ -240,17 +238,10 @@ async fn a_task_runs_asks_for_permission_and_survives_a_restart() {
|
||||
events.iter().any(|e| matches!(e, AgentEvent::Task { task } if task.status == AgentStatus::NeedsInput))
|
||||
);
|
||||
let last_entry = events.iter().rev().find_map(|e| match e {
|
||||
AgentEvent::Entry { index, entry, .. } if !matches!(entry, AgentEntry::User { .. }) => {
|
||||
Some((*index, entry.clone()))
|
||||
}
|
||||
AgentEvent::Entry { index, entry, .. } => Some((*index, entry.clone())),
|
||||
_ => None,
|
||||
});
|
||||
assert_eq!(last_entry, Some((4, AgentEntry::Agent { text: "chose yes".into() })));
|
||||
// The turn's end is recorded on the message that started it.
|
||||
assert!(events.iter().any(|e| matches!(
|
||||
e,
|
||||
AgentEvent::Entry { index: 0, entry: AgentEntry::User { sent_ms: Some(_), done_ms: Some(_), .. }, .. }
|
||||
)));
|
||||
}
|
||||
let providers = mgr.providers();
|
||||
let claude = providers.iter().find(|p| p.id == "claude").unwrap();
|
||||
@@ -262,7 +253,6 @@ async fn a_task_runs_asks_for_permission_and_survives_a_restart() {
|
||||
let agent2 = Arc::new(FakeAgent::default());
|
||||
let mgr2 = manager(tmp.path(), agent2.clone());
|
||||
assert_eq!(mgr2.entries(&task.id).unwrap().len(), 5);
|
||||
assert_eq!(mgr2.task(&task.id).unwrap().state.lock().task.title, "Lexer fix");
|
||||
assert_eq!(mgr2.providers().iter().find(|p| p.id == "claude").unwrap().config.len(), 2);
|
||||
mgr2.prompt(&task.id, text("again"), false).await.unwrap();
|
||||
tokio::time::sleep(Duration::from_millis(50)).await;
|
||||
|
||||
@@ -166,17 +166,11 @@ impl Timeline {
|
||||
}
|
||||
}
|
||||
|
||||
/// Settles what an ended turn left open: running tools and pending permissions,
|
||||
/// and records when the turn ended (`done`) on the message that started it.
|
||||
pub fn end_turn(&mut self, done: Option<f64>) -> Vec<usize> {
|
||||
/// Settles what an ended turn left open: running tools and pending permissions.
|
||||
pub fn end_turn(&mut self) -> Vec<usize> {
|
||||
let mut changed = Vec::new();
|
||||
let started = self.entries.iter().rposition(|e| matches!(e, AgentEntry::User { .. }));
|
||||
for (i, e) in self.entries.iter_mut().enumerate() {
|
||||
match e {
|
||||
AgentEntry::User { done_ms, .. } if Some(i) == started && done.is_some() && done_ms.is_none() => {
|
||||
*done_ms = done;
|
||||
changed.push(i);
|
||||
}
|
||||
AgentEntry::Tool { status, .. }
|
||||
if matches!(status, AgentToolStatus::Pending | AgentToolStatus::Running) =>
|
||||
{
|
||||
@@ -292,27 +286,12 @@ mod tests {
|
||||
assert_eq!(t.apply(&plan("completed")).changed, vec![0]);
|
||||
t.apply(&json!({"sessionUpdate": "tool_call", "toolCallId": "c", "title": "Run", "status": "in_progress"}));
|
||||
t.push(AgentEntry::Permission { id: 1, title: "Run?".into(), options: vec![], chosen: None });
|
||||
assert_eq!(t.end_turn(None), vec![2, 3]);
|
||||
assert_eq!(t.end_turn(), vec![2, 3]);
|
||||
let again = Timeline::from_entries(t.entries.clone());
|
||||
assert_eq!(again.plan, Some(0));
|
||||
assert_eq!(again.tools.get("c"), Some(&2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn end_turn_records_when_the_last_message_was_answered() {
|
||||
let user =
|
||||
|sent: f64| AgentEntry::User { text: "q".into(), attachments: vec![], sent_ms: Some(sent), done_ms: None };
|
||||
let mut t = Timeline::default();
|
||||
t.push(user(1.0));
|
||||
t.push(AgentEntry::Agent { text: "a".into() });
|
||||
t.push(user(2.0));
|
||||
assert_eq!(t.end_turn(Some(5.0)), vec![2]);
|
||||
assert!(matches!(t.entries[0], AgentEntry::User { done_ms: None, .. }));
|
||||
assert!(matches!(t.entries[2], AgentEntry::User { done_ms: Some(5.0), .. }));
|
||||
// Settled once: a later end (a restart) doesn't move it.
|
||||
assert_eq!(t.end_turn(Some(9.0)), Vec::<usize>::new());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn long_output_keeps_its_tail() {
|
||||
let s = tail("é".repeat(MAX_OUTPUT));
|
||||
|
||||
@@ -10,6 +10,5 @@ dunce.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
specta.workspace = true
|
||||
specta-typescript.workspace = true
|
||||
thiserror.workspace = true
|
||||
tokio-util.workspace = true
|
||||
@@ -42,9 +42,6 @@ pub struct Settings {
|
||||
/// Language servers / debug adapters at a user-chosen location, by the
|
||||
/// command the language definition launches (`elixir-ls`, `codelldb`).
|
||||
pub tools: BTreeMap<String, ToolSettings>,
|
||||
/// Per language server, by name (`rust-analyzer`): launch and protocol
|
||||
/// options on top of the language definition, or a server defined here.
|
||||
pub language_servers: BTreeMap<String, LanguageServerSettings>,
|
||||
/// Editor › Inspections profiles.
|
||||
pub inspections: InspectionSettings,
|
||||
/// Editor › Natural Languages › Spelling.
|
||||
@@ -64,58 +61,6 @@ pub struct ToolSettings {
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
pub struct LanguageServerSettings {
|
||||
/// `false` keeps the server from starting for any language.
|
||||
pub enabled: bool,
|
||||
/// Executable to launch instead of the definition's; required for a server
|
||||
/// defined here (one with `languages`).
|
||||
pub command: String,
|
||||
/// Replaces the definition's arguments.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[specta(optional)]
|
||||
pub args: Option<Vec<String>>,
|
||||
/// Added to the server's environment.
|
||||
pub env: BTreeMap<String, String>,
|
||||
/// Merged over the definition's `initializationOptions` (sent once at startup).
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[specta(optional, type = Option<specta_typescript::Unknown>)]
|
||||
pub initialization_options: Option<serde_json::Value>,
|
||||
/// Answers the server's `workspace/configuration` requests; changes are pushed
|
||||
/// with `workspace/didChangeConfiguration` without a restart.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[specta(optional, type = Option<specta_typescript::Unknown>)]
|
||||
pub settings: Option<serde_json::Value>,
|
||||
/// Language ids a server defined here serves (`python`); empty for the servers
|
||||
/// of the language definitions.
|
||||
pub languages: Vec<String>,
|
||||
/// Files marking a workspace root for a server defined here (`pyproject.toml`).
|
||||
pub root_markers: Vec<String>,
|
||||
}
|
||||
|
||||
impl Default for LanguageServerSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enabled: true,
|
||||
command: String::new(),
|
||||
args: None,
|
||||
env: BTreeMap::new(),
|
||||
initialization_options: None,
|
||||
settings: None,
|
||||
languages: Vec::new(),
|
||||
root_markers: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LanguageServerSettings {
|
||||
/// A server defined in settings rather than by a language definition.
|
||||
pub fn is_custom(&self) -> bool {
|
||||
!self.languages.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
/// The configured executable for `command`, if any (`~/` not yet expanded).
|
||||
pub fn tool_path(&self, command: &str) -> Option<&str> {
|
||||
@@ -144,7 +89,6 @@ impl Default for Settings {
|
||||
actions_on_save: ActionsOnSaveSettings::default(),
|
||||
external_tools: Vec::new(),
|
||||
tools: BTreeMap::new(),
|
||||
language_servers: BTreeMap::new(),
|
||||
inspections: InspectionSettings::default(),
|
||||
spelling: SpellingSettings::default(),
|
||||
ssh: SshSettings::default(),
|
||||
|
||||
@@ -241,11 +241,6 @@ pub fn lsp_servers(host: &Host, window: &str) -> IdeResult<Vec<ServerInfo>> {
|
||||
Ok(host.project(window)?.lsp.servers())
|
||||
}
|
||||
|
||||
pub fn lsp_resend_diagnostics(host: &Host, window: &str) -> IdeResult<()> {
|
||||
host.project(window)?.lsp.resend_diagnostics();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn lsp_restart(host: &Host, window: &str, server: ServerId) -> IdeResult<()> {
|
||||
host.project(window)?.lsp.restart(server).await
|
||||
}
|
||||
@@ -354,7 +349,6 @@ pub(crate) fn register(d: &mut Dispatcher) {
|
||||
lsp_type_hierarchy(&c.host, &c.window, c.arg("doc")?, c.arg("pos")?, c.arg("direction")?).await
|
||||
});
|
||||
d.add("lsp_servers", |c| async move { lsp_servers(&c.host, &c.window) });
|
||||
d.add("lsp_resend_diagnostics", |c| async move { lsp_resend_diagnostics(&c.host, &c.window) });
|
||||
d.add("lsp_restart", |c| async move { lsp_restart(&c.host, &c.window, c.arg("server")?).await });
|
||||
d.add("apply_workspace_edit", |c| async move { apply_workspace_edit(&c.host, &c.window, c.arg("edit")?) });
|
||||
d.add("lsp_execute_command", |c| async move {
|
||||
|
||||
@@ -113,7 +113,7 @@ pub fn set_settings(
|
||||
host.ssh.set_configs(host.global_settings.effective().ssh.configs);
|
||||
}
|
||||
// A new interpreter / toolchain / server executable restarts the language servers it affects.
|
||||
if ["languages", "tools", "languageServers"].iter().any(|k| key == *k || key.starts_with(&format!("{k}."))) {
|
||||
if ["languages", "tools"].iter().any(|k| key == *k || key.starts_with(&format!("{k}."))) {
|
||||
for project in affected() {
|
||||
let lsp = project.lsp.clone();
|
||||
host.runtime.spawn(async move { lsp.reconfigure().await });
|
||||
|
||||
@@ -26,17 +26,6 @@ fn tools(host: &Host, window: &str) -> IdeResult<Tools> {
|
||||
Ok(Tools::new(&data).with_custom_paths(custom).with_found_paths(found.into_iter().collect()))
|
||||
}
|
||||
|
||||
/// The language definitions plus the servers defined in the window's settings.
|
||||
fn languages(host: &Host, window: &str) -> Vec<ide_language::LanguageConfig> {
|
||||
let settings = match host.project(window) {
|
||||
Ok(project) => project.settings.effective(),
|
||||
Err(_) => host.global_settings.effective(),
|
||||
};
|
||||
let mut langs = host.languages.all();
|
||||
ide_sdk::apply::with_custom_servers(&mut langs, &settings);
|
||||
langs
|
||||
}
|
||||
|
||||
fn join_err(e: impl std::fmt::Display) -> IdeError {
|
||||
IdeError::internal(e.to_string())
|
||||
}
|
||||
@@ -51,7 +40,7 @@ fn reconfigure_servers(host: &Host) {
|
||||
/// Status of every known language server / debug adapter and the languages using it.
|
||||
pub async fn tools_list(host: &Host, window: &str) -> IdeResult<Vec<ToolInfo>> {
|
||||
let tools = tools(host, window)?;
|
||||
let langs = languages(host, window);
|
||||
let langs = host.languages.all();
|
||||
tokio::task::spawn_blocking(move || tools.list(&langs)).await.map_err(join_err)
|
||||
}
|
||||
|
||||
@@ -65,7 +54,7 @@ pub async fn tools_install(
|
||||
on_event: Channel<InstallEvent>,
|
||||
) -> IdeResult<ToolInfo> {
|
||||
let tools = tools(host, window)?;
|
||||
let langs = languages(host, window);
|
||||
let langs = host.languages.all();
|
||||
let cancel = host.begin_request(request);
|
||||
let result = tokio::task::spawn_blocking(move || {
|
||||
tools.install(&name, &langs, &cancel, &|e| {
|
||||
@@ -85,7 +74,7 @@ pub async fn tools_install(
|
||||
/// Removes a tool the IDE installed.
|
||||
pub async fn tools_uninstall(host: &Host, window: &str, name: String) -> IdeResult<ToolInfo> {
|
||||
let tools = tools(host, window)?;
|
||||
let langs = languages(host, window);
|
||||
let langs = host.languages.all();
|
||||
let info = tokio::task::spawn_blocking(move || tools.uninstall(&name, &langs)).await.map_err(join_err)??;
|
||||
reconfigure_servers(host);
|
||||
Ok(info)
|
||||
|
||||
@@ -117,9 +117,7 @@ impl Host {
|
||||
let data_dir = self.data_dir.clone();
|
||||
lsp.set_config_hook(Box::new(move |cfg, server_root| {
|
||||
let effective = settings.effective();
|
||||
ide_sdk::apply::server_launch_overrides(cfg, &effective);
|
||||
ide_sdk::apply::configure_server(cfg, &root, server_root, &effective);
|
||||
ide_sdk::java::cap_java_home(cfg, &ide_sdk::java::installed_jdks());
|
||||
if cfg.name == "jdtls" {
|
||||
let bundles: Vec<PathBuf> =
|
||||
ide_tools::managed_bundle(&data_dir, "java-debug").into_iter().collect();
|
||||
@@ -151,13 +149,6 @@ impl Host {
|
||||
);
|
||||
ide_sdk::jdtls::launch_directly(cfg);
|
||||
}
|
||||
ide_sdk::apply::server_protocol_overrides(cfg, &effective);
|
||||
}));
|
||||
}
|
||||
{
|
||||
let settings = settings.clone();
|
||||
lsp.set_servers_hook(Box::new(move |language, defined| {
|
||||
ide_sdk::apply::language_servers(language.as_str(), defined, &settings.effective())
|
||||
}));
|
||||
}
|
||||
{
|
||||
|
||||
@@ -9,7 +9,6 @@ license.workspace = true
|
||||
ide-core.workspace = true
|
||||
ide-text.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
specta.workspace = true
|
||||
toml.workspace = true
|
||||
tree-sitter.workspace = true
|
||||
|
||||
@@ -72,10 +72,6 @@ pub struct LanguageServerConfig {
|
||||
/// JSON passed as `initializationOptions`.
|
||||
#[serde(default)]
|
||||
pub initialization_options: Option<toml::Value>,
|
||||
/// Answers `workspace/configuration`; without it the sections are looked up
|
||||
/// in `initialization_options`.
|
||||
#[serde(default)]
|
||||
pub settings: Option<serde_json::Value>,
|
||||
/// Human hint shown when the binary is missing.
|
||||
#[serde(default)]
|
||||
pub install_hint: Option<String>,
|
||||
@@ -91,10 +87,6 @@ pub struct LanguageServerConfig {
|
||||
/// basedpyright): only used while none of those is installed.
|
||||
#[serde(default)]
|
||||
pub fallback: bool,
|
||||
/// Newest Java release the server runs on (kotlin-language-server: 21). A
|
||||
/// newer `JAVA_HOME` is replaced by the newest installed JDK that fits.
|
||||
#[serde(default)]
|
||||
pub max_java: Option<u32>,
|
||||
/// Set by the settings hook when the server can't run here (jdtls without
|
||||
/// a JDK 21+); reported as the failure instead of launching it.
|
||||
#[serde(skip)]
|
||||
|
||||
@@ -79,24 +79,20 @@ fn is_name_leaf(kind: &str) -> bool {
|
||||
kind.contains("identifier") || kind == "name"
|
||||
}
|
||||
|
||||
/// Node kinds whose `name` field is a use, not a declaration.
|
||||
const USE_PARENTS: &[&str] =
|
||||
&["invocation", "call", "access", "scoped", "reference", "expression", "selector", "qualified", "use_", "import"];
|
||||
|
||||
/// Whether the identifier leaf under `cursor` is the name a declaration
|
||||
/// introduces (`fn name`, `let pattern`, `int *declarator`, parameters,
|
||||
/// `name = …` assignments) rather than a use of one.
|
||||
fn declares(cursor: &TreeCursor<'_>, node: &Node<'_>) -> bool {
|
||||
let parent = node.parent().map(|p| p.kind()).unwrap_or_default();
|
||||
// Paths and calls name what is declared elsewhere (`use a::b::name`, `a.name()`).
|
||||
let reference = ["scoped", "qualified", "invocation", "member_access", "use_", "import", "call"]
|
||||
.iter()
|
||||
.any(|k| parent.contains(k));
|
||||
match cursor.field_name() {
|
||||
// Uses name their target with a `name` field too: Java `s.substring()`,
|
||||
// C# `a.Name`, Rust `use a::b::name`.
|
||||
Some("name") => !USE_PARENTS.iter().any(|p| parent.contains(p)),
|
||||
Some("name") => !reference,
|
||||
Some("pattern" | "declarator") => true,
|
||||
Some("left") => parent.contains("assignment") || parent.contains("declarator"),
|
||||
// A parameter's name, not its type (`String text`).
|
||||
Some("type") => false,
|
||||
_ => parent.contains("parameter") && !node.kind().contains("type"),
|
||||
_ => parent.contains("parameter"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1320,13 +1320,4 @@ fn spelling_regions_cover_declared_names_only() {
|
||||
.map(|r| &rs[r.start..r.end])
|
||||
.collect();
|
||||
assert_eq!(names, ["run", "n"]);
|
||||
let java = "class Bird { String fly(String text) { return text.substring(1); } }\n";
|
||||
let names: Vec<&str> = syntax()
|
||||
.spelling_regions(&lang("java"), java)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|r| r.kind == SpellingKind::Name)
|
||||
.map(|r| &java[r.start..r.end])
|
||||
.collect();
|
||||
assert_eq!(names, ["Bird", "fly", "text"]);
|
||||
}
|
||||
@@ -125,18 +125,20 @@ impl ClientHandler {
|
||||
}
|
||||
|
||||
fn configuration(&self, params: &Value) -> Value {
|
||||
let options = all_settings(&self.server.effective_config());
|
||||
let options = self
|
||||
.server
|
||||
.effective_config()
|
||||
.initialization_options
|
||||
.as_ref()
|
||||
.and_then(|v| serde_json::to_value(v).ok())
|
||||
.unwrap_or(Value::Null);
|
||||
let items = params.get("items").and_then(Value::as_array).cloned().unwrap_or_default();
|
||||
Value::Array(
|
||||
items
|
||||
.iter()
|
||||
// vtsls asks for the whole configuration as section `""`.
|
||||
.map(|item| match item.get("section").and_then(Value::as_str).filter(|s| !s.is_empty()) {
|
||||
// The server's own section: its block under `settings` (basedpyright asks
|
||||
// `basedpyright` and `basedpyright.analysis`), else the options themselves.
|
||||
Some(section) if section == self.server.name => {
|
||||
options.get("settings").and_then(|s| s.get(section)).unwrap_or(&options).clone()
|
||||
}
|
||||
Some(section) if section == self.server.name => options.clone(),
|
||||
// Servers that take settings under `initializationOptions.settings`
|
||||
// (jdtls) ask for the same sections later.
|
||||
Some(section) => [&options, options.get("settings").unwrap_or(&Value::Null)]
|
||||
@@ -242,29 +244,3 @@ impl Handler for ClientHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What `workspace/configuration` sections are looked up in: the server's
|
||||
/// `initializationOptions` with its `settings` merged over them.
|
||||
pub(crate) fn all_settings(cfg: &ide_language::LanguageServerConfig) -> Value {
|
||||
let mut out = cfg.initialization_options.as_ref().and_then(|v| serde_json::to_value(v).ok()).unwrap_or(Value::Null);
|
||||
if let Some(settings) = &cfg.settings {
|
||||
merge(&mut out, settings.clone());
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn merge(base: &mut Value, layer: Value) {
|
||||
match (base, layer) {
|
||||
(Value::Object(base), Value::Object(layer)) => {
|
||||
for (k, v) in layer {
|
||||
match base.get_mut(&k) {
|
||||
Some(existing) => merge(existing, v),
|
||||
None => {
|
||||
base.insert(k, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
(base, layer) => *base = layer,
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,8 @@ impl LspManager {
|
||||
/// run doesn't prompt to install every language it meets.
|
||||
pub fn serves_path(&self, path: &Path) -> bool {
|
||||
let lang = self.languages.detect(path, None);
|
||||
self.language_servers(&lang).iter().any(|ls| {
|
||||
let Some(config) = self.languages.get(&lang) else { return false };
|
||||
config.language_servers.iter().any(|ls| {
|
||||
let mut cfg = ls.clone();
|
||||
if let Some(hook) = self.config_hook.read().clone() {
|
||||
hook(&mut cfg, &self.project_root);
|
||||
|
||||
@@ -56,12 +56,6 @@ use types::*;
|
||||
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
const COMPLETION_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
const LONG_TIMEOUT: Duration = Duration::from_secs(30);
|
||||
|
||||
/// How long a server may take to answer `initialize`. Some import the whole
|
||||
/// build there (kotlin-lsp, jdtls on a large Gradle project) and need minutes
|
||||
/// on a cold start; the status shows "starting" meanwhile, and a crash still
|
||||
/// ends the wait at once.
|
||||
const INITIALIZE_TIMEOUT: Duration = Duration::from_secs(300);
|
||||
/// How long a request waits for a server that is still initializing.
|
||||
const START_WAIT: Duration = Duration::from_secs(10);
|
||||
/// File moves may start a server (jdtls takes a while to import).
|
||||
@@ -74,9 +68,6 @@ pub type ApplyEditHook = Arc<dyn Fn(WorkspaceEdit) -> bool + Send + Sync>;
|
||||
/// settings before each launch; receives the server's workspace root.
|
||||
pub type ConfigFn = dyn Fn(&mut LanguageServerConfig, &Path) + Send + Sync;
|
||||
pub type ConfigHook = Arc<ConfigFn>;
|
||||
/// The servers a language uses, from its definition's list (user settings
|
||||
/// disable some and add others).
|
||||
pub type ServersFn = dyn Fn(&LanguageId, &[LanguageServerConfig]) -> Vec<LanguageServerConfig> + Send + Sync;
|
||||
|
||||
struct Attached {
|
||||
server: Arc<Server>,
|
||||
@@ -155,7 +146,6 @@ pub struct LspManager {
|
||||
docs: Mutex<HashMap<DocId, DocState>>,
|
||||
apply_edit_hook: RwLock<Option<ApplyEditHook>>,
|
||||
config_hook: RwLock<Option<ConfigHook>>,
|
||||
servers_hook: RwLock<Option<Arc<ServersFn>>>,
|
||||
candidates_hook: RwLock<Option<Arc<CandidateFn>>>,
|
||||
shutting_down: AtomicBool,
|
||||
/// `window/showMessage` texts already surfaced; servers repeat them on every restart/reconfigure.
|
||||
@@ -274,7 +264,6 @@ impl LspManager {
|
||||
docs: Mutex::new(HashMap::new()),
|
||||
apply_edit_hook: RwLock::new(None),
|
||||
config_hook: RwLock::new(None),
|
||||
servers_hook: RwLock::new(None),
|
||||
candidates_hook: RwLock::new(None),
|
||||
shutting_down: AtomicBool::new(false),
|
||||
shown_messages: Mutex::new(HashSet::new()),
|
||||
@@ -308,9 +297,10 @@ impl LspManager {
|
||||
/// The servers serving `path`: every regular one, and each `fallback` one
|
||||
/// only while all servers listed before it are missing.
|
||||
fn servers_for(&self, language: &LanguageId, path: &Path) -> Vec<Arc<Server>> {
|
||||
let Some(cfg) = self.languages.get(language) else { return Vec::new() };
|
||||
let mut out = Vec::new();
|
||||
let mut available_before = false;
|
||||
for sc in &self.language_servers(language) {
|
||||
for sc in &cfg.language_servers {
|
||||
if sc.fallback && available_before {
|
||||
continue;
|
||||
}
|
||||
@@ -321,18 +311,8 @@ impl LspManager {
|
||||
out
|
||||
}
|
||||
|
||||
/// The definitions of the servers `language` uses.
|
||||
fn language_servers(&self, language: &LanguageId) -> Vec<LanguageServerConfig> {
|
||||
let Some(cfg) = self.languages.get(language) else { return Vec::new() };
|
||||
match self.servers_hook.read().clone() {
|
||||
Some(hook) => hook(language, &cfg.language_servers),
|
||||
None => cfg.language_servers,
|
||||
}
|
||||
}
|
||||
|
||||
/// A server turned out to be missing: attach the fallbacks it was hiding
|
||||
/// to the open documents (and start them). Also attaches servers newly
|
||||
/// enabled in settings.
|
||||
/// to the open documents (and start them).
|
||||
fn attach_fallbacks(&self) {
|
||||
let open: Vec<(DocId, LanguageId, PathBuf)> =
|
||||
self.docs.lock().iter().map(|(id, d)| (*id, d.language.clone(), d.path.clone())).collect();
|
||||
@@ -427,7 +407,7 @@ impl LspManager {
|
||||
};
|
||||
|
||||
let init = self.initialize_params(&server);
|
||||
let result = tokio::time::timeout(INITIALIZE_TIMEOUT, peer.request::<_, Value>("initialize", init, None))
|
||||
let result = tokio::time::timeout(Duration::from_secs(60), peer.request::<_, Value>("initialize", init, None))
|
||||
.await
|
||||
.unwrap_or(Err(RpcError::Timeout));
|
||||
let caps = match result {
|
||||
@@ -452,14 +432,6 @@ impl LspManager {
|
||||
if let Err(e) = peer.notify("initialized", json!({})) {
|
||||
tracing::warn!("{}: {e}", server.name);
|
||||
}
|
||||
// Servers that don't ask with `workspace/configuration` only learn settings this way.
|
||||
let cfg = server.effective_config();
|
||||
if cfg.settings.is_some()
|
||||
&& let Err(e) =
|
||||
peer.notify("workspace/didChangeConfiguration", json!({ "settings": handler::all_settings(&cfg) }))
|
||||
{
|
||||
tracing::debug!("{}: didChangeConfiguration: {e}", server.name);
|
||||
}
|
||||
let run = Running { generation, peer: peer.clone(), caps: Arc::new(RwLock::new(caps)) };
|
||||
|
||||
// Publish readiness and (re)open attached documents atomically w.r.t. did_change.
|
||||
@@ -1806,11 +1778,6 @@ impl LspManager {
|
||||
*self.config_hook.write() = Some(Arc::from(hook));
|
||||
}
|
||||
|
||||
/// Installed by `src-tauri` to apply the servers enabled / defined in settings.
|
||||
pub fn set_servers_hook(&self, hook: Box<ServersFn>) {
|
||||
*self.servers_hook.write() = Some(Arc::from(hook));
|
||||
}
|
||||
|
||||
/// The server's base configuration with the settings hook applied.
|
||||
fn configured(&self, server: &Server) -> LanguageServerConfig {
|
||||
let mut cfg = server.config.clone();
|
||||
@@ -1822,26 +1789,11 @@ impl LspManager {
|
||||
|
||||
/// Restarts running servers whose settings-derived configuration changed
|
||||
/// (e.g. a new project interpreter); stopped ones pick it up on their next start.
|
||||
/// A change of `settings` alone reaches a running server without a restart.
|
||||
/// Servers no longer enabled stop; newly enabled ones attach to open documents.
|
||||
pub async fn reconfigure(&self) {
|
||||
self.stop_unlisted().await;
|
||||
let servers: Vec<Arc<Server>> = self.servers.lock().clone();
|
||||
for s in servers {
|
||||
let next = self.configured(&s);
|
||||
let current = s.effective_config();
|
||||
if next == current {
|
||||
continue;
|
||||
}
|
||||
let without_settings = |c: &LanguageServerConfig| LanguageServerConfig { settings: None, ..c.clone() };
|
||||
if let Some(run) = s.running()
|
||||
&& without_settings(&next) == without_settings(¤t)
|
||||
{
|
||||
s.set_effective_config(next);
|
||||
let params = json!({ "settings": handler::all_settings(&s.effective_config()) });
|
||||
if let Err(e) = run.peer.notify("workspace/didChangeConfiguration", params) {
|
||||
tracing::debug!("{}: didChangeConfiguration: {e}", s.name);
|
||||
}
|
||||
if next == s.effective_config() {
|
||||
continue;
|
||||
}
|
||||
match s.status() {
|
||||
@@ -1863,120 +1815,12 @@ impl LspManager {
|
||||
ide_core::event::ServerStatus::Stopped => {}
|
||||
}
|
||||
}
|
||||
self.attach_fallbacks();
|
||||
self.detach_shadowed_fallbacks().await;
|
||||
}
|
||||
|
||||
/// A server enabled again shadows the fallbacks attached in its place: they
|
||||
/// leave the open documents, and stop once no document uses them.
|
||||
async fn detach_shadowed_fallbacks(&self) {
|
||||
let open: Vec<(DocId, LanguageId, PathBuf)> =
|
||||
self.docs.lock().iter().map(|(id, d)| (*id, d.language.clone(), d.path.clone())).collect();
|
||||
let mut shadowed: Vec<(DocId, Vec<ide_core::ServerId>)> = Vec::new();
|
||||
for (id, language, path) in open {
|
||||
let configs = self.language_servers(&language);
|
||||
let wanted = self.servers_for(&language, &path);
|
||||
let docs = self.docs.lock();
|
||||
let Some(d) = docs.get(&id) else { continue };
|
||||
let gone: Vec<ide_core::ServerId> = d
|
||||
.servers
|
||||
.iter()
|
||||
.filter(|a| {
|
||||
!wanted.iter().any(|w| w.id == a.server.id)
|
||||
&& configs.iter().any(|c| c.fallback && c.name == a.server.name)
|
||||
})
|
||||
.map(|a| a.server.id)
|
||||
.collect();
|
||||
if !gone.is_empty() {
|
||||
shadowed.push((id, gone));
|
||||
}
|
||||
}
|
||||
if shadowed.is_empty() {
|
||||
return;
|
||||
}
|
||||
let mut detached: Vec<Arc<Server>> = Vec::new();
|
||||
{
|
||||
let mut docs = self.docs.lock();
|
||||
for (id, gone) in shadowed {
|
||||
let Some(d) = docs.get_mut(&id) else { continue };
|
||||
let (leaving, staying): (Vec<Attached>, Vec<Attached>) =
|
||||
d.servers.drain(..).partition(|a| gone.contains(&a.server.id));
|
||||
d.servers = staying;
|
||||
for a in leaving {
|
||||
if let Some(run) = a.server.running()
|
||||
&& a.opened_gen == Some(run.generation)
|
||||
&& run.caps.read().open_close
|
||||
&& let Err(e) =
|
||||
run.peer.notify("textDocument/didClose", json!({ "textDocument": { "uri": d.uri } }))
|
||||
{
|
||||
tracing::debug!("{}: didClose: {e}", a.server.name);
|
||||
}
|
||||
self.sink.emit(ide_core::IdeEvent::Diagnostics {
|
||||
path: d.path.clone().into(),
|
||||
source: a.server.name.clone(),
|
||||
items: Vec::new(),
|
||||
});
|
||||
if !detached.iter().any(|s| s.id == a.server.id) {
|
||||
detached.push(a.server);
|
||||
}
|
||||
}
|
||||
}
|
||||
let in_use = |s: &Arc<Server>| docs.values().any(|d| d.servers.iter().any(|a| a.server.id == s.id));
|
||||
detached.retain(|s| !in_use(s));
|
||||
}
|
||||
if detached.is_empty() {
|
||||
return;
|
||||
}
|
||||
for s in &detached {
|
||||
tracing::info!("{}: shadowed by an enabled server, stopping", s.name);
|
||||
self.stop_instance(s, true).await;
|
||||
}
|
||||
self.servers.lock().retain(|s| !detached.iter().any(|d| d.id == s.id));
|
||||
}
|
||||
|
||||
/// Stops and forgets the servers that none of their languages uses any more.
|
||||
async fn stop_unlisted(&self) {
|
||||
let servers: Vec<Arc<Server>> = self.servers.lock().clone();
|
||||
let unlisted: Vec<Arc<Server>> = servers
|
||||
.into_iter()
|
||||
.filter(|s| !s.languages().iter().any(|l| self.language_servers(l).iter().any(|c| c.name == s.name)))
|
||||
.collect();
|
||||
if unlisted.is_empty() {
|
||||
return;
|
||||
}
|
||||
for s in &unlisted {
|
||||
tracing::info!("{}: no longer enabled, stopping", s.name);
|
||||
self.stop_instance(s, true).await;
|
||||
}
|
||||
let gone = |s: &Arc<Server>| unlisted.iter().any(|u| u.id == s.id);
|
||||
self.servers.lock().retain(|s| !gone(s));
|
||||
for d in self.docs.lock().values_mut() {
|
||||
d.servers.retain(|a| !gone(&a.server));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_apply_edit_hook(&self, hook: Box<dyn Fn(WorkspaceEdit) -> bool + Send + Sync>) {
|
||||
*self.apply_edit_hook.write() = Some(Arc::from(hook));
|
||||
}
|
||||
|
||||
/// Emits every server's current diagnostics again: a UI that (re)loaded
|
||||
/// after they were published has missed those events.
|
||||
pub fn resend_diagnostics(&self) {
|
||||
let servers: Vec<Arc<Server>> = self.servers.lock().clone();
|
||||
for server in servers {
|
||||
let encoding = server.running().map(|r| r.caps.read().encoding).unwrap_or_default();
|
||||
let conv = self.conv(encoding);
|
||||
for (path, items) in server.diagnostics_by_path() {
|
||||
let items = items.into_iter().map(|d| convert::diagnostic(&conv, &path, d, &server.name)).collect();
|
||||
self.sink.emit(ide_core::IdeEvent::Diagnostics {
|
||||
path: path.into(),
|
||||
source: server.name.clone(),
|
||||
items,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn servers(&self) -> Vec<ServerInfo> {
|
||||
self.servers
|
||||
.lock()
|
||||
|
||||
@@ -461,11 +461,6 @@ impl Server {
|
||||
d.iter().flat_map(|(p, items)| items.iter().map(move |i| (p.clone(), i.clone()))).collect()
|
||||
}
|
||||
|
||||
/// The current diagnostics of each file that has some.
|
||||
pub fn diagnostics_by_path(&self) -> Vec<(PathBuf, Vec<lsp::Diagnostic>)> {
|
||||
self.diagnostics.lock().iter().map(|(p, d)| (p.clone(), d.clone())).collect()
|
||||
}
|
||||
|
||||
pub fn take_diagnostic_paths(&self) -> Vec<PathBuf> {
|
||||
self.published.lock().clear();
|
||||
self.diagnostics.lock().drain().map(|(p, _)| p).collect()
|
||||
|
||||
@@ -203,11 +203,9 @@ fn server_cfg(name: &str) -> LanguageServerConfig {
|
||||
env: Default::default(),
|
||||
root_markers: vec!["mock.toml".into()],
|
||||
initialization_options: Some(toml::Value::Table(toml::toml! { flag = true nested = { deep = 1 } })),
|
||||
settings: None,
|
||||
install_hint: Some(format!("install {name}")),
|
||||
connect: None,
|
||||
fallback: false,
|
||||
max_java: None,
|
||||
launch_error: None,
|
||||
}
|
||||
}
|
||||
@@ -523,15 +521,6 @@ async fn diagnostics_become_events_and_feed_code_actions() {
|
||||
assert_eq!(items[0].range, rng(0, 4, 0, 10));
|
||||
}
|
||||
|
||||
// A reloaded UI asks for them again.
|
||||
h.events.lock().clear();
|
||||
h.mgr.resend_diagnostics();
|
||||
let again = h.events.lock().iter().find_map(|e| match e {
|
||||
IdeEvent::Diagnostics { path, items, .. } => Some((path.clone(), items.len())),
|
||||
_ => None,
|
||||
});
|
||||
assert_eq!(again, Some((path.clone().into(), 2)));
|
||||
|
||||
s.respond(
|
||||
"textDocument/codeAction",
|
||||
json!([
|
||||
@@ -806,54 +795,6 @@ async fn launch_error_fails_without_starting_the_server() {
|
||||
assert!(!h.statuses("mock").contains(&ServerStatus::Crashed));
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn settings_changes_reach_servers_without_restarts() {
|
||||
let h = harness(&[("mock", incremental_caps()), ("extra", incremental_caps())]);
|
||||
let settings: Arc<Mutex<Option<Value>>> = Default::default();
|
||||
let disabled: Arc<Mutex<Vec<String>>> = Default::default();
|
||||
{
|
||||
let settings = settings.clone();
|
||||
h.mgr.set_config_hook(Box::new(move |cfg, _| cfg.settings = settings.lock().clone()));
|
||||
}
|
||||
{
|
||||
let disabled = disabled.clone();
|
||||
h.mgr.set_servers_hook(Box::new(move |_, defined| {
|
||||
defined.iter().filter(|c| !disabled.lock().contains(&c.name)).cloned().collect()
|
||||
}));
|
||||
}
|
||||
h.open("a.mk", "x");
|
||||
h.wait_status("mock", ServerStatus::Ready).await;
|
||||
h.wait_status("extra", ServerStatus::Ready).await;
|
||||
|
||||
// Only `settings` changed: pushed to the running server, which keeps running.
|
||||
let s = h.launcher.state("mock");
|
||||
*settings.lock() = Some(json!({ "nested": { "other": 2 } }));
|
||||
h.mgr.reconfigure().await;
|
||||
eventually(|| !s.notified("workspace/didChangeConfiguration").is_empty()).await;
|
||||
assert_eq!(
|
||||
s.notified("workspace/didChangeConfiguration")[0],
|
||||
json!({ "settings": { "flag": true, "nested": { "deep": 1, "other": 2 } } })
|
||||
);
|
||||
assert_eq!(s.launches.load(Ordering::SeqCst), 1);
|
||||
let cfg: Value = s
|
||||
.peer()
|
||||
.request("workspace/configuration", json!({ "items": [{ "section": "nested.other" }] }), None)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(cfg, json!([2]));
|
||||
|
||||
// Disabled: stopped and forgotten; enabled again: attached to the open document.
|
||||
disabled.lock().push("extra".into());
|
||||
h.mgr.reconfigure().await;
|
||||
assert_eq!(h.mgr.servers().iter().map(|s| s.name.as_str()).collect::<Vec<_>>(), ["mock"]);
|
||||
assert_eq!(h.statuses("extra").last(), Some(&ServerStatus::Stopped));
|
||||
disabled.lock().clear();
|
||||
h.mgr.reconfigure().await;
|
||||
h.wait_status("extra", ServerStatus::Ready).await;
|
||||
eventually(|| h.launcher.state("extra").notified("textDocument/didOpen").len() == 2).await;
|
||||
assert_eq!(s.launches.load(Ordering::SeqCst), 1);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn fallback_servers_only_run_when_the_preferred_one_is_missing() {
|
||||
// Preferred installed: the alternative is never started.
|
||||
@@ -878,40 +819,6 @@ async fn fallback_servers_only_run_when_the_preferred_one_is_missing() {
|
||||
assert!(h.mgr.hover(doc, Pos::new(0, 0), Default::default()).await.is_ok());
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn a_fallback_leaves_when_the_preferred_server_is_enabled_again() {
|
||||
let h = harness_with_fallbacks(&[("main", incremental_caps()), ("alt", incremental_caps())], &["alt"]);
|
||||
let disabled: Arc<Mutex<Vec<String>>> = Default::default();
|
||||
{
|
||||
let disabled = disabled.clone();
|
||||
h.mgr.set_servers_hook(Box::new(move |_, defined| {
|
||||
defined.iter().filter(|c| !disabled.lock().contains(&c.name)).cloned().collect()
|
||||
}));
|
||||
}
|
||||
let (doc, path) = h.open("a.mk", "x");
|
||||
let uri = uri_of(&path);
|
||||
h.wait_status("main", ServerStatus::Ready).await;
|
||||
assert!(h.statuses("alt").is_empty());
|
||||
|
||||
// Preferred disabled: the fallback takes over the open document.
|
||||
disabled.lock().push("main".into());
|
||||
h.mgr.reconfigure().await;
|
||||
h.wait_status("alt", ServerStatus::Ready).await;
|
||||
eventually(|| h.launcher.state("alt").docs.lock().contains_key(&uri)).await;
|
||||
assert_eq!(h.mgr.servers().iter().map(|s| s.name.as_str()).collect::<Vec<_>>(), ["alt"]);
|
||||
|
||||
// Enabled again: the fallback closes the document and stops.
|
||||
disabled.lock().clear();
|
||||
h.mgr.reconfigure().await;
|
||||
h.wait_status("main", ServerStatus::Ready).await;
|
||||
eventually(|| h.launcher.state("main").docs.lock().contains_key(&uri)).await;
|
||||
assert!(!h.launcher.state("alt").notified("textDocument/didClose").is_empty());
|
||||
assert_eq!(h.statuses("alt").last(), Some(&ServerStatus::Stopped));
|
||||
assert_eq!(h.mgr.servers().iter().map(|s| s.name.as_str()).collect::<Vec<_>>(), ["main"]);
|
||||
assert!(h.mgr.hover(doc, Pos::new(0, 0), Default::default()).await.is_ok());
|
||||
assert_eq!(h.launcher.state("alt").requested("textDocument/hover").len(), 0);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn implementations_per_position() {
|
||||
let caps = json!({ "textDocumentSync": 1, "implementationProvider": true });
|
||||
|
||||
@@ -70,11 +70,9 @@ async fn missing_binary_is_reported_with_install_hint() {
|
||||
env: Default::default(),
|
||||
root_markers: vec![],
|
||||
initialization_options: None,
|
||||
settings: None,
|
||||
install_hint: Some("npm i -g nope-ls".into()),
|
||||
connect: None,
|
||||
fallback: false,
|
||||
max_java: None,
|
||||
launch_error: None,
|
||||
};
|
||||
let (mgr, events) = manager(dir.path(), LanguageRegistry::from_configs(vec![lang("nope", "nope", server)]));
|
||||
@@ -200,11 +198,9 @@ async fn typescript_language_server_end_to_end() {
|
||||
env: Default::default(),
|
||||
root_markers: vec!["tsconfig.json".into()],
|
||||
initialization_options: None,
|
||||
settings: None,
|
||||
install_hint: None,
|
||||
connect: None,
|
||||
fallback: false,
|
||||
max_java: None,
|
||||
launch_error: None,
|
||||
};
|
||||
let (mgr, events) = manager(&root, LanguageRegistry::from_configs(vec![lang("typescript", "ts", server)]));
|
||||
@@ -244,11 +240,9 @@ fn npm_server(tools: &Path, name: &str, bin: &str, init: Option<serde_json::Valu
|
||||
env: Default::default(),
|
||||
root_markers: vec!["package.json".into()],
|
||||
initialization_options: init.map(|v| toml::Value::try_from(v).unwrap()),
|
||||
settings: None,
|
||||
install_hint: None,
|
||||
connect: None,
|
||||
fallback: false,
|
||||
max_java: None,
|
||||
launch_error: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ use crate::discover::{project_venv_python, workspace_tsdk};
|
||||
use crate::exec::{path_with, search_path};
|
||||
use crate::{bin_dir, exe, venv_of};
|
||||
use crate::{godot, vue};
|
||||
use ide_core::settings::{LanguageServerSettings, Settings};
|
||||
use ide_language::{LanguageConfig, LanguageServerConfig};
|
||||
use ide_core::settings::Settings;
|
||||
use ide_language::LanguageServerConfig;
|
||||
use ide_run::RunConfig;
|
||||
use serde_json::{Value, json};
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -302,78 +302,6 @@ pub fn configure_server(cfg: &mut LanguageServerConfig, root: &Path, server_root
|
||||
}
|
||||
}
|
||||
|
||||
/// The servers `language` uses after Settings › Language Servers: the
|
||||
/// definition's ones that aren't disabled, then the ones defined in settings for it.
|
||||
pub fn language_servers(language: &str, defined: &[LanguageServerConfig], s: &Settings) -> Vec<LanguageServerConfig> {
|
||||
let enabled = |name: &str| s.language_servers.get(name).is_none_or(|ls| ls.enabled);
|
||||
let mut out: Vec<LanguageServerConfig> = defined.iter().filter(|c| enabled(&c.name)).cloned().collect();
|
||||
for (name, ls) in &s.language_servers {
|
||||
if ls.enabled && ls.languages.iter().any(|l| l == language) && !out.iter().any(|c| &c.name == name) {
|
||||
out.push(custom_server(name, ls));
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Adds the servers defined in settings to the languages they serve (to list
|
||||
/// them with the tools); disabled ones stay so they can be turned back on.
|
||||
pub fn with_custom_servers(langs: &mut [LanguageConfig], s: &Settings) {
|
||||
for (name, ls) in s.language_servers.iter().filter(|(_, ls)| ls.is_custom()) {
|
||||
for lang in langs.iter_mut().filter(|l| ls.languages.iter().any(|id| id == l.id.as_str())) {
|
||||
if !lang.language_servers.iter().any(|c| &c.name == name) {
|
||||
lang.language_servers.push(custom_server(name, ls));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn custom_server(name: &str, ls: &LanguageServerSettings) -> LanguageServerConfig {
|
||||
LanguageServerConfig {
|
||||
name: name.to_owned(),
|
||||
command: ls.command.trim().to_owned(),
|
||||
args: Vec::new(),
|
||||
env: Default::default(),
|
||||
root_markers: ls.root_markers.clone(),
|
||||
initialization_options: None,
|
||||
settings: None,
|
||||
install_hint: Some(match ls.command.trim() {
|
||||
"" => format!("Set the command of `{name}` in Settings › Language Servers"),
|
||||
command => format!("`{command}` was not found: install it, or set its path in Settings › Language Servers"),
|
||||
}),
|
||||
connect: None,
|
||||
fallback: false,
|
||||
max_java: None,
|
||||
launch_error: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Command and arguments from Settings › Language Servers; applied before
|
||||
/// [`configure_server`] so toolchain adjustments (a custom path, JVM args) still follow.
|
||||
pub fn server_launch_overrides(cfg: &mut LanguageServerConfig, s: &Settings) {
|
||||
let Some(ls) = s.language_servers.get(&cfg.name) else { return };
|
||||
if let Some(command) = non_empty(ls.command.trim()) {
|
||||
cfg.command = command.to_owned();
|
||||
}
|
||||
if let Some(args) = &ls.args {
|
||||
cfg.args = args.clone();
|
||||
}
|
||||
}
|
||||
|
||||
/// Environment, `initializationOptions` and `workspace/configuration` settings
|
||||
/// from Settings › Language Servers; applied last so they win over derived values.
|
||||
pub fn server_protocol_overrides(cfg: &mut LanguageServerConfig, s: &Settings) {
|
||||
let Some(ls) = s.language_servers.get(&cfg.name) else { return };
|
||||
cfg.env.extend(ls.env.iter().map(|(k, v)| (k.clone(), v.clone())));
|
||||
if let Some(options) = &ls.initialization_options {
|
||||
merge_init_options(cfg, options.clone());
|
||||
}
|
||||
if let Some(settings) = &ls.settings {
|
||||
let mut current = cfg.settings.take().filter(Value::is_object).unwrap_or_else(|| json!({}));
|
||||
merge(&mut current, settings.clone());
|
||||
cfg.settings = Some(current);
|
||||
}
|
||||
}
|
||||
|
||||
/// vue-language-server loads TypeScript as a library (`--tsdk`, else its own
|
||||
/// `require('typescript')`): the selected version, else its own, else the
|
||||
/// project's — whichever still has the language-service API.
|
||||
|
||||
@@ -161,19 +161,6 @@ pub fn jdtls_jdks(min_java: u32) -> Arc<[Jdk]> {
|
||||
}
|
||||
}
|
||||
|
||||
/// For a server with `max-java`: when the `JAVA_HOME` it would get (its env,
|
||||
/// else the IDE's) is a newer JDK, points it at the newest of `jdks` that fits.
|
||||
pub fn cap_java_home(cfg: &mut LanguageServerConfig, jdks: &[Jdk]) {
|
||||
let Some(max) = cfg.max_java else { return };
|
||||
let current = cfg.env.get("JAVA_HOME").cloned().or_else(|| std::env::var("JAVA_HOME").ok());
|
||||
if current.as_deref().and_then(|h| jdk_at(Path::new(h))).is_some_and(|j| j.major <= max) {
|
||||
return;
|
||||
}
|
||||
if let Some(jdk) = jdks.iter().filter(|j| j.major <= max).max_by_key(|j| j.major) {
|
||||
cfg.env.insert("JAVA_HOME".into(), jdk.home.to_string_lossy().into_owned());
|
||||
}
|
||||
}
|
||||
|
||||
/// Oldest Java version jdtls runs on when its install can't tell (its launcher's check).
|
||||
pub const JDTLS_MIN_JAVA: u32 = 21;
|
||||
|
||||
|
||||
@@ -28,11 +28,9 @@ fn server(name: &str) -> LanguageServerConfig {
|
||||
env: BTreeMap::new(),
|
||||
root_markers: vec![],
|
||||
initialization_options: None,
|
||||
settings: None,
|
||||
install_hint: None,
|
||||
connect: None,
|
||||
fallback: false,
|
||||
max_java: None,
|
||||
launch_error: None,
|
||||
}
|
||||
}
|
||||
@@ -207,59 +205,6 @@ fn project_jdk_and_maven_settings() {
|
||||
assert_eq!(project_jdk(tmp.path(), &s), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn language_server_settings_disable_add_and_override() {
|
||||
use crate::apply::{language_servers, server_launch_overrides, server_protocol_overrides, with_custom_servers};
|
||||
use ide_core::settings::LanguageServerSettings;
|
||||
use serde_json::json;
|
||||
|
||||
let mut s = Settings::default();
|
||||
s.language_servers.insert("pylsp".into(), LanguageServerSettings { enabled: false, ..Default::default() });
|
||||
s.language_servers.insert(
|
||||
"ruff".into(),
|
||||
LanguageServerSettings {
|
||||
command: "ruff".into(),
|
||||
args: Some(vec!["server".into()]),
|
||||
languages: vec!["python".into()],
|
||||
root_markers: vec!["pyproject.toml".into()],
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
let defined = [server("basedpyright"), server("pylsp")];
|
||||
let names = |v: Vec<LanguageServerConfig>| v.into_iter().map(|c| c.name).collect::<Vec<_>>();
|
||||
assert_eq!(names(language_servers("python", &defined, &s)), ["basedpyright", "ruff"]);
|
||||
assert_eq!(names(language_servers("rust", &[server("rust-analyzer")], &s)), ["rust-analyzer"]);
|
||||
|
||||
// Listed with the tools even while disabled.
|
||||
let mut langs = ide_language::LanguageRegistry::load(None).unwrap().all();
|
||||
with_custom_servers(&mut langs, &s);
|
||||
let python = langs.iter().find(|l| l.id.as_str() == "python").unwrap();
|
||||
let mut ruff = python.language_servers.iter().find(|c| c.name == "ruff").unwrap().clone();
|
||||
assert_eq!(ruff.root_markers, ["pyproject.toml"]);
|
||||
server_launch_overrides(&mut ruff, &s);
|
||||
assert_eq!((ruff.command.as_str(), ruff.args.as_slice()), ("ruff", &["server".to_string()][..]));
|
||||
|
||||
s.language_servers.insert(
|
||||
"rust-analyzer".into(),
|
||||
LanguageServerSettings {
|
||||
env: BTreeMap::from([("RA_LOG".into(), "info".into())]),
|
||||
initialization_options: Some(json!({ "check": { "command": "clippy" } })),
|
||||
settings: Some(json!({ "rust-analyzer": { "cargo": { "features": "all" } } })),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
let mut ra = server("rust-analyzer");
|
||||
ra.args = vec!["--stdio".into()];
|
||||
ra.initialization_options = Some(toml::Value::Table(toml::toml! { checkOnSave = false }));
|
||||
server_launch_overrides(&mut ra, &s);
|
||||
assert_eq!(ra.args, ["--stdio"], "no args setting keeps the definition's");
|
||||
server_protocol_overrides(&mut ra, &s);
|
||||
assert_eq!(ra.env["RA_LOG"], "info");
|
||||
let init = serde_json::to_value(ra.initialization_options.unwrap()).unwrap();
|
||||
assert_eq!(init, json!({ "checkOnSave": false, "check": { "command": "clippy" } }));
|
||||
assert_eq!(ra.settings, Some(json!({ "rust-analyzer": { "cargo": { "features": "all" } } })));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn jdtls_jdk_setting() {
|
||||
if cfg!(windows) {
|
||||
@@ -599,29 +544,3 @@ fn vue_language_server_gets_a_typescript_with_the_language_service_api() {
|
||||
let lib = project.join("node_modules/typescript/lib");
|
||||
assert_eq!(cfg.args, [format!("--tsdk={}", lib.to_string_lossy())]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn max_java_picks_an_older_jdk() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let jdk = |major: u32| {
|
||||
let home = dir.path().join(format!("jdk-{major}"));
|
||||
std::fs::create_dir_all(home.join("bin")).unwrap();
|
||||
std::fs::write(home.join("release"), format!("JAVA_VERSION=\"{major}.0.1\"\n")).unwrap();
|
||||
std::fs::write(home.join("bin").join(exe("java")), "").unwrap();
|
||||
crate::java::jdk_at(&home).unwrap()
|
||||
};
|
||||
let (j17, j21, j25) = (jdk(17), jdk(21), jdk(25));
|
||||
let jdks = [j25.clone(), j21.clone(), j17];
|
||||
let mut cfg = LanguageServerConfig { max_java: Some(21), ..server("kotlin-language-server") };
|
||||
cfg.env.insert("JAVA_HOME".into(), j25.home.to_string_lossy().into_owned());
|
||||
crate::java::cap_java_home(&mut cfg, &jdks);
|
||||
assert_eq!(cfg.env["JAVA_HOME"], j21.home.to_string_lossy());
|
||||
|
||||
// A JAVA_HOME that fits, or no limit: left alone.
|
||||
crate::java::cap_java_home(&mut cfg, &[]);
|
||||
assert_eq!(cfg.env["JAVA_HOME"], j21.home.to_string_lossy());
|
||||
let mut free = server("other");
|
||||
free.env.insert("JAVA_HOME".into(), j25.home.to_string_lossy().into_owned());
|
||||
crate::java::cap_java_home(&mut free, &jdks);
|
||||
assert_eq!(free.env["JAVA_HOME"], j25.home.to_string_lossy());
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ide-spell"
|
||||
description = "Spell checking (Proofreading › Typo): word extraction from comments, strings and declared names, Hunspell en_US / en_GB dictionary, programming terms, user dictionaries"
|
||||
description = "Spell checking (Proofreading › Typo): word extraction from comments, strings and declared names, Hunspell en_US dictionary, user dictionaries"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017-2025 Street Side Software <[email protected]>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -1,246 +0,0 @@
|
||||
# Tool and file names, abbreviations and words common in code the other lists lack.
|
||||
# Accepted on their own, never as part of a compound (`conf` would pass `conflift`).
|
||||
# One lowercase word per line; checked case-insensitively.
|
||||
accel
|
||||
acked
|
||||
adoc
|
||||
adoptium
|
||||
allman
|
||||
askpass
|
||||
assignees
|
||||
avif
|
||||
basedpyright
|
||||
bytea
|
||||
canceller
|
||||
cand
|
||||
cands
|
||||
cjs
|
||||
closable
|
||||
clsx
|
||||
codelldb
|
||||
colima
|
||||
commitish
|
||||
condvar
|
||||
conf
|
||||
conftest
|
||||
conns
|
||||
cte
|
||||
ctes
|
||||
cts
|
||||
customizations
|
||||
dap
|
||||
ddl
|
||||
debuggee
|
||||
decapitalize
|
||||
deemphasize
|
||||
defmodule
|
||||
desync
|
||||
dialogs
|
||||
dic
|
||||
disassembler
|
||||
dists
|
||||
dlsym
|
||||
dlv
|
||||
dnd
|
||||
dup
|
||||
emmet
|
||||
envrc
|
||||
eslintrc
|
||||
expando
|
||||
exs
|
||||
fallbacks
|
||||
fixup
|
||||
fori
|
||||
gdscript
|
||||
gdshader
|
||||
gfm
|
||||
gitattributes
|
||||
gitoxide
|
||||
gix
|
||||
glyphs
|
||||
gomod
|
||||
gopath
|
||||
gopls
|
||||
goroot
|
||||
gpgsign
|
||||
gradle
|
||||
gradlew
|
||||
graphql
|
||||
guice
|
||||
hamcrest
|
||||
haspopup
|
||||
hcl
|
||||
hotswap
|
||||
htdocs
|
||||
hxx
|
||||
ideavimrc
|
||||
ime
|
||||
inflight
|
||||
inlines
|
||||
inplace
|
||||
integrations
|
||||
intelephense
|
||||
interp
|
||||
inv
|
||||
ipynb
|
||||
jacoco
|
||||
javac
|
||||
javaw
|
||||
javax
|
||||
jdt
|
||||
jdtls
|
||||
jdwp
|
||||
jenkinsfile
|
||||
jre
|
||||
jsdom
|
||||
jshell
|
||||
jsonl
|
||||
kapt
|
||||
kotlinc
|
||||
kts
|
||||
labelledby
|
||||
latencies
|
||||
lcov
|
||||
lemminx
|
||||
lexically
|
||||
lezer
|
||||
linkify
|
||||
lldb
|
||||
lockb
|
||||
logpoint
|
||||
logpoints
|
||||
lombok
|
||||
lossily
|
||||
lossy
|
||||
mapleader
|
||||
matview
|
||||
memmem
|
||||
menlo
|
||||
menuitemcheckbox
|
||||
mjs
|
||||
msvc
|
||||
mts
|
||||
mvn
|
||||
mvnw
|
||||
natively
|
||||
nextest
|
||||
nocapture
|
||||
nodelay
|
||||
nonmatching
|
||||
noopener
|
||||
noreferrer
|
||||
noremap
|
||||
notif
|
||||
notnull
|
||||
nvm
|
||||
ord
|
||||
osgi
|
||||
pathing
|
||||
pdm
|
||||
pipfile
|
||||
pred
|
||||
preds
|
||||
prunable
|
||||
psvm
|
||||
publickey
|
||||
pwa
|
||||
pyc
|
||||
pycache
|
||||
pyenv
|
||||
pyi
|
||||
pylsp
|
||||
pyvenv
|
||||
recency
|
||||
recents
|
||||
redb
|
||||
redecl
|
||||
reformats
|
||||
reinstalls
|
||||
rekey
|
||||
replit
|
||||
rerunnable
|
||||
rescan
|
||||
restorable
|
||||
retarget
|
||||
rfind
|
||||
rollup
|
||||
rsplit
|
||||
rsplitn
|
||||
rss
|
||||
rst
|
||||
runserver
|
||||
sbt
|
||||
scm
|
||||
sdkman
|
||||
segs
|
||||
sel
|
||||
severities
|
||||
shorthands
|
||||
sig
|
||||
sigil
|
||||
solarized
|
||||
sout
|
||||
specta
|
||||
splitn
|
||||
storable
|
||||
stty
|
||||
subclassed
|
||||
subsequence
|
||||
subsequences
|
||||
subtest
|
||||
subtests
|
||||
supabase
|
||||
sym
|
||||
syms
|
||||
taplo
|
||||
tauri
|
||||
tcpip
|
||||
tcsh
|
||||
temurin
|
||||
texlab
|
||||
tgz
|
||||
timescaledb
|
||||
timestamptz
|
||||
toks
|
||||
topo
|
||||
tpl
|
||||
tsdk
|
||||
tsv
|
||||
unclosed
|
||||
unformatted
|
||||
unlisten
|
||||
unmarking
|
||||
unmatch
|
||||
unminimize
|
||||
unqueue
|
||||
unshelve
|
||||
unsplit
|
||||
unsub
|
||||
unsubs
|
||||
untag
|
||||
untagged
|
||||
uptime
|
||||
vcs
|
||||
vendored
|
||||
vimrc
|
||||
visibilities
|
||||
vite
|
||||
vitest
|
||||
vmargs
|
||||
volar
|
||||
vsix
|
||||
vtsls
|
||||
wasi
|
||||
wasmtime
|
||||
webflux
|
||||
webmanifest
|
||||
wip
|
||||
xcrun
|
||||
xdebug
|
||||
zig
|
||||
zlogin
|
||||
zls
|
||||
zprofile
|
||||
zshenv
|
||||
zshrc
|
||||
zustand
|
||||
@@ -551,15 +551,3 @@ vulkan
|
||||
wgpu
|
||||
woff
|
||||
woff2
|
||||
breakpoint
|
||||
sku
|
||||
dropdown
|
||||
navbar
|
||||
superclass
|
||||
typedef
|
||||
eslint
|
||||
unittest
|
||||
jvm
|
||||
jdk
|
||||
ux
|
||||
endpoint
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Spell checking for IDEA's "Proofreading › Typo" inspection: words of
|
||||
//! comments, string literals and declared names (regions come from the
|
||||
//! syntax layer), checked against the bundled en_US / en_GB Hunspell dictionary, a
|
||||
//! syntax layer), checked against the bundled en_US Hunspell dictionary, a
|
||||
//! list of programming terms and the user's accepted words and dictionaries.
|
||||
//! Regular agent nouns of known words (`checkpointer`) pass everywhere; in
|
||||
//! identifiers so do closed compounds of known words (`codebase`).
|
||||
@@ -98,17 +98,12 @@ impl SpellScope {
|
||||
/// At most this many typos are reported per text.
|
||||
pub const MAX_TYPOS: usize = 2000;
|
||||
|
||||
/// The en_GB entries en_US lacks (`colour`, `behaviour`, `normalise`), in the
|
||||
/// same affix scheme: either spelling passes.
|
||||
const EN_GB_EXTRA: &str = include_str!("dict/en_GB-extra.dic");
|
||||
|
||||
/// The en_US dictionary plus [`EN_GB_EXTRA`].
|
||||
fn english() -> &'static spellbook::Dictionary {
|
||||
static DICT: OnceLock<spellbook::Dictionary> = OnceLock::new();
|
||||
DICT.get_or_init(|| {
|
||||
let aff = include_str!("dict/en_US.aff");
|
||||
let dic = format!("{}{EN_GB_EXTRA}", include_str!("dict/en_US.dic"));
|
||||
spellbook::Dictionary::new(aff, &dic).expect("bundled en dictionary parses")
|
||||
let dic = include_str!("dict/en_US.dic");
|
||||
spellbook::Dictionary::new(aff, dic).expect("bundled en_US dictionary parses")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -119,7 +114,6 @@ fn lemmas() -> &'static HashSet<&'static str> {
|
||||
include_str!("dict/en_US.dic")
|
||||
.lines()
|
||||
.skip(1)
|
||||
.chain(EN_GB_EXTRA.lines())
|
||||
.map(|l| l.split('/').next().unwrap_or(l).trim())
|
||||
.filter(|w| !w.is_empty() && w.chars().all(|c| c.is_ascii_lowercase()))
|
||||
.collect()
|
||||
@@ -142,12 +136,13 @@ fn doubles_final_consonant(stem: &str) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether dropping one letter or swapping two adjacent ones gives a `known`
|
||||
/// Whether dropping one letter or swapping two adjacent ones gives a dictionary
|
||||
/// word: then a compound (`writ`+`ting`) is more likely a typo of
|
||||
/// it (`writing`), as Hunspell's CHECKCOMPOUNDREP reasons.
|
||||
fn near_word(lower: &str, known: impl Fn(&str) -> bool) -> bool {
|
||||
fn near_word(lower: &str) -> bool {
|
||||
let b = lower.as_bytes();
|
||||
let check = |v: &[u8]| std::str::from_utf8(v).is_ok_and(&known);
|
||||
let dict = english();
|
||||
let check = |v: &[u8]| std::str::from_utf8(v).is_ok_and(|w| dict.check(w));
|
||||
(0..b.len()).any(|i| check(&[&b[..i], &b[i + 1..]].concat()))
|
||||
|| (0..b.len().saturating_sub(1)).any(|i| {
|
||||
let mut v = b.to_vec();
|
||||
@@ -156,43 +151,17 @@ fn near_word(lower: &str, known: impl Fn(&str) -> bool) -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
fn term_list(text: &'static str) -> HashSet<&'static str> {
|
||||
text.lines().map(str::trim).filter(|l| !l.is_empty() && !l.starts_with('#')).collect()
|
||||
}
|
||||
|
||||
/// Hand-picked programming terms: short ones (`url`) may be part of a compound.
|
||||
fn curated_terms() -> &'static HashSet<&'static str> {
|
||||
static TERMS: OnceLock<HashSet<&'static str>> = OnceLock::new();
|
||||
TERMS.get_or_init(|| term_list(include_str!("dict/software.txt")))
|
||||
}
|
||||
|
||||
/// Imported programming terms, tool and library names, and abbreviations:
|
||||
/// never part of a compound.
|
||||
fn other_terms() -> &'static HashSet<&'static str> {
|
||||
fn software_terms() -> &'static HashSet<&'static str> {
|
||||
static TERMS: OnceLock<HashSet<&'static str>> = OnceLock::new();
|
||||
TERMS.get_or_init(|| {
|
||||
let mut terms = term_list(include_str!("dict/cspell-terms.txt"));
|
||||
terms.extend(term_list(include_str!("dict/code-words.txt")));
|
||||
terms
|
||||
include_str!("dict/software.txt")
|
||||
.lines()
|
||||
.map(str::trim)
|
||||
.filter(|l| !l.is_empty() && !l.starts_with('#'))
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
|
||||
fn term(lower: &str) -> bool {
|
||||
curated_terms().contains(lower) || other_terms().contains(lower)
|
||||
}
|
||||
|
||||
/// A software term, or the plural of one Hunspell doesn't know (`endpoints`,
|
||||
/// `regexes`; not `filess`, `contextes`, `checkings`). [`other_terms`] need
|
||||
/// 4+ letters for that (`acses` stays flagged).
|
||||
fn software_term(lower: &str) -> bool {
|
||||
let plural_of = |w: &str| (curated_terms().contains(w) || w.len() >= MIN_PART && term(w)) && !english().check(w);
|
||||
term(lower)
|
||||
|| lower.strip_suffix('s').is_some_and(|w| !w.ends_with('s') && plural_of(w))
|
||||
|| lower
|
||||
.strip_suffix("es")
|
||||
.is_some_and(|w| ["s", "x", "z", "ch", "sh"].iter().any(|e| w.ends_with(e)) && plural_of(w))
|
||||
}
|
||||
|
||||
/// Words of a custom dictionary file: a plain word list or a Hunspell `.dic`
|
||||
/// (leading count line and `/FLAGS` ignored). Cached by modification time.
|
||||
fn dictionary_file(path: &Path) -> Arc<HashSet<String>> {
|
||||
@@ -247,15 +216,11 @@ impl Speller {
|
||||
|
||||
/// Whether `word` (of prose, a comment or a string) is spelt correctly.
|
||||
/// Case is forgiven the way identifiers need it: `url` passes for `URL`,
|
||||
/// `paris` for `Paris`. Possessives (`backend's`), regular agent nouns
|
||||
/// (`checkpointer`, `serializers`) and `-ed` / `-ing` / `-able` forms of
|
||||
/// programming terms (`stringified`) pass too.
|
||||
/// `paris` for `Paris`. Regular agent nouns of known words pass too
|
||||
/// (`checkpointer`, `serializers`).
|
||||
pub fn is_correct(&self, word: &str) -> bool {
|
||||
if let Some(base) = word.strip_suffix("'s") {
|
||||
return self.is_correct(base);
|
||||
}
|
||||
let lower = word.to_lowercase();
|
||||
self.listed(word, &lower) || self.agent_noun(&lower) || self.term_form(&lower)
|
||||
self.listed(word, &lower) || self.agent_noun(&lower)
|
||||
}
|
||||
|
||||
/// [`Self::is_correct`] for a part of an identifier, which may also be two
|
||||
@@ -265,7 +230,9 @@ impl Speller {
|
||||
}
|
||||
|
||||
fn user_word(&self, lower: &str) -> bool {
|
||||
self.accepted.contains(lower) || software_term(lower) || self.custom.iter().any(|d| d.contains(lower))
|
||||
self.accepted.contains(lower)
|
||||
|| software_terms().contains(lower)
|
||||
|| self.custom.iter().any(|d| d.contains(lower))
|
||||
}
|
||||
|
||||
/// In a dictionary, in any case style.
|
||||
@@ -288,63 +255,30 @@ impl Speller {
|
||||
let singular = lower.strip_suffix('s').unwrap_or(lower);
|
||||
let Some(before_r) = singular.strip_suffix('r') else { return false };
|
||||
let Some(before_er) = before_r.strip_suffix('e') else { return false };
|
||||
let mut stems = vec![before_r.to_string()];
|
||||
// (stem, root the `-or` noun would be built on)
|
||||
let mut stems = vec![(before_r.to_string(), before_er)];
|
||||
if let Some(y) = before_er.strip_suffix('i') {
|
||||
stems.push(format!("{y}y"));
|
||||
stems.push((format!("{y}y"), before_er));
|
||||
} else if !before_er.ends_with('e') && !doubles_final_consonant(before_er) {
|
||||
stems.push(before_er.to_string());
|
||||
stems.push((before_er.to_string(), before_er));
|
||||
}
|
||||
let or_noun = format!("{before_er}or");
|
||||
stems
|
||||
.into_iter()
|
||||
.any(|stem| stem.len() >= MIN_PART && (lemmas().contains(stem.as_str()) || self.term_stem(&stem)))
|
||||
&& !self.listed(&or_noun, &or_noun)
|
||||
}
|
||||
|
||||
/// A programming term or accepted word of 5+ letters Hunspell doesn't know
|
||||
/// (`stringify`; not `calls` or `calc`), to derive other words from.
|
||||
fn term_stem(&self, s: &str) -> bool {
|
||||
s.len() > MIN_PART && self.user_word(s) && !english().check(s)
|
||||
}
|
||||
|
||||
/// `<term>ed` / `<term>ing` / `<term>able` of a programming term or an
|
||||
/// accepted word of 5+ letters: `stringified` (stringify), `memoizing`
|
||||
/// (memoize), `upserted`. Dictionary words only take the endings Hunspell
|
||||
/// knows: `falled`, `quiting` stay flagged. Not when one letter off a known
|
||||
/// word (`preprocesssing`).
|
||||
fn term_form(&self, lower: &str) -> bool {
|
||||
if !lower.bytes().all(|c| c.is_ascii_lowercase()) {
|
||||
return false;
|
||||
}
|
||||
let stem = |s: &str| self.term_stem(s);
|
||||
let derived = ["ed", "ing", "able"].into_iter().any(|suffix| {
|
||||
let Some(root) = lower.strip_suffix(suffix) else { return false };
|
||||
let b = root.as_bytes();
|
||||
(stem(root) && !doubles_final_consonant(root))
|
||||
|| stem(&format!("{root}e"))
|
||||
|| (suffix != "ing" && root.strip_suffix('i').is_some_and(|y| stem(&format!("{y}y"))))
|
||||
|| (b.len() > 2 && b[b.len() - 1] == b[b.len() - 2] && stem(&root[..root.len() - 1]))
|
||||
});
|
||||
derived && !near_word(lower, |w| english().check(w) || self.user_word(w))
|
||||
stems.into_iter().any(|(stem, root)| {
|
||||
stem.len() >= MIN_PART
|
||||
&& (lemmas().contains(stem.as_str()) || self.user_word(&stem))
|
||||
&& !english().check(&format!("{root}or"))
|
||||
})
|
||||
}
|
||||
|
||||
/// Two known words run together, each at least [`MIN_PART`] letters (or a
|
||||
/// hand-picked or accepted 3-letter term: `urlpath`). Proper nouns and
|
||||
/// [`other_terms`] don't count (`guid` + `lines` would pass `guidlines`).
|
||||
/// 3-letter programming term: `urlpath`). Proper nouns don't count.
|
||||
fn compound(&self, lower: &str) -> bool {
|
||||
if lower.len() < 6 || !lower.bytes().all(|c| c.is_ascii_lowercase()) || NOT_COMPOUNDS.contains(&lower) {
|
||||
return false;
|
||||
}
|
||||
let known = |p: &str| {
|
||||
self.accepted.contains(p) || curated_terms().contains(p) || self.custom.iter().any(|d| d.contains(p))
|
||||
let part = |p: &str| {
|
||||
(p.len() >= 3 && self.user_word(p)) || (p.len() >= MIN_PART && (english().check(p) || self.agent_noun(p)))
|
||||
};
|
||||
let part = |p: &str| match p.len() {
|
||||
0..3 => false,
|
||||
3 => known(p),
|
||||
_ => known(p) || english().check(p) || self.agent_noun(p),
|
||||
};
|
||||
(3..=lower.len() - 3).any(|i| part(&lower[..i]) && part(&lower[i..]))
|
||||
&& !near_word(lower, |w| english().check(w))
|
||||
(3..=lower.len() - 3).any(|i| part(&lower[..i]) && part(&lower[i..])) && !near_word(lower)
|
||||
}
|
||||
|
||||
/// Replacements for `word`, best first, in the word's case style.
|
||||
@@ -361,14 +295,6 @@ impl Speller {
|
||||
out
|
||||
}
|
||||
|
||||
/// Whether the letter run `w` was split from is a known term as a whole:
|
||||
/// `IntelliJ` (`Intelli` + `J`), `PostgreSQL` (`Postgre` + `SQL`).
|
||||
fn known_run(&self, text: &str, w: &WordSpan) -> bool {
|
||||
let start = text[..w.start].rfind(|c: char| !c.is_alphabetic()).map_or(0, |i| i + 1);
|
||||
let end = text[w.end..].find(|c: char| !c.is_alphabetic()).map_or(text.len(), |i| w.end + i);
|
||||
(start, end) != (w.start, w.end) && self.user_word(&text[start..end].to_lowercase())
|
||||
}
|
||||
|
||||
/// Misspelt words of `regions` (document order) in `text`; `None` when
|
||||
/// `cancelled` fires.
|
||||
pub fn check(&self, text: &str, regions: &[Region], cancelled: &dyn Fn() -> bool) -> Option<Vec<Typo>> {
|
||||
@@ -387,7 +313,7 @@ impl Speller {
|
||||
let ok = *verdicts
|
||||
.entry((word, name))
|
||||
.or_insert_with(|| if name { self.is_correct_identifier(word) } else { self.is_correct(word) });
|
||||
if !ok && !self.known_run(text, w) {
|
||||
if !ok {
|
||||
bad.push((*w, r.kind));
|
||||
}
|
||||
}
|
||||
@@ -513,53 +439,6 @@ mod tests {
|
||||
assert!(!s.is_correct("lenght"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn software_terms_and_their_plurals() {
|
||||
let s = Speller::default();
|
||||
for ok in ["breakpoint", "breakpoints", "endpoints", "datasets", "regexes"] {
|
||||
assert!(s.is_correct(ok), "{ok}");
|
||||
}
|
||||
for ok in
|
||||
["stringify", "instanceof", "keydown", "submenu", "truthy", "vitest", "gradle", "unstaged", "rebasing"]
|
||||
{
|
||||
assert!(s.is_correct(ok), "{ok}");
|
||||
}
|
||||
for bad in ["filess", "contextes", "checkings", "acses"] {
|
||||
assert!(!s.is_correct(bad), "{bad}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn british_spellings() {
|
||||
let s = Speller::default();
|
||||
for ok in ["colour", "behaviours", "normalised", "centred", "analyse", "cancelled", "dialogs"] {
|
||||
assert!(s.is_correct(ok), "{ok}");
|
||||
}
|
||||
for bad in ["colur", "behavour", "normalsed"] {
|
||||
assert!(!s.is_correct(bad), "{bad}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn split_terms_checked_whole() {
|
||||
let s = Speller::default();
|
||||
let text = "// Open IntelliJ or PostgreSQL, not Intelli alone";
|
||||
let words: Vec<_> =
|
||||
s.check(text, &whole(text, RegionKind::Comment), &|| false).unwrap().into_iter().map(|t| t.word).collect();
|
||||
assert_eq!(words, ["Intelli"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn possessives_and_term_forms() {
|
||||
let s = Speller::default();
|
||||
for ok in ["backend's", "commit's", "stringified", "memoizing", "upserted"] {
|
||||
assert!(s.is_correct(ok), "{ok}");
|
||||
}
|
||||
for bad in ["recieve's", "falled", "quiting", "preprocesssing", "perfer", "callser"] {
|
||||
assert!(!s.is_correct(bad), "{bad}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn agent_nouns_of_known_words() {
|
||||
let s = Speller::default();
|
||||
@@ -578,7 +457,7 @@ mod tests {
|
||||
for ok in ["filepath", "dataframe", "username", "codebase", "pathname", "urlpath", "timestampfile"] {
|
||||
assert!(s.is_correct_identifier(ok), "{ok}");
|
||||
}
|
||||
assert!(!s.is_correct("timestampfile"));
|
||||
assert!(!s.is_correct("dataframe"));
|
||||
for bad in ["eachother", "everytime", "publically", "mesage", "lenght", "recieve", "comming", "withold"] {
|
||||
assert!(!s.is_correct_identifier(bad), "{bad}");
|
||||
}
|
||||
|
||||
@@ -72,10 +72,6 @@ pub struct ToolInfo {
|
||||
pub homepage: Option<String>,
|
||||
/// Why the executable chosen in settings cannot be used (status is then `Missing`).
|
||||
pub custom_error: Option<String>,
|
||||
/// A language server's arguments from its language definition.
|
||||
pub default_args: Vec<String>,
|
||||
/// A language server's `initializationOptions` from its language definition, as JSON text.
|
||||
pub default_initialization_options: Option<String>,
|
||||
}
|
||||
|
||||
/// Streamed install progress.
|
||||
@@ -213,8 +209,6 @@ struct Usage {
|
||||
command: Option<String>,
|
||||
kind: Option<ToolKind>,
|
||||
install_hint: Option<String>,
|
||||
args: Vec<String>,
|
||||
initialization_options: Option<String>,
|
||||
}
|
||||
|
||||
fn usages(langs: &[LanguageConfig]) -> BTreeMap<String, Usage> {
|
||||
@@ -249,14 +243,6 @@ fn usages(langs: &[LanguageConfig]) -> BTreeMap<String, Usage> {
|
||||
let languages = map.get(*host).map(|u| u.languages.clone()).unwrap_or_default();
|
||||
map.entry(plugin.to_string()).or_default().languages = languages;
|
||||
}
|
||||
// A server's defaults come from the first definition using it.
|
||||
for s in langs.iter().flat_map(|l| &l.language_servers).rev() {
|
||||
if let Some(u) = map.get_mut(&s.name) {
|
||||
u.args = s.args.clone();
|
||||
u.initialization_options =
|
||||
s.initialization_options.as_ref().and_then(|v| serde_json::to_value(v).ok()).map(|v| v.to_string());
|
||||
}
|
||||
}
|
||||
map
|
||||
}
|
||||
|
||||
@@ -469,8 +455,6 @@ impl Tools {
|
||||
install_hint,
|
||||
homepage: None,
|
||||
custom_error: None,
|
||||
default_args: u.args.clone(),
|
||||
default_initialization_options: u.initialization_options.clone(),
|
||||
})
|
||||
.map(|info| self.apply_custom(info, None));
|
||||
};
|
||||
@@ -493,8 +477,6 @@ impl Tools {
|
||||
install_hint,
|
||||
homepage: Some(spec.homepage.to_string()),
|
||||
custom_error: None,
|
||||
default_args: usage.map(|u| u.args.clone()).unwrap_or_default(),
|
||||
default_initialization_options: usage.and_then(|u| u.initialization_options.clone()),
|
||||
})
|
||||
.map(|info| self.apply_custom(info, Some(spec)))
|
||||
}
|
||||
|
||||
@@ -106,33 +106,20 @@ fn json_to_toml(value: &Json) -> IdeResult<toml_edit::Value> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Sets (or removes, for `None`) a dotted key in a TOML document. A new
|
||||
/// `map_entry` object becomes a `[languageServers.ruff]` table rather than an
|
||||
/// inline table under an explicit `[languageServers]` header.
|
||||
fn set_in_document(doc: &mut DocumentMut, segments: &[&str], value: Option<toml_edit::Value>, map_entry: bool) {
|
||||
/// Sets (or removes, for `None`) a dotted key in a TOML document.
|
||||
fn set_in_document(doc: &mut DocumentMut, segments: &[&str], value: Option<toml_edit::Value>) {
|
||||
let (last, parents) = segments.split_last().expect("non-empty key");
|
||||
let mut table: &mut dyn TableLike = doc.as_table_mut();
|
||||
let mut in_inline = false;
|
||||
for seg in parents {
|
||||
if !table.get(seg).is_some_and(Item::is_table_like) {
|
||||
if value.is_none() {
|
||||
return;
|
||||
}
|
||||
// Implicit: no `[languageServers]` header above `[languageServers.ruff]`.
|
||||
let mut new = Table::new();
|
||||
new.set_implicit(true);
|
||||
table.insert(seg, Item::Table(new));
|
||||
table.insert(seg, Item::Table(Table::new()));
|
||||
}
|
||||
let item = table.get_mut(seg).expect("table just ensured");
|
||||
in_inline |= item.is_inline_table();
|
||||
table = item.as_table_like_mut().expect("table just ensured");
|
||||
table = table.get_mut(seg).and_then(Item::as_table_like_mut).expect("table just ensured");
|
||||
}
|
||||
match value {
|
||||
Some(toml_edit::Value::InlineTable(t))
|
||||
if map_entry && !in_inline && !matches!(table.get(last), Some(Item::Value(_))) =>
|
||||
{
|
||||
table.insert(last, Item::Table(t.into_table()));
|
||||
}
|
||||
Some(v) => match table.get_mut(last) {
|
||||
// Keep the key's decor (comments, spacing) when replacing a value.
|
||||
Some(Item::Value(existing)) => {
|
||||
@@ -201,19 +188,9 @@ impl SettingsStore {
|
||||
if segments.iter().any(|s| s.is_empty()) {
|
||||
return Err(IdeError::invalid(format!("invalid settings key {key:?}")));
|
||||
}
|
||||
let defaults = defaults_json();
|
||||
let mut cursor = &defaults;
|
||||
let mut map_entry = false;
|
||||
for (i, seg) in segments.iter().enumerate() {
|
||||
match cursor.get(seg) {
|
||||
Some(next) => cursor = next,
|
||||
// An entry of a map setting (`languageServers.rust-analyzer`): the merge below validates it.
|
||||
None if cursor.as_object().is_some_and(|m| m.is_empty()) => {
|
||||
map_entry = i + 1 == segments.len();
|
||||
break;
|
||||
}
|
||||
None => return Err(IdeError::invalid(format!("unknown setting {key:?}"))),
|
||||
}
|
||||
let mut cursor = &defaults_json();
|
||||
for seg in &segments {
|
||||
cursor = cursor.get(seg).ok_or_else(|| IdeError::invalid(format!("unknown setting {key:?}")))?;
|
||||
}
|
||||
|
||||
let text = match std::fs::read_to_string(&file) {
|
||||
@@ -225,7 +202,7 @@ impl SettingsStore {
|
||||
.parse()
|
||||
.map_err(|e| IdeError::invalid(format!("{} is not valid TOML; fix it first: {e}", file.display())))?;
|
||||
let new_value = if value.is_null() { None } else { Some(json_to_toml(&value)?) };
|
||||
set_in_document(&mut doc, &segments, new_value, map_entry);
|
||||
set_in_document(&mut doc, &segments, new_value);
|
||||
let new_text = doc.to_string();
|
||||
|
||||
// Validate the resulting stack before touching the disk.
|
||||
@@ -373,47 +350,6 @@ mod tests {
|
||||
let s =
|
||||
store.set(SettingsScope::Global, "appearance.statusBarWidgets", json!({"editor.caret": false})).unwrap();
|
||||
assert_eq!(s.appearance.status_bar_widgets.len(), 1);
|
||||
// One entry of a map setting, set and removed on its own.
|
||||
let s = store
|
||||
.set(
|
||||
SettingsScope::Global,
|
||||
"languageServers.rust-analyzer",
|
||||
json!({"args": ["--log"], "initializationOptions": {"check": {"command": "clippy"}}}),
|
||||
)
|
||||
.unwrap();
|
||||
let ra = &s.language_servers["rust-analyzer"];
|
||||
assert!(ra.enabled);
|
||||
assert_eq!(ra.args.as_deref(), Some(&["--log".to_string()][..]));
|
||||
assert_eq!(ra.initialization_options, Some(json!({"check": {"command": "clippy"}})));
|
||||
assert_eq!(
|
||||
store
|
||||
.set(SettingsScope::Global, "languageServers.rust-analyzer", json!({"enabled": "no"}))
|
||||
.unwrap_err()
|
||||
.kind,
|
||||
ide_core::error::ErrorKind::InvalidInput
|
||||
);
|
||||
let s = store.set(SettingsScope::Global, "languageServers.rust-analyzer", json!(null)).unwrap();
|
||||
assert!(s.language_servers.is_empty());
|
||||
// New parent tables stay implicit: no empty `[languageServers]` header.
|
||||
let fresh = tmp.path().join("fresh");
|
||||
let s = SettingsStore::load(&fresh, None)
|
||||
.set(SettingsScope::Global, "languageServers.ruff.languages", json!(["python"]))
|
||||
.unwrap();
|
||||
assert!(s.language_servers["ruff"].is_custom());
|
||||
let text = std::fs::read_to_string(fresh.join("settings.toml")).unwrap();
|
||||
assert_eq!(text, "[languageServers.ruff]\nlanguages = [\"python\"]\n");
|
||||
// A whole new entry: a table of its own, still under an implicit parent.
|
||||
let added = tmp.path().join("added");
|
||||
let s = SettingsStore::load(&added, None)
|
||||
.set(
|
||||
SettingsScope::Global,
|
||||
"languageServers.ruff",
|
||||
json!({"command": "ruff", "args": ["server"], "languages": ["python"]}),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(s.language_servers["ruff"].command, "ruff");
|
||||
let text = std::fs::read_to_string(added.join("settings.toml")).unwrap();
|
||||
assert_eq!(text, "[languageServers.ruff]\nargs = [\"server\"]\ncommand = \"ruff\"\nlanguages = [\"python\"]\n");
|
||||
|
||||
// Project layer is created on demand and wins.
|
||||
let s = store.set(SettingsScope::Project, "editor.fontSize", json!(12)).unwrap();
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
# 核心体验运行验收补测(2026-10-25)
|
||||
|
||||
本轮按用户缩小后的“核心体验”范围执行,**27个明确场景:修复复测后27通过、0失败**。这不是原94项清单全量完成声明;首轮发现的中文漏译及原清单未完成项仍保留。
|
||||
|
||||
实际版本:`d3feb05`(功能提交 `1e00ea5` 加版本更新)。macOS 原生调试应用,使用真实窗口、编辑器、已安装语言服务器、实际子进程与磁盘结果。测试项目是 `fixtures/ts-app` 的 `/tmp/idea-parity-qa/core-ts` 副本;Python调试和终端脚本仅写入该副本。首次验收未修改产品源码;随后按用户要求修复下列两处问题,运行版本为 `d3feb05` 加工作区改动,未在本仓库提交;Git验收仅在独立core-git副本里创建QA提交。
|
||||
|
||||
通过判定仅针对表内明确写出的步骤。重点编辑、查找、导航、补全、格式化、项目视图和 npm 运行做了亮/暗复测;调试、启动链等执行逻辑没有逐一覆盖所有主题和语言组合。数据库、Docker部署、复杂Git图/merge/rebase/worktree、设置导入导出、完整书签/布局/宏管理不在这次缩小后的核心范围内,原清单相关待测项仍保留。
|
||||
|
||||
## 修复复测(同日)
|
||||
|
||||
- IN-2:保留未过滤的服务器诊断;检查方案编辑时重新投影已完成或进行中的结果,同步严重级别和问题计数,保留排除状态。原生应用亮/暗各验证 error → warning → disabled → restored;还验证了禁用时执行检查,再启用无需重跑即恢复2条诊断。[结构化证据](/tmp/idea-parity-qa/fix-IN2-results.json)、[暗色恢复截图](/tmp/idea-parity-qa/fix-IN2-dark-restored.png)。
|
||||
- CSS:为共享语言服务器的 CSS、SCSS、Less 配置提供默认对象,避免 workspace/configuration 返回 null。三种文件分别打开 `.qa { colr: red; }`,均返回 unknownProperties 警告;新进程日志无 validProperties 异常。[诊断证据](/tmp/idea-parity-qa/fix-css-results.json)、[原生日志](/tmp/idea-parity-qa/fix-app.log)。
|
||||
- 验证:前端分析相关10项测试、LSP协议26项测试均通过;pnpm typecheck、原生 debug build、cargo clippy -p ide-lsp --all-targets -- -D warnings、cargo fmt 与 git diff --check 通过。新增回归覆盖方案修改、禁用后恢复、流式检查中修改方案、计数和原始严重级别恢复,以及真实内置配置的协议响应。
|
||||
|
||||
## 首次失败记录(已修复,保留复现过程)
|
||||
|
||||
### A. IN-2:旧 Inspect Code 结果不随检查方案更新
|
||||
|
||||
1. 打开 `src/qa-diagnostic.ts`:`const qaNumber: number = "wrong";`。
|
||||
2. 默认方案执行 Code › Inspect Code,仅检查当前文件,得到2条 TypeScript 错误。
|
||||
3. 将 TypeScript 检查严重级别设为 warning:编辑器变为黄色波浪线、Problems 显示 warning;旧 Inspection Results 仍是红色错误。
|
||||
4. 禁用该检查:编辑器无波浪线、Problems 清空;旧 Inspection Results 仍显示“2 problems in 1 file”。
|
||||
|
||||
期望:按 IN-2 的“同时变化”要求,三处采用同一有效方案。实际只有前两处即时更新。亮/暗均复现。[暗色截图](/tmp/idea-parity-qa/core-IN2-repro-dark.png)、[亮色截图](/tmp/idea-parity-qa/core-IN2-batch-disabled.png)、[结构化结果](/tmp/idea-parity-qa/core-IN2-repro-dark.json)。
|
||||
|
||||
**边界:重新执行 Inspect Code 后确实得到0条结果**,所以不是方案永远无效,而是已有批量结果的实时同步缺失。[重跑结果](/tmp/idea-parity-qa/core-IN2-rerun-disabled.json)。
|
||||
|
||||
实现线索:[inspect.ts](/Users/thomas/repo/kalo/idea/src/features/analysis/inspect.ts:183) 在启动时取得方案,接收事件时过滤一次并保存;[InspectionView.tsx](/Users/thomas/repo/kalo/idea/src/features/analysis/InspectionView.tsx:219) 的树以已有 files 构建,没有将方案变化作为依赖。这与首次运行现象一致;现已按上节修复。
|
||||
|
||||
### B. CSS 语言服务器校验抛异常
|
||||
|
||||
1. 在副本新建并打开 `src/qa-validation.css`:`.qa { colr: red; }`。
|
||||
2. 等待已安装的 `vscode-css-language-server` 校验。
|
||||
3. 日志出现 `TypeError: Cannot read properties of null (reading 'validProperties')`,诊断列表为空,错误属性没有提示。
|
||||
|
||||
期望:默认 CSS 校验正常运行并对未知属性给出诊断,不抛异常。新建两个空 CSS 时已出现同一异常;专用错误样例和原生进程重启后再次复现。[运行日志及诊断](/tmp/idea-parity-qa/core-css-validation.json)、[编辑器截图](/tmp/idea-parity-qa/core-css-validation.png)、[重启日志](/tmp/idea-parity-qa/core-app-restart.log)。
|
||||
|
||||
首次排查线索为 [handler.rs](/Users/thomas/repo/kalo/idea/crates/ide-lsp/src/handler.rs:119) 的 workspace/configuration:未配置 section 返回 null。现已验证默认配置对象可修复该异常,见上节。
|
||||
|
||||
## 完成的核心场景
|
||||
|
||||
| 编号 | 结果 | 场景 | 实际验证 | 证据 |
|
||||
|---|---|---|---|---|
|
||||
| C01 | 通过 | 编辑与保存 | 输入、撤销、重做、保存磁盘、外部写入自动重载;亮/暗各复测。 | [记录](/tmp/idea-parity-qa/core-edit-confirm-results.json) |
|
||||
| C02 | 通过 | 常用编辑命令 | 同一行注释/取消注释、复制行,验证实际文档结果;亮/暗各复测。注释命令会移动到下一行,复测时重新定位原行。 | [记录](/tmp/idea-parity-qa/core-edit-commands-final-dark.json) |
|
||||
| C03 | 通过 | 项目视图与恢复 | 五种视图均切换;Open Files 成目录树;All Changed Files 仅包含被修改的已跟踪 index.ts。结束并重新启动原生进程后仍为 Open Files,23个打开路径与重启前完全一致。 | [记录](/tmp/idea-parity-qa/core-persist-after.json) |
|
||||
| C04 | 通过 | New 搜索和创建 | 项目树焦点下 ⌘N 出现 Search for file type;css 能找到 Stylesheet。CSS/SCSS/Less、Dockerfile、EditorConfig、gitignore、JSON/YAML/TOML/Shell/HTTP 的磁盘结果沿用首轮实际创建证据。 | [记录](/tmp/idea-parity-qa/core-NF1-dark.png) |
|
||||
| C05 | 通过 | ⌘N 上下文路由 | Python/Markdown 打开 New,并实际在当前文件的 src 目录创建 CSS;Java/Kotlin/TS 的动作轨迹为 code.generate,未打开 New。Kotlin 只验证路由,未声称生成代码可用。 | [记录](/tmp/idea-parity-qa/core-lastkeys.log) |
|
||||
| C06 | 通过 | 项目树文件操作 | 从选中的 src 目录 New › File 创建 qa-tree-created.txt;Rename 后旧路径消失、新路径存在;确认移至 Trash 后新路径消失。 | [记录](/tmp/idea-parity-qa/core-tree-deleted.json) |
|
||||
| C07 | 通过 | 文件内上下文查找 | In Comments 仅选中三个注释内的 shared(含 shared_history),Next/Previous 在位置3/38/78间导航,不命中代码和字符串;亮/暗各复测。 | [记录](/tmp/idea-parity-qa/core-find-final.log) |
|
||||
| C08 | 通过 | 替换大小写与排除 | Preserve Case 实际得到 bar/Bar/BAR;排除项出现删除线,Replace All 保留该项、替换其余项;亮/暗重新验证。 | [记录](/tmp/idea-parity-qa/core-FB4-final-dark.png) |
|
||||
| C09 | 通过 | 多行及搜索历史 | ⇧⌘↵ 输入跨行 alpha/beta 后计数1/1并选中完整跨行文本;⌥↓ 能打开编辑器历史,Find in Files 也显示新增 QA_shared_history。 | [记录](/tmp/idea-parity-qa/core-FB5-dark-confirm.png) |
|
||||
| C10 | 通过 | 自定义搜索范围 | 三个文件同一标记:不限定时3个文件;file:src//*.ts&&!file:*test* 仅命中 qa_scope.ts;Inspect Code 的 Custom scope 可选同一 Core TS Scope。 | [记录](/tmp/idea-parity-qa/core-FF3-final.png) |
|
||||
| C11 | 通过 | 跨文件替换与预览 | 两个文本文件6处替换,预览显示 Bar/BAR/bar,确认后磁盘一致;多行搜索可命中多个文件。保留大小写在亮/暗分别确认。 | [记录](/tmp/idea-parity-qa/core-FF4-dark-final.json) |
|
||||
| C12 | 通过 | 搜索排除归档 | 在项目内放入含唯一标记的 zip、jar,Find in Files 返回 No matches;不是只根据代码推断。 | [记录](/tmp/idea-parity-qa/core-FF5-archive.png) |
|
||||
| C13 | 通过 | 文件/类型/符号导航 | Go to File 打开 money.ts,Go to Class 打开 Cart,Go to Symbol 打开 formatMoney;调用点转到 Cart 定义,Back/Forward 正确返回和前进;亮/暗各复测。 | [记录](/tmp/idea-parity-qa/core-navigation.log) |
|
||||
| C14 | 通过 | Search Everywhere 筛选 | Files 排除 TypeScript、Classes 排除 Classes、Symbols 排除 Functions、Text 设 *.py,结果分别被过滤;切换页后各页值独立保留;亮/暗各复测。 | [记录](/tmp/idea-parity-qa/core-filters-final.log) |
|
||||
| C15 | 通过 | Actions 跳转设置 | 复选框为 Include disabled actions;搜索 code completion 有 Settings: Editor | General,选中后回车打开原生 Settings 的 Code Completion 页。 | [记录](/tmp/idea-parity-qa/core-NV2-target-final.png) |
|
||||
| C16 | 通过 | 重命名与 Generate | ⇧F6 原地重命名,第二次 ⇧F6 打开名称对话框;qaOriginalName 的声明和引用一起改为 qaRenamed。TS ⌘N 对缺失接口方法执行 Generate,生成 run() 实现。 | [记录](/tmp/idea-parity-qa/core-rename-clean.log) |
|
||||
| C17 | 通过 | LSP 补全 | 单候选自动插入开关实际改变行为;字母排序有效;函数补全插入(),有参数时光标在括号内且显示参数提示;无参光标在括号后;已有(不重复。亮/暗各复测。 | [记录](/tmp/idea-parity-qa/core-completion.log) |
|
||||
| C18 | 通过 | 格式化保护区 | 手动 Reformat 与保存时格式化都格式化保护区外的代码,@formatter:off/on 中间保持逐字不变;亮/暗各复测。 | [记录](/tmp/idea-parity-qa/core-IN7-save-dark.json) |
|
||||
| C19 | 通过 | 检查结果同步(IN-2) | 修复后亮/暗均验证严重级别、禁用和恢复即时同步,禁用时运行后重新启用也可恢复旧结果,无需重跑。 | [记录](/tmp/idea-parity-qa/fix-IN2-results.json) |
|
||||
| C20 | 通过 | 运行与测试反馈 | npm start 输出购物车合计 $134.97、退出0;正常测试通过;开启 opt-in 失败测试后树显示1 failed/4 passed、断言和源文件行、退出1。亮/暗各复测。 | [记录](/tmp/idea-parity-qa/core-runactual-final.log) |
|
||||
| C21 | 通过 | Current File 与调试 | Current File 直接运行 TS 输出 QA_CURRENT_FILE_OK;Python Current File 调试命中断点,显示 number=21,进入 double、越过后 answer=42,求值返回42,跳出、恢复后输出42、退出0。TS 调试器另列环境阻塞。 | [记录](/tmp/idea-parity-qa/core-debug-final-console.png) |
|
||||
| C22 | 通过 | Before launch 执行链 | 先运行子配置,再成功 Build,再 shell,最后主进程;记录 child/shell/main,Build 成功且主子退出0。额外验证非0步骤阻止启动并通知、循环引用被拒绝。 | [记录](/tmp/idea-parity-qa/core-RC6-success.json) |
|
||||
| C23 | 通过 | Compound | 两个成员17ms间隔启动并同时处于 running;选择 compound、从编辑器触发 Stop 后两个成员均 finished/130。 | [记录](/tmp/idea-parity-qa/core-RC7-stopped.json) |
|
||||
| C24 | 通过 | 交互终端 | PTY 输入 hello 得到回显;QA_RED 在亮/暗为红色;窗口缩放使子进程收到尺寸233→89列,恢复后120列;输入exit正常退出0,另一次Stop退出130。 | [记录](/tmp/idea-parity-qa/core-RC9-resize.png) |
|
||||
| C25 | 通过 | Power Save 核心行为 | 正常模式自动补全弹出;开启后同样输入不弹出,编辑器有横幅;有效配置同时关闭 usages Code Vision 等后台提示。随后关闭并确认重启后 false;未把这等同于全部后台任务性能验证。 | [记录](/tmp/idea-parity-qa/core-WB7-enabled.json) |
|
||||
| C26 | 通过 | CSS 校验集成 | 修复后重新编译并启动原生应用,CSS/SCSS/Less 均对 colr 返回 unknownProperties 警告,日志无原异常。 | [记录](/tmp/idea-parity-qa/fix-css-results.json) |
|
||||
| C27 | 通过 | Git常用流程 | 独立Python副本中查看HEAD与工作区diff,显示唯一QA标记差异;Commit先报告已有2个警告,选择Commit Anyway后实际提交,git diff为空,Git Log显示新提交。未推送。 | [记录](/tmp/idea-parity-qa/core-git-final.json) |
|
||||
|
||||
## 环境和验证边界
|
||||
|
||||
- Python debugpy 1.8.22 已安装,断点、变量、求值、三种单步和正常退出都实际验证。`js-debug` 未安装,**TypeScript/Node 调试没有通过判定**,没有拿 Python 的结果替代它。
|
||||
- Kotlin 两个语言服务器和 Marksman 缺失。Kotlin 的 ⌘N 仅确认路由到 Generate;未声称 Kotlin 代码生成/补全/重构已通过。
|
||||
- 部分配置通过真实 settings IPC 写入副本,运行配置执行链通过真实注册动作启动;没有把这些视作配置编辑器每个鼠标流程都已验收。
|
||||
- 第一次应用运行经过热更新,产生过状态模块/焦点残留;已关闭该调试进程、单独启动Vite和编译好的原生二进制后复测快捷键。干净启动后重命名和 Generate 正常,因此不列为产品失败。
|
||||
- `document.execCommand` 在终端缩放后的第二次注入没有发送文本;改用 textarea 的 InputEvent 后回显与正常退出均成功。这是驱动差异,不列为产品键入失败。使用的桥接输入均未被等同于人工键盘全矩阵验证。
|
||||
- 已结束并重启原生进程,Open Files 模式和23个打开路径完整恢复。[重启前](/tmp/idea-parity-qa/core-persist-before.json)、[重启后](/tmp/idea-parity-qa/core-persist-after.json)。记录中的 `/tmp` 与 `/private/tmp` 双路径是测试脚本先后用两种路径打开同一文件造成,没有将其直接列为正常用户路径问题。
|
||||
- 本轮没有应用崩溃;没有做量化卡顿测试。故意失败的测试、Before launch失败和Stop后的130通知均为测试输入产生;独立异常是上面的CSS服务器错误。
|
||||
- 本轮无产品代码改动,因此没有重复运行完整构建测试;首轮的 typecheck 与30个相关Vitest结果仍单独记录,不作为运行场景的替代。
|
||||
- 测试进程已停止;Power Save 恢复为false;全局语言/主题未新增改动。副本和截图保留供复核。
|
||||
@@ -0,0 +1,125 @@
|
||||
# IDEA 对齐运行验收记录(2026-10-25)
|
||||
|
||||
结论:**尚未达到全量验收通过条件**。累计94项中,功能断言通过35项、失败1项、部分验证58项。IN-2与清单外CSS校验异常已修复并经原生应用复测。核心复测27场景的具体范围、修复后27通过/0失败结论见[核心补测报告](acceptance-idea-core-result.md);不能把本次核心补测当作原94项全部完成。
|
||||
|
||||
目标提交为 `1e00ea5`;启动后仓库由外部更新为 `d3feb05 chore: v0.1.14`,仅版本文件变化,实际后续验收运行此版本。首次验收未改动产品源码;随后按用户要求修复IN-2和CSS配置,版本为 `d3feb05` 加工作区改动,未提交。测试均使用 `/tmp/idea-parity-qa/` 下的 fixture 副本。
|
||||
|
||||
使用 `pnpm tauri dev` 启动真实 macOS Tauri 应用,桥接操作真实 DOM、注册动作,并读取运行结果。部分设置通过真实 IPC 写入测试项目配置,以核对运行时行为;这不替代 Settings 原始鼠标路径或快捷键验证。热更新造成的旧模块实例问题已识别,相关外部库检查重新使用运行中的模块后重做;以 `libraries-final.log` 为准。
|
||||
|
||||
亮/暗主题已抽查 New、查找、运行配置、数据库、工具栏、Cleanup;未做到94项各自双主题全覆盖,主题总要求仍未完成。中文抽查发现可复现漏译。未观察到功能整体缺失;未覆盖项不能据此判定已实现。
|
||||
|
||||
辅助检查:`pnpm typecheck` 退出码0;4个相关 Vitest 文件共30个测试通过(libraries、NewPopup、file templates、run-anything)。没有重新运行完整 Rust/前端测试,不沿用清单中旧提交的通过数作为本轮证据。
|
||||
|
||||
## 逐项记录
|
||||
|
||||
| 编号 | 结果 | 现象、范围和证据 |
|
||||
|---|---|---|
|
||||
| PV-1 | 通过 | 真实 Project 标题下拉列出五种要求的模式;[证据](/tmp/idea-parity-qa/PV-1-menu.png) |
|
||||
| PV-2 | 通过 | 核心复测:五种模式已操作;Open Files 成树、All Changed Files 仅显示修改的已跟踪文件;原生进程重启后 Open Files 和23个打开路径恢复。[证据](/tmp/idea-parity-qa/core-persist-after.json) |
|
||||
| PV-3 | 通过 | Open Files 中定位未打开的 README.md,自动回到 Project 并选中 |
|
||||
| PV-4 | 部分 | Python 副本已建 .venv,External Libraries 注册标准库、venv 库和 site-packages;.venv 下逐级展开对照未完成;[证据](/tmp/idea-parity-qa/PV-6-python-app.png) |
|
||||
| PV-5 | 部分 | 在副本 site-packages 新建 qa_library.py,经编辑器插入文字后内容和磁盘均不变,readOnly=true,横幅正常;节点重命名/删除/新建/拖拽未逐项操作;[证据](/tmp/idea-parity-qa/PV-5-blocked-input.png) |
|
||||
| PV-6 | 部分 | Rust stdlib、Go SDK、JDK/src.zip、Gradle junit-jupiter 源码 jar、TS 的 typescript/vitest 直接依赖均已识别并注册到树;Cargo 依赖、Go 模块和 Maven 分组未完整覆盖;[证据](/tmp/idea-parity-qa/libraries-final.log) |
|
||||
| PV-7 | 部分 | JDK src.zip!/java.base/java/lang/String.java 实际打开,语法高亮、readOnly=true;树内逐级浏览及另一个 jar 未完整操作;[证据](/tmp/idea-parity-qa/PV-7-archive.png) |
|
||||
| PV-8 | 通过 | TS 副本 package.json 添加已在 node_modules 中的 qa-dep;857ms 后 External Libraries 已出现该依赖,随后恢复清单;[证据](/tmp/idea-parity-qa/PV-8-refresh.json) |
|
||||
| NF-1 | 通过 | 核心复测:项目树选中src,⌘N 打开带搜索框的 New;css 找到 Stylesheet。随后 New › File 实际在src创建文件。[证据](/tmp/idea-parity-qa/core-tree-new-parent.json) |
|
||||
| NF-2 | 通过 | 实际创建 CSS、SCSS、Less、Dockerfile、.editorconfig、.gitignore、JSON、YAML、TOML、Shell 和 HTTP 文件;核对磁盘扩展名及模板内容;[证据](/tmp/idea-parity-qa/templatesactual.log) |
|
||||
| NF-3 | 通过 | 核心复测:Python/Markdown 的 ⌘N 均打开 New,实际创建的CSS都在当前文件的src目录。[证据](/tmp/idea-parity-qa/core-lastkeys.log) |
|
||||
| NF-4 | 通过 | 核心复测:Java/Kotlin/TS 的 ⌘N 动作轨迹为 code.generate,均不打开 New;TS 实际生成缺失接口方法。Kotlin只验证路由,语言服务器缺失。[证据](/tmp/idea-parity-qa/core-NF4-generate.png) |
|
||||
| NF-5 | 部分 | 动作能弹出 New 并在当前 worker 目录创建文件;任意焦点和 ⌃⌥N 按键矩阵未完整验证;[证据](/tmp/idea-parity-qa/NF-5.png) |
|
||||
| NF-6 | 通过 | 创建 /tmp/idea-parity-qa/qa-new-project,勾选 Git,磁盘 .git 存在,出现独立 project-1 窗口;[证据](/tmp/idea-parity-qa/NF-6-created.json) |
|
||||
| NF-7 | 部分 | 重命名为 QA renamed project 后原生窗口标题更新,polyglot 磁盘目录保持原名;最近项目列表未单独检查;[证据](/tmp/idea-parity-qa/NF-7-renamed.png) |
|
||||
| FB-1 | 通过 | 漏斗列出 Search In Selection 和清单中的六种上下文范围;[证据](/tmp/idea-parity-qa/FB-1-filter.png) |
|
||||
| FB-2 | 通过 | 核心复测:In Comments 计数3;Next/Previous在三个注释位置间跳转,不命中代码/字符串;亮暗均验证。[证据](/tmp/idea-parity-qa/core-find-final.log) |
|
||||
| FB-3 | 通过 | 9 处 foo/Foo/FOO 替换为 bar/Bar/BAR,磁盘副本编辑内容符合预期;[证据](/tmp/idea-parity-qa/FB-3-result.png) |
|
||||
| FB-4 | 通过 | 排除第一处匹配后显示删除线,Replace All 保留该处 bar,其余变为 baz;[证据](/tmp/idea-parity-qa/FB-4-result.png) |
|
||||
| FB-5 | 通过 | 核心复测:⇧⌘↵ 后跨行输入alpha/beta,计数1/1、选择完整跨行内容;亮暗均确认。[证据](/tmp/idea-parity-qa/core-FB5-dark-confirm.png) |
|
||||
| FB-6 | 通过 | 核心复测:⌥↓ 打开编辑器最近搜索,新增QA_shared_history同时出现在 Find in Files 的最近搜索。[证据](/tmp/idea-parity-qa/core-find-final.log) |
|
||||
| FF-1 | 通过 | 真实窗口显示 In Project/Module/Directory/Scope,polyglot Module 下拉含根模块及 api、web;[证据](/tmp/idea-parity-qa/FF-1-options.json) |
|
||||
| FF-2 | 通过 | 新建并保存自定义 scope;!(file:src//* 实时显示 Missing `)` 错误,合法表达式出现在下拉;[证据](/tmp/idea-parity-qa/FF-2-real-invalid.png) |
|
||||
| FF-3 | 通过 | 核心复测:自定义Scope将3个标记文件缩至唯一qa_scope.ts;Inspect Code的Custom scope也能选Core TS Scope。[证据](/tmp/idea-parity-qa/core-FF3-final.png) |
|
||||
| FF-4 | 通过 | 核心复测:跨文件多行搜索命中;6处替换的保留大小写预览与磁盘Bar/BAR/bar一致;亮暗均确认。[证据](/tmp/idea-parity-qa/core-FF4-dark-final.json) |
|
||||
| FF-5 | 通过 | 核心复测:项目内jar/zip包含唯一标记,Find in Files不命中。[证据](/tmp/idea-parity-qa/core-FF5-archive.png) |
|
||||
| NV-1 | 通过 | 核心复测:四页分别过滤文件类型/类种类/符号种类/文件掩码,结果变化且各页保留独立选择;亮暗均验证。[证据](/tmp/idea-parity-qa/core-filters-final.log) |
|
||||
| NV-2 | 通过 | 核心复测:文案正确;Settings: Code Completion结果回车打开原生设置的对应页面。[证据](/tmp/idea-parity-qa/core-NV2-target-final.png) |
|
||||
| NV-3 | 部分 | 未执行:动作快捷键录入、生效与三种冲突解决 |
|
||||
| NV-4 | 部分 | 未执行:书签列表新建/重命名/删除/默认列表/移动矩阵 |
|
||||
| NV-5 | 部分 | 书签弹窗入口存在且空状态正常;文件、文件夹、行书签及按列表分组跳转未执行;[证据](/tmp/idea-parity-qa/NV-5.png) |
|
||||
| NV-6 | 部分 | 未执行:Structure 字段/非公开成员/可见性排序 |
|
||||
| NV-7 | 部分 | 未执行:支持 typeHierarchy 的 TS/Java 继承成员及跳转 |
|
||||
| NV-8 | 部分 | Recent Locations 有相对时间和代码片段;类/方法面包屑和片段高亮未完整核对;[证据](/tmp/idea-parity-qa/NV-8.png) |
|
||||
| NV-9 | 部分 | 已提交 fixture 的 Python 函数出现 Thomas Hong 作者;Settings 有 Code author;多人 +N 及关闭效果未验证 |
|
||||
| ED-1 | 通过 | 核心复测:关闭单候选自动插入时保留一个候选,开启后实际自动插入;亮暗均确认。[证据](/tmp/idea-parity-qa/core-completion.log) |
|
||||
| ED-2 | 通过 | 核心复测:打开Sort suggestions alphabetically后真实候选按名称排序,popup含Sort by name;通过设置开关路径验证。[证据](/tmp/idea-parity-qa/core-ED2-sorted-dark.png) |
|
||||
| ED-3 | 通过 | 核心复测:有参/无参函数自动括号、光标落点和参数提示符合要求;已有(不重复;亮暗均验证。[证据](/tmp/idea-parity-qa/core-completion.log) |
|
||||
| ED-4 | 部分 | Top/Bottom/Left/Right/None 均切换并截图,左右为竖排,None 隐藏标签;滚动、拖拽和菜单一致性未逐项验证;[证据](/tmp/idea-parity-qa/ED-4-none.png) |
|
||||
| ED-5 | 部分 | Editor Tabs 的相关设置项齐全;每种选项实际行为未逐项验证;[证据](/tmp/idea-parity-qa/settings-Editor-Tabs.png) |
|
||||
| ED-6 | 部分 | Inline Completion 设置页存在;未配置支持 inlineCompletion 的服务,运行预览及快捷键跳过,不能视为通过;[证据](/tmp/idea-parity-qa/settings-Inline-Completion.png) |
|
||||
| IN-1 | 部分 | Inspections 页面有方案、搜索、按语言树和描述区域;三态与 Severity 的编辑操作未完成;[证据](/tmp/idea-parity-qa/IN-1-settings.png) |
|
||||
| IN-2 | 通过 | 修复复测:亮/暗下编辑器和旧Inspect Code结果随严重级别、禁用、恢复即时同步,计数同步;禁用时运行后也能重新启用恢复诊断,无需重跑。[证据](/tmp/idea-parity-qa/fix-IN2-results.json) |
|
||||
| IN-3 | 部分 | 未执行:检查方案 Duplicate/Copy/Rename/Delete 和内置方案保护 |
|
||||
| IN-4 | 部分 | 测试副本已写入 recieve;注释/字符串/声明和调用名的诊断对照未完成 |
|
||||
| IN-5 | 部分 | Spelling 设置页面存在;Typo 上下文候选及保存两类词典未执行;[证据](/tmp/idea-parity-qa/settings-Spelling.png) |
|
||||
| IN-6 | 部分 | Code Style 页面有 Default (IDE) Scheme 与 Copy to Project;语言子页面联动未完整操作;[证据](/tmp/idea-parity-qa/settings-Code-Style.png) |
|
||||
| IN-7 | 通过 | 核心复测:手动及保存格式化都格式化保护区之外,formatter:off/on之间逐字保持;亮暗均验证。[证据](/tmp/idea-parity-qa/core-IN7-save-dark.json) |
|
||||
| IN-8 | 通过 | 项目配置 Do not format 为 *.json,执行 Reformat Code 出现明确跳过提示;[证据](/tmp/idea-parity-qa/IN-8-excluded.png) |
|
||||
| IN-9 | 部分 | Cleanup 范围及 fix/import/format 选项存在,可取消;实际清理结果和中途取消未执行;[证据](/tmp/idea-parity-qa/IN-9.png) |
|
||||
| FT-1 | 部分 | 打开 x.foo 后添加 YAML 关联,现有 editor context 立即变为 yaml/YAML;图标及 Go to File 未独立核对;[证据](/tmp/idea-parity-qa/FT-1-yaml.png) |
|
||||
| FT-2 | 部分 | 调用同名注册动作使 YAML→JSON→YAML,现有编辑器立即更新;右键菜单路径及撤销未操作;[证据](/tmp/idea-parity-qa/FT-2-revert.json) |
|
||||
| FT-3 | 通过 | 无扩展名 qa-hashbang 带 #!/usr/bin/env python3,实际 editor context 为 python/Python;[证据](/tmp/idea-parity-qa/FT-3-hashbang.png) |
|
||||
| PS-1 | 部分 | 添加外部 extra-root 后树出现根,Find in Files 命中 extra.ts;Go to File 和外部文件修改刷新未完整验证;[证据](/tmp/idea-parity-qa/PS-1-search.png) |
|
||||
| PS-2 | 部分 | 即时设置 *.log;tmp* 后 Find in Files 不再命中 qa.log 中的唯一标记;树与索引侧未独立核对;[证据](/tmp/idea-parity-qa/PS-2-search.png) |
|
||||
| TP-1 | 部分 | File and Code Templates 页面包含 Includes,说明支持 #parse;编辑 File Header 后新建 Java/Kotlin 未执行 |
|
||||
| TP-2 | 部分 | 模板页有 Code 标签;修改测试方法模板并生成测试未执行 |
|
||||
| TP-3 | 部分 | Reformat according to style 默认已勾选;$END$ 光标及格式化效果未单独验证;[证据](/tmp/idea-parity-qa/settings-File-and-Code-Templates.png) |
|
||||
| RC-1 | 通过 | 核心复测:Current File保持可选,直接运行TS输出正确;Python Current File调试命中断点并可单步/求值/正常退出。Node调试器缺失单独记为环境阻塞。[证据](/tmp/idea-parity-qa/core-debug-final-console.png) |
|
||||
| RC-2 | 通过 | + 菜单列出所有要求类型,含 Compound 与 Docker 三种子类型,搜索输入存在;[证据](/tmp/idea-parity-qa/RC-2-types.png) |
|
||||
| RC-3 | 部分 | 实际新建 Shell/Program,Program env 运行成功,检测配置正常;其余每种类型执行及旧配置兼容未覆盖;[证据](/tmp/idea-parity-qa/RC-8-process-output.png) |
|
||||
| RC-4 | 部分 | 表单支持复制/分组/排序/Templates;对话框 Run 成功,local TOML 已落盘且 git check-ignore 命中 .openidea/.gitignore;其余子流程未逐项执行 |
|
||||
| RC-5 | 部分 | Modify options 显示各类可选项;移除控件与各选项的运行效果未完整验证;[证据](/tmp/idea-parity-qa/RC-5.json) |
|
||||
| RC-6 | 通过 | 核心复测:实际子配置→Build→Shell→主进程;Build成功,记录child/shell/main;失败步骤中止并通知,循环被拒绝。[证据](/tmp/idea-parity-qa/core-RC6-success.json) |
|
||||
| RC-7 | 通过 | 核心复测:两成员17ms间隔启动并同时running,选中compound从编辑器触发Stop后都结束、退出130。[证据](/tmp/idea-parity-qa/core-RC7-stopped.json) |
|
||||
| RC-8 | 部分 | A=1;B=2 输入后对话框拆成两行,关闭系统环境后 /usr/bin/env 仅输出 A/B,退出码 0;独立 Paste 按钮未操作;[证据](/tmp/idea-parity-qa/RC-8-process-output.png) |
|
||||
| RC-9 | 通过 | 核心复测:PTY回显、亮暗ANSI颜色、resize传到子进程(233→89列)均正常;输入exit退出0,另次Stop退出130。[证据](/tmp/idea-parity-qa/core-RC9-resize.png) |
|
||||
| RC-10 | 部分 | 空 Run 显示三条提示及 run configuration 链接;点击链接未操作 |
|
||||
| RC-11 | 部分 | 本机 Docker 可用,但未运行/停止 fixture Docker 和 Compose,不能视为通过 |
|
||||
| GT-1 | 部分 | Graph Options 所列排序和分支选项齐全;复杂分支图下的效果未执行;[证据](/tmp/idea-parity-qa/GT-1-options.png) |
|
||||
| GT-2 | 部分 | View Options 所列显示项和 Highlight 存在;开关效果及重启持久化未完整验证;[证据](/tmp/idea-parity-qa/GT-2-options.png) |
|
||||
| GT-3 | 部分 | 未执行:Log 焦点 ⌘F、补全、跳转及自动加载更多 |
|
||||
| GT-4 | 部分 | 未执行:设置 Date 过滤后图仍保留 |
|
||||
| GT-5 | 部分 | 七种对话框均实际打开,选项可见;未执行 pull/merge/rebase/worktree/clone 的磁盘变化;[证据](/tmp/idea-parity-qa/gitcheck.log) |
|
||||
| SV-1 | 部分 | Add Service 菜单有三类要求入口;⌘N 和无连接空状态未完整验证;[证据](/tmp/idea-parity-qa/SV-1.png) |
|
||||
| SV-2 | 部分 | 实际 Program/Run Anything/PTY 均已启动;Services 中运行配置分组与停止/重跑/输出跳转未验证 |
|
||||
| SV-3 | 部分 | 自动连接 orbstack,显示容器、镜像、卷和网络;新建多个连接及绑定操作路由未执行;[证据](/tmp/idea-parity-qa/SV-1.png) |
|
||||
| TD-1 | 部分 | TODO 有 Scope Based、Changes,显示7条 fixture TODO/FIXME;自定义范围和多个 changelist 下拉未验证;[证据](/tmp/idea-parity-qa/TD-1.png) |
|
||||
| CV-1 | 部分 | LCOV 导入显示 app.ts 50%(1/2),管理弹窗列出报告;Go/JaCoCo、多报告切换和 gutter 未完整验证;[证据](/tmp/idea-parity-qa/CV-1-import.png) |
|
||||
| DB-1 | 部分 | Driver 下拉按字母列出 CockroachDB/Redshift/TiDB 等;逐种默认端口未核对;[证据](/tmp/idea-parity-qa/DB-1-list.png) |
|
||||
| DB-2 | 通过 | 指定 JDBC URL 解析出 h、5432、db,SSL 页为 Verify Full;[证据](/tmp/idea-parity-qa/DB-2-ssl.png) |
|
||||
| DB-3 | 部分 | Options/Schemas/Advanced 页签存在;未连 SQLite/Postgres 验证只读/启动脚本/时区/过滤/驱动属性 |
|
||||
| DB-4 | 部分 | 颜色和 Add comment 控件存在;树节点、console 标签及 hover 效果未验证 |
|
||||
| WB-1 | 部分 | Run Anything 执行 pwd,输出进入 Run,cwd 为 fixture,退出码0,并列出检测配置;双 Ctrl、Maven/Gradle 和新历史未完整验证;[证据](/tmp/idea-parity-qa/WB-1-output.png) |
|
||||
| WB-2 | 部分 | Customize Main Toolbar 可打开并显示增删/排序/恢复控件;实际保存和重启持久化未执行;[证据](/tmp/idea-parity-qa/WB-2.png) |
|
||||
| WB-3 | 部分 | Save Current Layout as 弹出命名输入;另存、恢复、重命名、删除完整流程未执行;[证据](/tmp/idea-parity-qa/WB-3-save.json) |
|
||||
| WB-4 | 部分 | 未执行:原生 View › Tool Windows 与注册表的一一核对 |
|
||||
| WB-5 | 部分 | Quick Switch Scheme 弹出四类选项;其余菜单命令及所有效果未完整验证;[证据](/tmp/idea-parity-qa/WB-5.png) |
|
||||
| WB-6 | 部分 | 无可用重构位置弹出 Nothing here;原生菜单上下文置灰未验证;[证据](/tmp/idea-parity-qa/WB-6.png) |
|
||||
| WB-7 | 部分 | Power Save Mode 切换后编辑器出现横幅,随后关闭恢复;后台高亮与自动弹出抑制未完整验证;[证据](/tmp/idea-parity-qa/WB-7-real.png) |
|
||||
| WB-8 | 部分 | 未执行:完整 Export/Import 设置与快捷键、模板、宏、布局恢复 |
|
||||
| WB-9 | 部分 | 录制 QA macro 后回放,内容为 QA macroQA macro;保存命名和 Keymap 绑定未执行;[证据](/tmp/idea-parity-qa/WB-9-replay-result.png) |
|
||||
| WB-10 | 部分 | Coverage 导入的信息通知显示 Don’t Show Again;点击后同类通知抑制未验证 |
|
||||
| I18N-1 | 失败 | 复现:切换中文,打开 Code › Code Cleanup。实际 Whole project、Module or directory、Uncommitted files 和底部说明仍为英文;打开 Customize Main Toolbar 后 Project Widget/VCS Widget/Build Project/Run Widget 仍为英文;Services 的 Containers/Images/Volumes/Networks 仍为英文。期望这些新增界面文案均翻译;均不属于清单已知例外;[证据](/tmp/idea-parity-qa/IN-zh-dark.png) |
|
||||
|
||||
## 独立问题与环境说明
|
||||
|
||||
- 崩溃:已执行流程中未观察到应用崩溃。版本更新引起的 dev 自动重编译不是崩溃。
|
||||
- 控制台:有自动化自身造成的错误(错误 action id、首次尝试不存在的文件、带换行注入脚本的 Unexpected EOF)和手动 reload 后 Tauri callback 警告;不归为产品功能失败。尚不能声明控制台全量无错误。应用日志在 [/tmp/idea-parity-qa.log](/tmp/idea-parity-qa.log)。
|
||||
- 卡顿:未观察到已执行操作中的明显持续卡顿;没有完成量化性能验收。桥接脚本等待用户输入对话框导致的超时不按应用卡顿计。
|
||||
- 核心补测新增的CSS语言服务器validProperties空值异常已修复;CSS/SCSS/Less真实校验均返回未知属性警告,见核心报告修复复测。
|
||||
- Python REPL 的 Stop 先发中断(出现 KeyboardInterrupt),随后超时强制结束,最终137/SIGKILL;这是本轮观察结果,未仅凭此判失败。
|
||||
- 首轮安装TS依赖时pnpm提示esbuild脚本未批准;核心补测已实际运行npm start及正常/故意失败测试。Build通过专用最小TS目标验证,未据此宣称所有原始QA文件能通过类型检查。
|
||||
- 全量放行前仍需完成表中的未执行子项,包括所有语言/运行类型、Docker、复杂Git图与合并/变基、数据库、设置导入导出、完整书签/布局管理等;双主题逐项与中文复测也未全覆盖。Before launch、Compound、补全和基础运行/调试已有核心复测证据,见对应行。
|
||||
|
||||
截图和结构化证据目录:[/tmp/idea-parity-qa](/tmp/idea-parity-qa)。验收期间使用的全局主题、语言和 Power Save Mode 已恢复;最后录制宏为 QA 样例,测试项目仍保留供复核。
|
||||
|
||||
|
||||
核心补测:新增真实编辑、导航、补全、重命名、检查同步、运行/调试、Before launch/Compound、PTY和原生重启验证;详情见[核心补测报告](acceptance-idea-core-result.md)。原表中其他待测子项仍保留,不因核心补测而自动变绿。
|
||||
|
Після Ширина: | Висота: | Розмір: 169 KiB |
|
Після Ширина: | Висота: | Розмір: 133 KiB |
|
Після Ширина: | Висота: | Розмір: 171 KiB |
|
Після Ширина: | Висота: | Розмір: 135 KiB |
|
Після Ширина: | Висота: | Розмір: 164 KiB |
|
Після Ширина: | Висота: | Розмір: 129 KiB |
|
Після Ширина: | Висота: | Розмір: 168 KiB |
|
Після Ширина: | Висота: | Розмір: 131 KiB |
@@ -3,21 +3,7 @@ import tseslint from "typescript-eslint";
|
||||
import reactHooks from "eslint-plugin-react-hooks";
|
||||
|
||||
export default tseslint.config(
|
||||
{
|
||||
ignores: [
|
||||
"dist",
|
||||
"target",
|
||||
"src-tauri",
|
||||
"crates",
|
||||
"src/bindings.ts",
|
||||
"fixtures",
|
||||
"plugins",
|
||||
"test-results",
|
||||
"playwright-report",
|
||||
// Agent worktrees: whole checkouts of the repo.
|
||||
".claude",
|
||||
],
|
||||
},
|
||||
{ ignores: ["dist", "target", "src-tauri", "crates", "src/bindings.ts", "fixtures", "plugins", "test-results", "playwright-report"] },
|
||||
js.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
{
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<div id="splash" class="splash" data-tauri-drag-region>
|
||||
<svg class="splash-logo" viewBox="22 24 56 56" aria-hidden="true">
|
||||
<rect x="22" y="26" width="56" height="52" rx="12" fill="#D9582C" /><rect x="27" y="26" width="46" height="42" rx="9" fill="#1B1A1A" /><circle cx="44" cy="47.4" r="4.1" fill="none" stroke="#EAE7E0" stroke-width="2.7" /><rect x="54.3" y="42" width="2.8" height="10.5" fill="#EAE7E0" /><rect x="51.2" y="42" width="5.9" height="2.5" fill="#EAE7E0" /><rect x="51.2" y="50" width="9.4" height="2.5" fill="#EAE7E0" /><circle cx="55.7" cy="38.4" r="1.8" fill="#EAE7E0" />
|
||||
<svg class="splash-logo" viewBox="0 0 64 64" aria-hidden="true">
|
||||
<rect width="64" height="64" rx="15" fill="#0E0E10" />
|
||||
<circle cx="26" cy="32" r="11" fill="none" stroke="#FFFFFF" stroke-width="8" />
|
||||
<rect x="43" y="18" width="8" height="28" rx="1.5" fill="#FF4F1A" />
|
||||
</svg>
|
||||
<!-- "OpenIDEA" in Inter 500 as outlines: the web font loads late in dev and would swap in. -->
|
||||
<svg class="splash-wordmark" viewBox="0 -1984 9994 2478" role="img" aria-label="OpenIDEA">
|
||||
|
||||
@@ -38,11 +38,6 @@ eclipse = { downloadSources = true }
|
||||
references = { includeDecompiledSources = true }
|
||||
signatureHelp = { enabled = true }
|
||||
configuration = { updateBuildConfiguration = "automatic" }
|
||||
# Generated code (implement methods, getters, toString…) indents like the editor (`indent` above).
|
||||
format = { insertSpaces = true, tabSize = 4 }
|
||||
# Calls complete as `name()` with the caret inside and parameter info, not guessed arguments;
|
||||
# JDK internals (`sun.*`, `com.sun.*`, `jdk.*`) and AWT's `List` stay out of completion and auto-import.
|
||||
completion = { guessMethodArguments = "off", filteredTypes = ["java.awt.List", "com.sun.*", "sun.*", "jdk.*", "org.graalvm.*", "io.micrometer.shaded.*"] }
|
||||
|
||||
[language-servers.initialization-options.settings.java.import]
|
||||
# Keep Eclipse metadata (.project, .classpath, .settings) out of the project.
|
||||
|
||||
@@ -19,8 +19,6 @@ name = "kotlin-language-server"
|
||||
# Alternative: used only when the server above is not installed.
|
||||
fallback = true
|
||||
command = "kotlin-language-server"
|
||||
# Its bundled Kotlin compiler can't parse newer JDK versions ("25.0.4.1").
|
||||
max-java = 21
|
||||
root-markers = ["settings.gradle.kts", "settings.gradle", "build.gradle.kts", "build.gradle", "pom.xml"]
|
||||
install-hint = "brew install kotlin-language-server (https://github.com/fwcd/kotlin-language-server)"
|
||||
|
||||
|
||||
@@ -15,14 +15,6 @@ args = ["--stdio"]
|
||||
root-markers = ["pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", "Pipfile", "pyrightconfig.json"]
|
||||
install-hint = "pip install basedpyright (or: uv tool install basedpyright)"
|
||||
|
||||
# basedpyright defaults to "recommended", which flags unannotated attributes and
|
||||
# every unknown type. "standard" reports real problems; a project's own
|
||||
# `[tool.basedpyright]` / pyrightconfig.json still takes precedence.
|
||||
[language-servers.initialization-options.settings.basedpyright.analysis]
|
||||
typeCheckingMode = "standard"
|
||||
# Off whenever analysis settings are sent without it: `src/` layouts would stop resolving.
|
||||
autoSearchPaths = true
|
||||
|
||||
[[language-servers]]
|
||||
name = "pyright"
|
||||
# Alternative: used only when the server above is not installed.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "openidea",
|
||||
"private": true,
|
||||
"description": "An open-source IDE inspired by IntelliJ IDEA",
|
||||
"version": "0.1.19",
|
||||
"version": "0.1.18",
|
||||
"license": "Apache-2.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* Linked, not inlined in index.html: release builds hash inline <style> blocks into the CSP,
|
||||
which voids style-src 'unsafe-inline' and blocks the editor's runtime-injected styles. */
|
||||
/* Start-up splash over the page until the window's launch project is open (platform/splash.ts).
|
||||
Until tokens load, the colours are the last theme's --bg-frame / --fg-muted that boot.js
|
||||
restored as --boot-*, else these built-in ones; the bar keeps the last --accent throughout. */
|
||||
Until tokens load, the colours are the last theme's --bg-frame / --fg-muted / --accent that
|
||||
boot.js restored as --boot-*, else these built-in ones. */
|
||||
/* Not on html: the canvas then takes body's (themed) background, which a fast resize shows before relayout. */
|
||||
body, .splash { background: var(--bg-frame, var(--boot-frame, #e9eaee)); }
|
||||
:root[data-theme="dark"] :is(body, .splash) { background: var(--bg-frame, var(--boot-frame, #26282c)); }
|
||||
@@ -33,13 +33,11 @@ body, .splash { background: var(--bg-frame, var(--boot-frame, #e9eaee)); }
|
||||
/* 15px Inter: 2048 units per em, the line box from ascender to descender. */
|
||||
.splash-wordmark { width: 73.2px; height: 18.15px; }
|
||||
.splash-bar { width: 120px; height: 2px; border-radius: 1px; overflow: hidden; background: rgb(127 127 127 / 0.18); }
|
||||
/* Fake progress: eases towards ~90% over the 4 s cap; hideSplash() fills it before fading out.
|
||||
The remembered accent comes first: tokens.css brings the theme's default --accent before
|
||||
settings restore a custom one, which would flash the default mid-load. */
|
||||
/* Fake progress: eases towards ~90% over the 4 s cap; hideSplash() fills it before fading out. */
|
||||
.splash-bar > i {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: var(--boot-accent, var(--accent, #3871e1));
|
||||
background: var(--accent, var(--boot-accent, #3871e1));
|
||||
transform-origin: left;
|
||||
animation: splash-fill 4s cubic-bezier(0.1, 0.7, 0.3, 1) both;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ tauri-plugin-single-instance = "2"
|
||||
tauri-plugin-updater = "2"
|
||||
tracing-appender = "0.2"
|
||||
tauri-specta = { version = "=2.0.0-rc.25", features = ["derive", "typescript"] }
|
||||
specta-typescript.workspace = true
|
||||
specta-typescript = "0.0.12"
|
||||
specta.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
||||
|
До Ширина: | Висота: | Розмір: 2.6 KiB Після Ширина: | Висота: | Розмір: 4.1 KiB |
|
До Ширина: | Висота: | Розмір: 4.9 KiB Після Ширина: | Висота: | Розмір: 8.9 KiB |
|
До Ширина: | Висота: | Розмір: 718 B Після Ширина: | Висота: | Розмір: 877 B |
|
До Ширина: | Висота: | Розмір: 2.1 KiB Після Ширина: | Висота: | Розмір: 3.2 KiB |
|
До Ширина: | Висота: | Розмір: 2.9 KiB Після Ширина: | Висота: | Розмір: 4.5 KiB |
|
До Ширина: | Висота: | Розмір: 2.9 KiB Після Ширина: | Висота: | Розмір: 4.7 KiB |
|
До Ширина: | Висота: | Розмір: 5.5 KiB Після Ширина: | Висота: | Розмір: 10 KiB |
|
До Ширина: | Висота: | Розмір: 710 B Після Ширина: | Висота: | Розмір: 870 B |
|
До Ширина: | Висота: | Розмір: 5.8 KiB Після Ширина: | Висота: | Розмір: 11 KiB |
|
До Ширина: | Висота: | Розмір: 993 B Після Ширина: | Висота: | Розмір: 1.2 KiB |
|
До Ширина: | Висота: | Розмір: 1.5 KiB Після Ширина: | Висота: | Розмір: 2.1 KiB |
|
До Ширина: | Висота: | Розмір: 1.8 KiB Після Ширина: | Висота: | Розмір: 2.7 KiB |
|
До Ширина: | Висота: | Розмір: 1.1 KiB Після Ширина: | Висота: | Розмір: 1.4 KiB |
|
До Ширина: | Висота: | Розмір: 10 KiB Після Ширина: | Висота: | Розмір: 13 KiB |
|
До Ширина: | Висота: | Розмір: 9.9 KiB Після Ширина: | Висота: | Розмір: 20 KiB |
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="22 24 56 56"><title>OpenIDEA</title><rect x="22" y="26" width="56" height="52" rx="12" fill="#D9582C"/><rect x="27" y="26" width="46" height="42" rx="9" fill="#1B1A1A"/><circle cx="44" cy="47.4" r="4.1" fill="none" stroke="#EAE7E0" stroke-width="2.7"/><rect x="54.3" y="42" width="2.8" height="10.5" fill="#EAE7E0"/><rect x="51.2" y="42" width="5.9" height="2.5" fill="#EAE7E0"/><rect x="51.2" y="50" width="9.4" height="2.5" fill="#EAE7E0"/><circle cx="55.7" cy="38.4" r="1.8" fill="#EAE7E0"/></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>OpenIDEA</title><rect width="64" height="64" rx="15" fill="#0E0E10"/><circle cx="26" cy="32" r="11" fill="none" stroke="#FFFFFF" stroke-width="8"/><rect x="43" y="18" width="8" height="28" rx="1.5" fill="#FF4F1A"/></svg>
|
||||
|
До Ширина: | Висота: | Розмір: 573 B Після Ширина: | Висота: | Розмір: 311 B |
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 100 100" role="img" aria-label="OpenIDEA"><rect x="10" y="10" width="80" height="80" rx="18" fill="#EAE7E0"/><g transform="translate(50 50) scale(1.25) translate(-50 -52)"><rect x="22" y="26" width="56" height="52" rx="12" fill="#D9582C"/><rect x="27" y="26" width="46" height="42" rx="9" fill="#1B1A1A"/><circle cx="44" cy="47.4" r="4.1" fill="none" stroke="#EAE7E0" stroke-width="2.7"/><rect x="54.3" y="42" width="2.8" height="10.5" fill="#EAE7E0"/><rect x="51.2" y="42" width="5.9" height="2.5" fill="#EAE7E0"/><rect x="51.2" y="50" width="9.4" height="2.5" fill="#EAE7E0"/><circle cx="55.7" cy="38.4" r="1.8" fill="#EAE7E0"/></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024" role="img" aria-label="OpenIDEA"><rect x="100" y="100" width="824" height="824" rx="185" fill="#0E0E10"/><g transform="translate(100 100) scale(12.875)"><rect width="64" height="64" rx="15" fill="none"/><circle cx="26" cy="32" r="11" fill="none" stroke="#FFFFFF" stroke-width="8"/><rect x="43" y="18" width="8" height="28" rx="1.5" fill="#FF4F1A"/></g><rect x="102" y="102" width="820" height="820" rx="183" fill="none" stroke="#FFFFFF" stroke-opacity="0.10" stroke-width="4"/></svg>
|
||||
|
До Ширина: | Висота: | Розмір: 721 B Після Ширина: | Висота: | Розмір: 575 B |
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="435" height="128" viewBox="0 0 435 128" role="img" aria-label="OpenIDEA"><title>OpenIDEA</title><g transform="translate(14 14)"><rect x="10" y="10" width="80" height="80" rx="18" fill="#EAE7E0"/><g transform="translate(50 50) scale(1.25) translate(-50 -52)"><rect x="22" y="26" width="56" height="52" rx="12" fill="#D9582C"/><rect x="27" y="26" width="46" height="42" rx="9" fill="#1B1A1A"/><circle cx="44" cy="47.4" r="4.1" fill="none" stroke="#EAE7E0" stroke-width="2.7"/><rect x="54.3" y="42" width="2.8" height="10.5" fill="#EAE7E0"/><rect x="51.2" y="42" width="5.9" height="2.5" fill="#EAE7E0"/><rect x="51.2" y="50" width="9.4" height="2.5" fill="#EAE7E0"/><circle cx="55.7" cy="38.4" r="1.8" fill="#EAE7E0"/></g></g><g transform="translate(0 88.01)"><path fill="#FFFFFF" d="M150.72 0.64Q144.35 0.64 139.25 -2.26Q134.15 -5.16 131.19 -10.66Q128.23 -16.17 128.23 -23.98Q128.23 -31.83 131.19 -37.36Q134.15 -42.88 139.25 -45.77Q144.35 -48.66 150.72 -48.66Q157.11 -48.66 162.19 -45.77Q167.27 -42.88 170.23 -37.36Q173.19 -31.83 173.19 -23.98Q173.19 -16.15 170.23 -10.64Q167.27 -5.14 162.19 -2.25Q157.11 0.64 150.72 0.64ZM150.72 -8.33Q154.42 -8.33 157.15 -10.13Q159.89 -11.93 161.4 -15.42Q162.91 -18.92 162.91 -23.98Q162.91 -29.07 161.4 -32.58Q159.89 -36.09 157.15 -37.89Q154.42 -39.69 150.72 -39.69Q147.05 -39.69 144.31 -37.89Q141.57 -36.09 140.04 -32.58Q138.52 -29.07 138.52 -23.98Q138.52 -18.92 140.04 -15.42Q141.57 -11.93 144.31 -10.13Q147.05 -8.33 150.72 -8.33ZM176.05 13.47V-36.03H185.86V-29.94H186.31Q186.98 -31.42 188.23 -32.94Q189.48 -34.45 191.52 -35.47Q193.55 -36.48 196.56 -36.48Q200.52 -36.48 203.83 -34.43Q207.13 -32.38 209.13 -28.27Q211.13 -24.15 211.13 -17.96Q211.13 -11.94 209.19 -7.81Q207.26 -3.67 203.95 -1.54Q200.63 0.58 196.51 0.58Q193.62 0.58 191.59 -0.39Q189.57 -1.37 188.28 -2.83Q187 -4.29 186.31 -5.77H186.02V13.47ZM193.36 -7.36Q195.83 -7.36 197.5 -8.71Q199.17 -10.06 200.04 -12.46Q200.9 -14.86 200.9 -17.98Q200.9 -21.11 200.04 -23.48Q199.18 -25.86 197.52 -27.2Q195.85 -28.54 193.36 -28.54Q190.95 -28.54 189.26 -27.24Q187.57 -25.95 186.68 -23.58Q185.8 -21.21 185.8 -17.98Q185.8 -14.79 186.69 -12.41Q187.58 -10.02 189.28 -8.69Q190.97 -7.36 193.36 -7.36ZM229.58 0.7Q224.05 0.7 220.03 -1.56Q216.01 -3.81 213.86 -7.97Q211.72 -12.14 211.72 -17.84Q211.72 -23.4 213.86 -27.6Q216 -31.79 219.91 -34.13Q223.82 -36.48 229.11 -36.48Q232.68 -36.48 235.77 -35.34Q238.87 -34.21 241.19 -31.93Q243.51 -29.65 244.8 -26.22Q246.1 -22.79 246.1 -18.19V-15.46H215.69V-21.62H241.26L236.61 -20.01Q236.61 -22.76 235.77 -24.79Q234.93 -26.81 233.28 -27.92Q231.63 -29.04 229.18 -29.04Q226.74 -29.04 225.03 -27.92Q223.33 -26.79 222.44 -24.85Q221.55 -22.91 221.55 -20.39V-16.04Q221.55 -13.12 222.57 -11.04Q223.6 -8.96 225.45 -7.85Q227.3 -6.74 229.74 -6.74Q231.4 -6.74 232.75 -7.22Q234.11 -7.69 235.09 -8.62Q236.07 -9.56 236.57 -10.91L245.79 -10.29Q245.08 -6.96 242.95 -4.49Q240.81 -2.02 237.42 -0.66Q234.04 0.7 229.58 0.7ZM258 -20.81V0H248.03V-36.03H257.84V-29.62H258.2Q259.42 -32.8 262.09 -34.64Q264.75 -36.48 268.79 -36.48Q272.55 -36.48 275.33 -34.84Q278.12 -33.21 279.66 -30.16Q281.2 -27.12 281.2 -22.92V0H271.24V-21.14Q271.24 -24.43 269.54 -26.31Q267.83 -28.19 264.83 -28.19Q262.83 -28.19 261.28 -27.31Q259.74 -26.43 258.87 -24.79Q258 -23.15 258 -20.81Z"/><path fill="#A3A7B0" d="M291.88 -48.02V0H286.08V-48.02ZM312.9 0H301.36V-5.16H312.51Q318.48 -5.16 322.39 -7.44Q326.31 -9.73 328.24 -13.99Q330.17 -18.24 330.17 -24.11Q330.17 -29.91 328.27 -34.11Q326.37 -38.32 322.59 -40.59Q318.8 -42.86 313.16 -42.86H301.11V-48.02H313.55Q320.54 -48.02 325.52 -45.15Q330.5 -42.28 333.14 -36.92Q335.78 -31.55 335.78 -24.11Q335.78 -16.6 333.11 -11.2Q330.43 -5.8 325.32 -2.9Q320.22 0 312.9 0ZM303.88 -48.02V0H298.08V-48.02ZM340.11 0V-48.02H369.11V-42.86H345.91V-26.81H367.57V-21.66H345.91V-5.16H369.44V0ZM376.15 0H370.03L387.69 -48.02H393.68L411.28 0H405.22L390.85 -40.41H390.46ZM378.41 -18.76H402.96V-13.6H378.41Z"/></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="435" height="128" viewBox="0 0 435 128" role="img" aria-label="OpenIDEA"><title>OpenIDEA</title><g transform="translate(24 24) scale(1.25)"><rect width="64" height="64" rx="15" fill="#FFFFFF"/><circle cx="26.5" cy="32" r="11" fill="none" stroke="#0E0E10" stroke-width="6"/><rect x="43.5" y="19" width="6" height="26" rx="1.5" fill="#FF4F1A"/></g><g transform="translate(0 88.01)"><path fill="#FFFFFF" d="M150.72 0.64Q144.35 0.64 139.25 -2.26Q134.15 -5.16 131.19 -10.66Q128.23 -16.17 128.23 -23.98Q128.23 -31.83 131.19 -37.36Q134.15 -42.88 139.25 -45.77Q144.35 -48.66 150.72 -48.66Q157.11 -48.66 162.19 -45.77Q167.27 -42.88 170.23 -37.36Q173.19 -31.83 173.19 -23.98Q173.19 -16.15 170.23 -10.64Q167.27 -5.14 162.19 -2.25Q157.11 0.64 150.72 0.64ZM150.72 -8.33Q154.42 -8.33 157.15 -10.13Q159.89 -11.93 161.4 -15.42Q162.91 -18.92 162.91 -23.98Q162.91 -29.07 161.4 -32.58Q159.89 -36.09 157.15 -37.89Q154.42 -39.69 150.72 -39.69Q147.05 -39.69 144.31 -37.89Q141.57 -36.09 140.04 -32.58Q138.52 -29.07 138.52 -23.98Q138.52 -18.92 140.04 -15.42Q141.57 -11.93 144.31 -10.13Q147.05 -8.33 150.72 -8.33ZM176.05 13.47V-36.03H185.86V-29.94H186.31Q186.98 -31.42 188.23 -32.94Q189.48 -34.45 191.52 -35.47Q193.55 -36.48 196.56 -36.48Q200.52 -36.48 203.83 -34.43Q207.13 -32.38 209.13 -28.27Q211.13 -24.15 211.13 -17.96Q211.13 -11.94 209.19 -7.81Q207.26 -3.67 203.95 -1.54Q200.63 0.58 196.51 0.58Q193.62 0.58 191.59 -0.39Q189.57 -1.37 188.28 -2.83Q187 -4.29 186.31 -5.77H186.02V13.47ZM193.36 -7.36Q195.83 -7.36 197.5 -8.71Q199.17 -10.06 200.04 -12.46Q200.9 -14.86 200.9 -17.98Q200.9 -21.11 200.04 -23.48Q199.18 -25.86 197.52 -27.2Q195.85 -28.54 193.36 -28.54Q190.95 -28.54 189.26 -27.24Q187.57 -25.95 186.68 -23.58Q185.8 -21.21 185.8 -17.98Q185.8 -14.79 186.69 -12.41Q187.58 -10.02 189.28 -8.69Q190.97 -7.36 193.36 -7.36ZM229.58 0.7Q224.05 0.7 220.03 -1.56Q216.01 -3.81 213.86 -7.97Q211.72 -12.14 211.72 -17.84Q211.72 -23.4 213.86 -27.6Q216 -31.79 219.91 -34.13Q223.82 -36.48 229.11 -36.48Q232.68 -36.48 235.77 -35.34Q238.87 -34.21 241.19 -31.93Q243.51 -29.65 244.8 -26.22Q246.1 -22.79 246.1 -18.19V-15.46H215.69V-21.62H241.26L236.61 -20.01Q236.61 -22.76 235.77 -24.79Q234.93 -26.81 233.28 -27.92Q231.63 -29.04 229.18 -29.04Q226.74 -29.04 225.03 -27.92Q223.33 -26.79 222.44 -24.85Q221.55 -22.91 221.55 -20.39V-16.04Q221.55 -13.12 222.57 -11.04Q223.6 -8.96 225.45 -7.85Q227.3 -6.74 229.74 -6.74Q231.4 -6.74 232.75 -7.22Q234.11 -7.69 235.09 -8.62Q236.07 -9.56 236.57 -10.91L245.79 -10.29Q245.08 -6.96 242.95 -4.49Q240.81 -2.02 237.42 -0.66Q234.04 0.7 229.58 0.7ZM258 -20.81V0H248.03V-36.03H257.84V-29.62H258.2Q259.42 -32.8 262.09 -34.64Q264.75 -36.48 268.79 -36.48Q272.55 -36.48 275.33 -34.84Q278.12 -33.21 279.66 -30.16Q281.2 -27.12 281.2 -22.92V0H271.24V-21.14Q271.24 -24.43 269.54 -26.31Q267.83 -28.19 264.83 -28.19Q262.83 -28.19 261.28 -27.31Q259.74 -26.43 258.87 -24.79Q258 -23.15 258 -20.81Z"/><path fill="#A3A7B0" d="M291.88 -48.02V0H286.08V-48.02ZM312.9 0H301.36V-5.16H312.51Q318.48 -5.16 322.39 -7.44Q326.31 -9.73 328.24 -13.99Q330.17 -18.24 330.17 -24.11Q330.17 -29.91 328.27 -34.11Q326.37 -38.32 322.59 -40.59Q318.8 -42.86 313.16 -42.86H301.11V-48.02H313.55Q320.54 -48.02 325.52 -45.15Q330.5 -42.28 333.14 -36.92Q335.78 -31.55 335.78 -24.11Q335.78 -16.6 333.11 -11.2Q330.43 -5.8 325.32 -2.9Q320.22 0 312.9 0ZM303.88 -48.02V0H298.08V-48.02ZM340.11 0V-48.02H369.11V-42.86H345.91V-26.81H367.57V-21.66H345.91V-5.16H369.44V0ZM376.15 0H370.03L387.69 -48.02H393.68L411.28 0H405.22L390.85 -40.41H390.46ZM378.41 -18.76H402.96V-13.6H378.41Z"/></g></svg>
|
||||
|
До Ширина: | Висота: | Розмір: 3.9 KiB Після Ширина: | Висота: | Розмір: 3.5 KiB |
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="435" height="128" viewBox="0 0 435 128" role="img" aria-label="OpenIDEA"><title>OpenIDEA</title><g transform="translate(14 14)"><rect x="10" y="10" width="80" height="80" rx="18" fill="#EAE7E0"/><g transform="translate(50 50) scale(1.25) translate(-50 -52)"><rect x="22" y="26" width="56" height="52" rx="12" fill="#D9582C"/><rect x="27" y="26" width="46" height="42" rx="9" fill="#1B1A1A"/><circle cx="44" cy="47.4" r="4.1" fill="none" stroke="#EAE7E0" stroke-width="2.7"/><rect x="54.3" y="42" width="2.8" height="10.5" fill="#EAE7E0"/><rect x="51.2" y="42" width="5.9" height="2.5" fill="#EAE7E0"/><rect x="51.2" y="50" width="9.4" height="2.5" fill="#EAE7E0"/><circle cx="55.7" cy="38.4" r="1.8" fill="#EAE7E0"/></g></g><g transform="translate(0 88.01)"><path fill="#0E0E10" d="M150.72 0.64Q144.35 0.64 139.25 -2.26Q134.15 -5.16 131.19 -10.66Q128.23 -16.17 128.23 -23.98Q128.23 -31.83 131.19 -37.36Q134.15 -42.88 139.25 -45.77Q144.35 -48.66 150.72 -48.66Q157.11 -48.66 162.19 -45.77Q167.27 -42.88 170.23 -37.36Q173.19 -31.83 173.19 -23.98Q173.19 -16.15 170.23 -10.64Q167.27 -5.14 162.19 -2.25Q157.11 0.64 150.72 0.64ZM150.72 -8.33Q154.42 -8.33 157.15 -10.13Q159.89 -11.93 161.4 -15.42Q162.91 -18.92 162.91 -23.98Q162.91 -29.07 161.4 -32.58Q159.89 -36.09 157.15 -37.89Q154.42 -39.69 150.72 -39.69Q147.05 -39.69 144.31 -37.89Q141.57 -36.09 140.04 -32.58Q138.52 -29.07 138.52 -23.98Q138.52 -18.92 140.04 -15.42Q141.57 -11.93 144.31 -10.13Q147.05 -8.33 150.72 -8.33ZM176.05 13.47V-36.03H185.86V-29.94H186.31Q186.98 -31.42 188.23 -32.94Q189.48 -34.45 191.52 -35.47Q193.55 -36.48 196.56 -36.48Q200.52 -36.48 203.83 -34.43Q207.13 -32.38 209.13 -28.27Q211.13 -24.15 211.13 -17.96Q211.13 -11.94 209.19 -7.81Q207.26 -3.67 203.95 -1.54Q200.63 0.58 196.51 0.58Q193.62 0.58 191.59 -0.39Q189.57 -1.37 188.28 -2.83Q187 -4.29 186.31 -5.77H186.02V13.47ZM193.36 -7.36Q195.83 -7.36 197.5 -8.71Q199.17 -10.06 200.04 -12.46Q200.9 -14.86 200.9 -17.98Q200.9 -21.11 200.04 -23.48Q199.18 -25.86 197.52 -27.2Q195.85 -28.54 193.36 -28.54Q190.95 -28.54 189.26 -27.24Q187.57 -25.95 186.68 -23.58Q185.8 -21.21 185.8 -17.98Q185.8 -14.79 186.69 -12.41Q187.58 -10.02 189.28 -8.69Q190.97 -7.36 193.36 -7.36ZM229.58 0.7Q224.05 0.7 220.03 -1.56Q216.01 -3.81 213.86 -7.97Q211.72 -12.14 211.72 -17.84Q211.72 -23.4 213.86 -27.6Q216 -31.79 219.91 -34.13Q223.82 -36.48 229.11 -36.48Q232.68 -36.48 235.77 -35.34Q238.87 -34.21 241.19 -31.93Q243.51 -29.65 244.8 -26.22Q246.1 -22.79 246.1 -18.19V-15.46H215.69V-21.62H241.26L236.61 -20.01Q236.61 -22.76 235.77 -24.79Q234.93 -26.81 233.28 -27.92Q231.63 -29.04 229.18 -29.04Q226.74 -29.04 225.03 -27.92Q223.33 -26.79 222.44 -24.85Q221.55 -22.91 221.55 -20.39V-16.04Q221.55 -13.12 222.57 -11.04Q223.6 -8.96 225.45 -7.85Q227.3 -6.74 229.74 -6.74Q231.4 -6.74 232.75 -7.22Q234.11 -7.69 235.09 -8.62Q236.07 -9.56 236.57 -10.91L245.79 -10.29Q245.08 -6.96 242.95 -4.49Q240.81 -2.02 237.42 -0.66Q234.04 0.7 229.58 0.7ZM258 -20.81V0H248.03V-36.03H257.84V-29.62H258.2Q259.42 -32.8 262.09 -34.64Q264.75 -36.48 268.79 -36.48Q272.55 -36.48 275.33 -34.84Q278.12 -33.21 279.66 -30.16Q281.2 -27.12 281.2 -22.92V0H271.24V-21.14Q271.24 -24.43 269.54 -26.31Q267.83 -28.19 264.83 -28.19Q262.83 -28.19 261.28 -27.31Q259.74 -26.43 258.87 -24.79Q258 -23.15 258 -20.81Z"/><path fill="#5F6470" d="M291.88 -48.02V0H286.08V-48.02ZM312.9 0H301.36V-5.16H312.51Q318.48 -5.16 322.39 -7.44Q326.31 -9.73 328.24 -13.99Q330.17 -18.24 330.17 -24.11Q330.17 -29.91 328.27 -34.11Q326.37 -38.32 322.59 -40.59Q318.8 -42.86 313.16 -42.86H301.11V-48.02H313.55Q320.54 -48.02 325.52 -45.15Q330.5 -42.28 333.14 -36.92Q335.78 -31.55 335.78 -24.11Q335.78 -16.6 333.11 -11.2Q330.43 -5.8 325.32 -2.9Q320.22 0 312.9 0ZM303.88 -48.02V0H298.08V-48.02ZM340.11 0V-48.02H369.11V-42.86H345.91V-26.81H367.57V-21.66H345.91V-5.16H369.44V0ZM376.15 0H370.03L387.69 -48.02H393.68L411.28 0H405.22L390.85 -40.41H390.46ZM378.41 -18.76H402.96V-13.6H378.41Z"/></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="435" height="128" viewBox="0 0 435 128" role="img" aria-label="OpenIDEA"><title>OpenIDEA</title><g transform="translate(24 24) scale(1.25)"><rect width="64" height="64" rx="15" fill="#0E0E10"/><circle cx="26.5" cy="32" r="11" fill="none" stroke="#FFFFFF" stroke-width="6"/><rect x="43.5" y="19" width="6" height="26" rx="1.5" fill="#FF4F1A"/></g><g transform="translate(0 88.01)"><path fill="#0E0E10" d="M150.72 0.64Q144.35 0.64 139.25 -2.26Q134.15 -5.16 131.19 -10.66Q128.23 -16.17 128.23 -23.98Q128.23 -31.83 131.19 -37.36Q134.15 -42.88 139.25 -45.77Q144.35 -48.66 150.72 -48.66Q157.11 -48.66 162.19 -45.77Q167.27 -42.88 170.23 -37.36Q173.19 -31.83 173.19 -23.98Q173.19 -16.15 170.23 -10.64Q167.27 -5.14 162.19 -2.25Q157.11 0.64 150.72 0.64ZM150.72 -8.33Q154.42 -8.33 157.15 -10.13Q159.89 -11.93 161.4 -15.42Q162.91 -18.92 162.91 -23.98Q162.91 -29.07 161.4 -32.58Q159.89 -36.09 157.15 -37.89Q154.42 -39.69 150.72 -39.69Q147.05 -39.69 144.31 -37.89Q141.57 -36.09 140.04 -32.58Q138.52 -29.07 138.52 -23.98Q138.52 -18.92 140.04 -15.42Q141.57 -11.93 144.31 -10.13Q147.05 -8.33 150.72 -8.33ZM176.05 13.47V-36.03H185.86V-29.94H186.31Q186.98 -31.42 188.23 -32.94Q189.48 -34.45 191.52 -35.47Q193.55 -36.48 196.56 -36.48Q200.52 -36.48 203.83 -34.43Q207.13 -32.38 209.13 -28.27Q211.13 -24.15 211.13 -17.96Q211.13 -11.94 209.19 -7.81Q207.26 -3.67 203.95 -1.54Q200.63 0.58 196.51 0.58Q193.62 0.58 191.59 -0.39Q189.57 -1.37 188.28 -2.83Q187 -4.29 186.31 -5.77H186.02V13.47ZM193.36 -7.36Q195.83 -7.36 197.5 -8.71Q199.17 -10.06 200.04 -12.46Q200.9 -14.86 200.9 -17.98Q200.9 -21.11 200.04 -23.48Q199.18 -25.86 197.52 -27.2Q195.85 -28.54 193.36 -28.54Q190.95 -28.54 189.26 -27.24Q187.57 -25.95 186.68 -23.58Q185.8 -21.21 185.8 -17.98Q185.8 -14.79 186.69 -12.41Q187.58 -10.02 189.28 -8.69Q190.97 -7.36 193.36 -7.36ZM229.58 0.7Q224.05 0.7 220.03 -1.56Q216.01 -3.81 213.86 -7.97Q211.72 -12.14 211.72 -17.84Q211.72 -23.4 213.86 -27.6Q216 -31.79 219.91 -34.13Q223.82 -36.48 229.11 -36.48Q232.68 -36.48 235.77 -35.34Q238.87 -34.21 241.19 -31.93Q243.51 -29.65 244.8 -26.22Q246.1 -22.79 246.1 -18.19V-15.46H215.69V-21.62H241.26L236.61 -20.01Q236.61 -22.76 235.77 -24.79Q234.93 -26.81 233.28 -27.92Q231.63 -29.04 229.18 -29.04Q226.74 -29.04 225.03 -27.92Q223.33 -26.79 222.44 -24.85Q221.55 -22.91 221.55 -20.39V-16.04Q221.55 -13.12 222.57 -11.04Q223.6 -8.96 225.45 -7.85Q227.3 -6.74 229.74 -6.74Q231.4 -6.74 232.75 -7.22Q234.11 -7.69 235.09 -8.62Q236.07 -9.56 236.57 -10.91L245.79 -10.29Q245.08 -6.96 242.95 -4.49Q240.81 -2.02 237.42 -0.66Q234.04 0.7 229.58 0.7ZM258 -20.81V0H248.03V-36.03H257.84V-29.62H258.2Q259.42 -32.8 262.09 -34.64Q264.75 -36.48 268.79 -36.48Q272.55 -36.48 275.33 -34.84Q278.12 -33.21 279.66 -30.16Q281.2 -27.12 281.2 -22.92V0H271.24V-21.14Q271.24 -24.43 269.54 -26.31Q267.83 -28.19 264.83 -28.19Q262.83 -28.19 261.28 -27.31Q259.74 -26.43 258.87 -24.79Q258 -23.15 258 -20.81Z"/><path fill="#5F6470" d="M291.88 -48.02V0H286.08V-48.02ZM312.9 0H301.36V-5.16H312.51Q318.48 -5.16 322.39 -7.44Q326.31 -9.73 328.24 -13.99Q330.17 -18.24 330.17 -24.11Q330.17 -29.91 328.27 -34.11Q326.37 -38.32 322.59 -40.59Q318.8 -42.86 313.16 -42.86H301.11V-48.02H313.55Q320.54 -48.02 325.52 -45.15Q330.5 -42.28 333.14 -36.92Q335.78 -31.55 335.78 -24.11Q335.78 -16.6 333.11 -11.2Q330.43 -5.8 325.32 -2.9Q320.22 0 312.9 0ZM303.88 -48.02V0H298.08V-48.02ZM340.11 0V-48.02H369.11V-42.86H345.91V-26.81H367.57V-21.66H345.91V-5.16H369.44V0ZM376.15 0H370.03L387.69 -48.02H393.68L411.28 0H405.22L390.85 -40.41H390.46ZM378.41 -18.76H402.96V-13.6H378.41Z"/></g></svg>
|
||||
|
До Ширина: | Висота: | Розмір: 3.9 KiB Після Ширина: | Висота: | Розмір: 3.5 KiB |
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 100 100" role="img" aria-label="OpenIDEA"><rect x="10" y="10" width="80" height="80" rx="18" fill="#EAE7E0"/><g transform="translate(50 50) scale(1.25) translate(-50 -52)"><rect x="22" y="26" width="56" height="52" rx="12" fill="#D9582C"/><rect x="27" y="26" width="46" height="42" rx="9" fill="#1B1A1A"/><circle cx="44" cy="47.4" r="4.1" fill="none" stroke="#EAE7E0" stroke-width="2.7"/><rect x="54.3" y="42" width="2.8" height="10.5" fill="#EAE7E0"/><rect x="51.2" y="42" width="5.9" height="2.5" fill="#EAE7E0"/><rect x="51.2" y="50" width="9.4" height="2.5" fill="#EAE7E0"/><circle cx="55.7" cy="38.4" r="1.8" fill="#EAE7E0"/></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024" role="img" aria-label="OpenIDEA"><defs><filter id="oi-shadow" x="-20%" y="-20%" width="140%" height="150%"><feDropShadow dx="0" dy="14" stdDeviation="16" flood-color="#000000" flood-opacity="0.28"/></filter></defs><rect x="100" y="100" width="824" height="824" rx="185" fill="#0E0E10" filter="url(#oi-shadow)"/><g transform="translate(100 100) scale(12.875)"><rect width="64" height="64" rx="15" fill="none"/><circle cx="26.5" cy="32" r="11" fill="none" stroke="#FFFFFF" stroke-width="6"/><rect x="43.5" y="19" width="6" height="26" rx="1.5" fill="#FF4F1A"/></g><rect x="102" y="102" width="820" height="820" rx="183" fill="none" stroke="#FFFFFF" stroke-opacity="0.10" stroke-width="4"/></svg>
|
||||
|
До Ширина: | Висота: | Розмір: 721 B Після Ширина: | Висота: | Розмір: 785 B |
@@ -309,13 +309,6 @@ pub fn lsp_servers(window: Window, state: State<'_, AppState>) -> IdeResult<Vec<
|
||||
ide_host::ops::lsp::lsp_servers(&state.host, window.label())
|
||||
}
|
||||
|
||||
/// Re-emits the language servers' current diagnostics (the UI loaded after they arrived).
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn lsp_resend_diagnostics(window: Window, state: State<'_, AppState>) -> IdeResult<()> {
|
||||
ide_host::ops::lsp::lsp_resend_diagnostics(&state.host, window.label())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn lsp_restart(window: Window, state: State<'_, AppState>, server: ServerId) -> IdeResult<()> {
|
||||
|
||||
@@ -174,7 +174,6 @@ pub fn builder() -> tauri_specta::Builder<tauri::Wry> {
|
||||
lsp::lsp_call_hierarchy,
|
||||
lsp::lsp_type_hierarchy,
|
||||
lsp::lsp_servers,
|
||||
lsp::lsp_resend_diagnostics,
|
||||
lsp::lsp_restart,
|
||||
lsp::apply_workspace_edit,
|
||||
lsp::lsp_execute_command,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "OpenIDEA",
|
||||
"version": "0.1.19",
|
||||
"version": "0.1.18",
|
||||
"identifier": "ai.l0ng.openidea",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm dev",
|
||||
|
||||
@@ -336,8 +336,6 @@ export const commands = {
|
||||
lspCallHierarchy: (doc: DocId, pos: Pos, direction: HierarchyDirection) => typedError<HierarchyItem[], IdeError>(__TAURI_INVOKE("lsp_call_hierarchy", { doc, pos, direction })),
|
||||
lspTypeHierarchy: (doc: DocId, pos: Pos, direction: HierarchyDirection) => typedError<HierarchyItem[], IdeError>(__TAURI_INVOKE("lsp_type_hierarchy", { doc, pos, direction })),
|
||||
lspServers: () => typedError<ServerInfo[], IdeError>(__TAURI_INVOKE("lsp_servers")),
|
||||
/** Re-emits the language servers' current diagnostics (the UI loaded after they arrived). */
|
||||
lspResendDiagnostics: () => typedError<null, IdeError>(__TAURI_INVOKE("lsp_resend_diagnostics")),
|
||||
lspRestart: (server: ServerId) => typedError<null, IdeError>(__TAURI_INVOKE("lsp_restart", { server })),
|
||||
/** Applies a (previewed) workspace edit, e.g. after rename confirmation. */
|
||||
applyWorkspaceEdit: (edit: WorkspaceEdit) => typedError<null, IdeError>(__TAURI_INVOKE("apply_workspace_edit", { edit })),
|
||||
@@ -986,11 +984,7 @@ export type AgentConfigVia =
|
||||
/** One item of a task's conversation. */
|
||||
export type AgentEntry = { type: "user"; text: string;
|
||||
/** Names of the files and images sent with it. */
|
||||
attachments: string[];
|
||||
/** When it was sent (ms since the epoch); `None` in tasks saved before this was kept. */
|
||||
sentMs?: number | null;
|
||||
/** When the turn it started ended; `None` while it runs or when it was cut off. */
|
||||
doneMs?: number | null } | { type: "agent"; text: string } | { type: "thought"; text: string } | { type: "tool"; id: string; title: string;
|
||||
attachments: string[] } | { type: "agent"; text: string } | { type: "thought"; text: string } | { type: "tool"; id: string; title: string;
|
||||
/** ACP tool kind: `read`, `edit`, `execute`, `search`, `fetch`, `think`… */
|
||||
kind: string; status: AgentToolStatus; locations: IpcPath[];
|
||||
/** Text the tool reported (command output…), truncated. */
|
||||
@@ -1073,7 +1067,7 @@ export type AgentTask = {
|
||||
branch: string | null,
|
||||
/** Branch (or revision) the worktree was created from. */
|
||||
base: string | null,
|
||||
/** Commit the task's changes are compared against (worktree tasks; local ones use `HEAD`). */
|
||||
/** Commit the task's changes are compared against. */
|
||||
baseCommit: string | null,
|
||||
/** Why the task failed, when it did. */
|
||||
error: string | null,
|
||||
@@ -3439,64 +3433,6 @@ export type LanguageInfo_Serialize = {
|
||||
firstLine?: string | null,
|
||||
};
|
||||
|
||||
export type LanguageServerSettings = LanguageServerSettings_Serialize | LanguageServerSettings_Deserialize;
|
||||
|
||||
export type LanguageServerSettings_Deserialize = {
|
||||
/** `false` keeps the server from starting for any language. */
|
||||
enabled?: boolean,
|
||||
/**
|
||||
* Executable to launch instead of the definition's; required for a server
|
||||
* defined here (one with `languages`).
|
||||
*/
|
||||
command?: string,
|
||||
/** Replaces the definition's arguments. */
|
||||
args?: string[] | null,
|
||||
/** Added to the server's environment. */
|
||||
env?: { [key in string]: string },
|
||||
/** Merged over the definition's `initializationOptions` (sent once at startup). */
|
||||
initializationOptions?: unknown | null,
|
||||
/**
|
||||
* Answers the server's `workspace/configuration` requests; changes are pushed
|
||||
* with `workspace/didChangeConfiguration` without a restart.
|
||||
*/
|
||||
settings?: unknown | null,
|
||||
/**
|
||||
* Language ids a server defined here serves (`python`); empty for the servers
|
||||
* of the language definitions.
|
||||
*/
|
||||
languages?: string[],
|
||||
/** Files marking a workspace root for a server defined here (`pyproject.toml`). */
|
||||
rootMarkers?: string[],
|
||||
};
|
||||
|
||||
export type LanguageServerSettings_Serialize = {
|
||||
/** `false` keeps the server from starting for any language. */
|
||||
enabled: boolean,
|
||||
/**
|
||||
* Executable to launch instead of the definition's; required for a server
|
||||
* defined here (one with `languages`).
|
||||
*/
|
||||
command: string,
|
||||
/** Replaces the definition's arguments. */
|
||||
args?: string[] | null,
|
||||
/** Added to the server's environment. */
|
||||
env: { [key in string]: string },
|
||||
/** Merged over the definition's `initializationOptions` (sent once at startup). */
|
||||
initializationOptions?: unknown | null,
|
||||
/**
|
||||
* Answers the server's `workspace/configuration` requests; changes are pushed
|
||||
* with `workspace/didChangeConfiguration` without a restart.
|
||||
*/
|
||||
settings?: unknown | null,
|
||||
/**
|
||||
* Language ids a server defined here serves (`python`); empty for the servers
|
||||
* of the language definitions.
|
||||
*/
|
||||
languages: string[],
|
||||
/** Files marking a workspace root for a server defined here (`pyproject.toml`). */
|
||||
rootMarkers: string[],
|
||||
};
|
||||
|
||||
export type LanguagesSettings = {
|
||||
python?: PythonSettings,
|
||||
node?: NodeSettings,
|
||||
@@ -4923,11 +4859,6 @@ export type Settings_Deserialize = {
|
||||
* command the language definition launches (`elixir-ls`, `codelldb`).
|
||||
*/
|
||||
tools?: { [key in string]: ToolSettings },
|
||||
/**
|
||||
* Per language server, by name (`rust-analyzer`): launch and protocol
|
||||
* options on top of the language definition, or a server defined here.
|
||||
*/
|
||||
languageServers?: { [key in string]: LanguageServerSettings_Deserialize },
|
||||
/** Editor › Inspections profiles. */
|
||||
inspections?: InspectionSettings,
|
||||
/** Editor › Natural Languages › Spelling. */
|
||||
@@ -4976,11 +4907,6 @@ export type Settings_Serialize = {
|
||||
* command the language definition launches (`elixir-ls`, `codelldb`).
|
||||
*/
|
||||
tools: { [key in string]: ToolSettings },
|
||||
/**
|
||||
* Per language server, by name (`rust-analyzer`): launch and protocol
|
||||
* options on top of the language definition, or a server defined here.
|
||||
*/
|
||||
languageServers: { [key in string]: LanguageServerSettings_Serialize },
|
||||
/** Editor › Inspections profiles. */
|
||||
inspections: InspectionSettings,
|
||||
/** Editor › Natural Languages › Spelling. */
|
||||
@@ -5480,10 +5406,6 @@ export type ToolInfo = {
|
||||
homepage: string | null,
|
||||
/** Why the executable chosen in settings cannot be used (status is then `Missing`). */
|
||||
customError: string | null,
|
||||
/** A language server's arguments from its language definition. */
|
||||
defaultArgs: string[],
|
||||
/** A language server's `initializationOptions` from its language definition, as JSON text. */
|
||||
defaultInitializationOptions: string | null,
|
||||
};
|
||||
|
||||
export type ToolKind = "languageServer" | "debugger" |
|
||||
|
||||
@@ -192,12 +192,6 @@ export function whenSynced(view: EditorView): Promise<void> {
|
||||
return view.state.facet(documentSynced)?.() ?? Promise.resolve();
|
||||
}
|
||||
|
||||
/** Every open editor's edits reached the backend (language servers answer from its copy). */
|
||||
export function whenAllSynced(): Promise<void> {
|
||||
const editors = useEditorRegistry.getState().editors;
|
||||
return editors.size ? Promise.all([...editors].map((e) => whenSynced(e.view))).then(() => {}) : Promise.resolve();
|
||||
}
|
||||
|
||||
/** True for doc changes that did not originate from typing in *this* view. */
|
||||
export function isExternalChange(tr: Transaction): boolean {
|
||||
return !!tr.annotation(remoteChange) || !!tr.annotation(mirroredChange);
|
||||
|
||||
@@ -52,7 +52,6 @@ import {
|
||||
removePane,
|
||||
reopenClosed,
|
||||
setActivePane,
|
||||
splitAtEdge,
|
||||
sortTabs,
|
||||
splitPane,
|
||||
tabOptions,
|
||||
@@ -785,7 +784,7 @@ export class EditorController implements SlotHost {
|
||||
this.navSuppress++;
|
||||
try {
|
||||
let s = useTabs.getState();
|
||||
let paneId = o.pane && s.panes[o.pane] ? o.pane : s.activePane;
|
||||
let paneId = s.activePane;
|
||||
if (o.side) {
|
||||
const right = neighbourPane(s, paneId);
|
||||
if (right) paneId = right;
|
||||
@@ -800,7 +799,7 @@ export class EditorController implements SlotHost {
|
||||
}
|
||||
const found = findTab(s, input.key, paneId);
|
||||
let tabId: string;
|
||||
if (found && (!(o.side || o.pane) || found.paneId === paneId)) {
|
||||
if (found && (!o.side || found.paneId === paneId)) {
|
||||
paneId = found.paneId;
|
||||
s = activateTab(setActivePane(s, paneId), paneId, found.tab.id);
|
||||
if (!o.preview) s = promoteTab(s, paneId, found.tab.id);
|
||||
@@ -936,20 +935,6 @@ export class EditorController implements SlotHost {
|
||||
if (slot?.view) slot.focus();
|
||||
else if (slot) slot.wantsFocus = true;
|
||||
}
|
||||
/** Files dropped on an editor: opened in that pane, or in a new split at `edge`. */
|
||||
async openFilesIn(paths: readonly string[], paneId: string, edge: SplitEdge | "center") {
|
||||
const s = useTabs.getState();
|
||||
if (!s.panes[paneId] || !paths.length) return;
|
||||
let target = paneId;
|
||||
if (edge !== "center") {
|
||||
const r = splitAtEdge(s, paneId, edge);
|
||||
useTabs.setState(r.state, true);
|
||||
target = r.paneId;
|
||||
}
|
||||
for (const [i, path] of paths.entries()) await this.openFile(path, { pane: target, focus: i === paths.length - 1 });
|
||||
const pane = useTabs.getState().panes[target];
|
||||
if (pane && !pane.tabs.length) this.apply((st) => removePane(st, target));
|
||||
}
|
||||
/** IDEA "Move to Opposite Group"; without a split, "Split and Move Right". */
|
||||
moveToOpposite(paneId: string, tabId: string) {
|
||||
const target = neighbourPane(useTabs.getState(), paneId);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { initialTabsState, moveTabToNewSplit, openTab, paneIds, splitAtEdge, splitPane, togglePin, type TabsState } from "./tabs";
|
||||
import { initialTabsState, moveTabToNewSplit, openTab, paneIds, splitPane, togglePin, type TabsState } from "./tabs";
|
||||
import { loadSession, parseSession, restoreTabsState, serializeSession, slashPath } from "./session";
|
||||
|
||||
const file = (path: string) => ({ kind: "file", key: `file:${path}`, path });
|
||||
@@ -145,15 +145,3 @@ describe("sessions saved with Windows backslash paths", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("splitAtEdge", () => {
|
||||
it("adds an empty active pane on the given side", () => {
|
||||
const s = open(initialTabsState(), "/a");
|
||||
const pane = s.activePane;
|
||||
const r = splitAtEdge(s, pane, "right");
|
||||
expect(paneIds(r.state)).toEqual([pane, r.paneId]);
|
||||
expect(r.state.panes[r.paneId]!.tabs).toEqual([]);
|
||||
expect(r.state.activePane).toBe(r.paneId);
|
||||
expect(paths(r.state, pane)).toEqual(["/a"]);
|
||||
});
|
||||
});
|
||||
@@ -425,29 +425,21 @@ export function moveTabToNewSplit(
|
||||
const tab = src?.tabs.find((t) => t.id === tabId);
|
||||
if (!src || !tab || !s.panes[targetPane]) return null;
|
||||
if (fromPane === targetPane && src.tabs.length === 1) return null;
|
||||
const next = { ...removeTabs(s, fromPane, new Set([tabId])), closed: s.closed };
|
||||
let next = { ...removeTabs(s, fromPane, new Set([tabId])), closed: s.closed };
|
||||
// The source pane may have collapsed away; split the target if it survived, else the active pane.
|
||||
const anchor = next.panes[targetPane] ? targetPane : next.activePane;
|
||||
const moved: Tab = { ...tab, preview: false };
|
||||
return splitAtEdge(next, anchor, edge, { tabs: [moved], active: moved.id, mru: [moved.id] });
|
||||
}
|
||||
|
||||
/** A new pane (empty unless `content` is given) at `edge` of `anchor`, made active. */
|
||||
export function splitAtEdge(
|
||||
s: TabsState,
|
||||
anchor: string,
|
||||
edge: SplitEdge,
|
||||
content: Omit<Pane, "id"> = { tabs: [], active: null, mru: [] },
|
||||
): { state: TabsState; paneId: string } {
|
||||
const id = nextId("pane");
|
||||
const moved: Tab = { ...tab, preview: false };
|
||||
const pane: Pane = { id, tabs: [moved], active: moved.id, mru: [moved.id] };
|
||||
const dir = edge === "left" || edge === "right" ? "row" : "column";
|
||||
const before = edge === "left" || edge === "top";
|
||||
const layout = mapLayout(s.layout, (n) => {
|
||||
const layout = mapLayout(next.layout, (n) => {
|
||||
if (n.kind === "pane" && n.paneId === anchor) {
|
||||
const added: LayoutNode = { kind: "pane", paneId: id };
|
||||
return { kind: "split", id: nextId("split"), dir, children: before ? [added, n] : [n, added] };
|
||||
}
|
||||
return n;
|
||||
})!;
|
||||
return { state: { ...s, layout, panes: { ...s.panes, [id]: { id, ...content } }, activePane: id }, paneId: id };
|
||||
next = { ...next, layout, panes: { ...next.panes, [id]: pane }, activePane: id };
|
||||
return { state: next, paneId: id };
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* decorations, middle-click close, Alt+click close others, double-click to
|
||||
* keep a preview / maximize the editor, context menu) and the active editor.
|
||||
*/
|
||||
import { Fragment, useEffect, useMemo, useRef, useState, type FocusEvent, type ReactNode } from "react";
|
||||
import { Fragment, useMemo, useRef, useState, type DragEvent, type FocusEvent, type ReactNode } from "react";
|
||||
import clsx from "clsx";
|
||||
import { useShallow } from "zustand/react/shallow";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
@@ -32,8 +32,6 @@ import {
|
||||
SplitPanel,
|
||||
Tabs,
|
||||
showContextMenu,
|
||||
registerDropTarget,
|
||||
FILES_DRAG,
|
||||
type TabItem,
|
||||
type TabsDnd,
|
||||
} from "@/ui";
|
||||
@@ -199,33 +197,6 @@ function PaneView({ paneId }: { paneId: string }) {
|
||||
return { all: strip(0), rest: strip(pinnedCount) };
|
||||
}, [ctrl, paneId, pinnedCount]);
|
||||
|
||||
// Dropping a tab or project files on the editor: an edge splits, the middle opens / moves here.
|
||||
const contentRef = useRef<HTMLDivElement>(null);
|
||||
const hasPane = !!pane;
|
||||
useEffect(() => {
|
||||
const el = contentRef.current;
|
||||
if (!el) return;
|
||||
const zoneAt = (x: number, y: number) => dropZoneAt(x, y, el.getBoundingClientRect());
|
||||
return registerDropTarget(el, {
|
||||
accepts: (type) => type === EDITOR_TAB_MIME || type === FILES_DRAG,
|
||||
over: (_, x, y) => setDropZone(zoneAt(x, y)),
|
||||
leave: () => setDropZone(null),
|
||||
drop: (data, x, y) => {
|
||||
const zone = zoneAt(x, y);
|
||||
setDropZone(null);
|
||||
if (data.type === FILES_DRAG) {
|
||||
void ctrl.openFilesIn(data.payload.split("\n").filter(Boolean), paneId, zone);
|
||||
return;
|
||||
}
|
||||
const p = parseTabPayload(data.payload);
|
||||
if (!p) return;
|
||||
const target = useTabs.getState().panes[paneId];
|
||||
if (zone === "center") ctrl.moveTab(p.paneId, p.tabId, paneId, target?.tabs.length ?? 0);
|
||||
else ctrl.moveTabToSplit(p.paneId, p.tabId, paneId, zone);
|
||||
},
|
||||
});
|
||||
}, [ctrl, paneId, hasPane]);
|
||||
|
||||
if (!pane) return null;
|
||||
const active = pane.tabs.find((t) => t.id === pane.active) ?? null;
|
||||
|
||||
@@ -237,6 +208,33 @@ function PaneView({ paneId }: { paneId: string }) {
|
||||
if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setContext("editorFocus", false);
|
||||
};
|
||||
|
||||
// Dropping a tab on the editor: an edge splits, the middle moves the tab here.
|
||||
const isTabDrag = (e: DragEvent) => [...e.dataTransfer.types].includes(EDITOR_TAB_MIME);
|
||||
const contentDnd = {
|
||||
onDragOverCapture: (e: DragEvent<HTMLDivElement>) => {
|
||||
if (!isTabDrag(e)) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.dataTransfer.dropEffect = "move";
|
||||
const zone = dropZoneAt(e.clientX, e.clientY, e.currentTarget.getBoundingClientRect());
|
||||
if (zone !== dropZone) setDropZone(zone);
|
||||
},
|
||||
onDragLeave: (e: DragEvent<HTMLDivElement>) => {
|
||||
if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setDropZone(null);
|
||||
},
|
||||
onDropCapture: (e: DragEvent<HTMLDivElement>) => {
|
||||
if (!isTabDrag(e)) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const zone = dropZoneAt(e.clientX, e.clientY, e.currentTarget.getBoundingClientRect());
|
||||
setDropZone(null);
|
||||
const p = parseTabPayload(e.dataTransfer.getData(EDITOR_TAB_MIME));
|
||||
if (!p) return;
|
||||
if (zone === "center") ctrl.moveTab(p.paneId, p.tabId, paneId, pane.tabs.length);
|
||||
else ctrl.moveTabToSplit(p.paneId, p.tabId, paneId, zone);
|
||||
},
|
||||
};
|
||||
|
||||
const hidden = tabPrefs.placement === "none" || distractionFree;
|
||||
const strip = (stripItems: TabItem[], stripDnd: TabsDnd, trailing: ReactNode) => (
|
||||
<Tabs
|
||||
@@ -301,7 +299,7 @@ function PaneView({ paneId }: { paneId: string }) {
|
||||
role="tabpanel"
|
||||
id={active ? `editor-${paneId}-panel-${active.id}` : undefined}
|
||||
aria-labelledby={active ? `editor-${paneId}-tab-${active.id}` : undefined}
|
||||
ref={contentRef}
|
||||
{...contentDnd}
|
||||
>
|
||||
{active ? <PaneContent paneId={paneId} tab={active} /> : <EmptyEditor />}
|
||||
{dropZone && <div className={clsx(styles.dropZone, styles[`drop-${dropZone}`])} aria-hidden="true" />}
|
||||
|
||||
@@ -178,6 +178,10 @@
|
||||
}
|
||||
.bulb {
|
||||
flex: none;
|
||||
color: var(--warning);
|
||||
}
|
||||
.bulbFix {
|
||||
color: var(--danger);
|
||||
}
|
||||
.empty {
|
||||
font-size: var(--fs-ui);
|
||||
|
||||
@@ -44,7 +44,7 @@ import { useUsagesStatus } from "./navigation";
|
||||
import styles from "./Popups.module.css";
|
||||
|
||||
export function BulbIcon({ fix }: { fix?: boolean }) {
|
||||
return <Icon name={fix ? "bulb-fix" : "bulb"} size={16} className={styles.bulb} />;
|
||||
return <Icon name="bulb" size={16} className={clsx(styles.bulb, fix && styles.bulbFix)} />;
|
||||
}
|
||||
|
||||
function ItemIcon({ item }: { item: ListPopupItem }) {
|
||||
|
||||
@@ -10,8 +10,7 @@ import { quickDefinition, quickDocumentation } from "./hover";
|
||||
import { expressionTypeInfo } from "./typeInfo";
|
||||
import { gotoTargets, highlightUsages } from "./navigation";
|
||||
import { gotoDiagnostic } from "./diagnostics";
|
||||
import { applyKindSilently, applyQuickFix, runKindAction, showIntentions } from "./intentions";
|
||||
import { implementPythonAbstractMethods } from "./pythonMembers";
|
||||
import { applyKindSilently, runKindAction, showIntentions } from "./intentions";
|
||||
import { workflowSettings, type ActionsOnSaveValid } from "@/platform/workflowSettings";
|
||||
import { startRename } from "./rename";
|
||||
import { formatDocument, reformatDialog } from "./format";
|
||||
@@ -155,9 +154,6 @@ export function registerLspActions(): () => void {
|
||||
editorAction("code.showIntentions", "Show Context Actions", "Code", showIntentions, {
|
||||
keywords: ["intention", "quick fix", "lightbulb"],
|
||||
}),
|
||||
editorAction("code.applyQuickFix", "Apply Quick Fix", "Code", applyQuickFix, {
|
||||
keywords: ["fix error", "problem", "lightbulb"],
|
||||
}),
|
||||
editorAction("code.reformat", "Reformat Code", "Code", reformat, {
|
||||
keywords: ["format", "prettier"],
|
||||
}),
|
||||
@@ -232,12 +228,7 @@ export function registerLspActions(): () => void {
|
||||
// Implement / Override Methods: the server's code actions for them (jdtls "Override/Implement
|
||||
// Methods…", rust-analyzer "Implement missing members", TS "Implement interface"…).
|
||||
editorAction("code.implementMethods", "Implement Methods…", "Code", (v) =>
|
||||
runKindAction(v, "", {
|
||||
title: IMPLEMENT_TITLE,
|
||||
none: "Nothing to implement",
|
||||
label: "Implement Members",
|
||||
fallback: () => implementPythonAbstractMethods(v),
|
||||
}),
|
||||
runKindAction(v, "", { title: IMPLEMENT_TITLE, none: "Nothing to implement", label: "Implement Members" }),
|
||||
),
|
||||
editorAction("code.overrideMethods", "Override Methods…", "Code", (v) =>
|
||||
runKindAction(v, "", { title: OVERRIDE_TITLE, none: "Nothing to override", label: "Override Members" }),
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import type { IdeEvent } from "@/bindings";
|
||||
|
||||
const listeners = vi.hoisted(() => new Set<(e: IdeEvent) => void>());
|
||||
vi.mock("@/platform/ipc", async (orig) => {
|
||||
const real = await orig<typeof import("@/platform/ipc")>();
|
||||
return {
|
||||
...real,
|
||||
isTauri: () => true,
|
||||
onIdeEvent: (_type: string, fn: (e: IdeEvent) => void) => {
|
||||
listeners.add(fn);
|
||||
return () => listeners.delete(fn);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const { onServerSettled } = await import("./availability");
|
||||
|
||||
const status = (s: string) => {
|
||||
for (const fn of listeners) fn({ type: "languageServer", server: 1, status: s } as unknown as IdeEvent);
|
||||
};
|
||||
|
||||
describe("onServerSettled", () => {
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
listeners.clear();
|
||||
});
|
||||
|
||||
it("re-runs a callback that keeps the server busy only once", () => {
|
||||
vi.useFakeTimers();
|
||||
const fn = vi.fn();
|
||||
onServerSettled(fn);
|
||||
status("starting");
|
||||
status("ready");
|
||||
expect(fn).toHaveBeenCalledTimes(1);
|
||||
for (let i = 0; i < 2; i++) {
|
||||
status("busy");
|
||||
vi.advanceTimersByTime(2000);
|
||||
status("ready");
|
||||
}
|
||||
expect(fn).toHaveBeenCalledTimes(2);
|
||||
// Indexing that starts later is a new settle.
|
||||
vi.advanceTimersByTime(10_000);
|
||||
status("busy");
|
||||
vi.advanceTimersByTime(5000);
|
||||
status("ready");
|
||||
expect(fn).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
|
||||
it("ignores short busy spells", () => {
|
||||
vi.useFakeTimers();
|
||||
const fn = vi.fn();
|
||||
onServerSettled(fn);
|
||||
status("busy");
|
||||
vi.advanceTimersByTime(100);
|
||||
status("ready");
|
||||
expect(fn).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -46,43 +46,6 @@ export function onLspRefresh(kind: LspRefreshKind, fn: () => void): () => void {
|
||||
};
|
||||
}
|
||||
|
||||
/** A busy spell at least this long is indexing / a build, not the server answering a request. */
|
||||
const LONG_BUSY_MS = 1500;
|
||||
|
||||
/** A busy spell starting this soon after `fn` ran may be `fn`'s own requests. */
|
||||
const ECHO_MS = 2000;
|
||||
|
||||
/**
|
||||
* Calls `fn` when a server becomes ready after starting or after a long busy
|
||||
* spell (indexing), when earlier answers may have been incomplete. Short busy
|
||||
* spells are ignored: jdtls reports progress for the very requests a caller
|
||||
* sends, and re-asking on each of them would never stop. For the same reason
|
||||
* a long spell that began right after `fn` ran (slow requests `fn` sent, or
|
||||
* indexing right after start) re-runs it only once in a row.
|
||||
*/
|
||||
export function onServerSettled(fn: () => void): () => void {
|
||||
if (!isTauri()) return () => {};
|
||||
const since = new Map<number, number>();
|
||||
const fired = new Map<number, { at: number; echoed: boolean }>();
|
||||
return onIdeEvent("languageServer", (e) => {
|
||||
if (e.status === "starting") {
|
||||
since.set(e.server, -Infinity);
|
||||
fired.delete(e.server);
|
||||
} else if (e.status === "busy") {
|
||||
if (!since.has(e.server)) since.set(e.server, Date.now());
|
||||
} else if (e.status === "ready") {
|
||||
const t = since.get(e.server);
|
||||
since.delete(e.server);
|
||||
if (t === undefined || Date.now() - t < LONG_BUSY_MS) return;
|
||||
const last = fired.get(e.server);
|
||||
const echo = !!last && t - last.at < ECHO_MS;
|
||||
if (echo && last.echoed) return;
|
||||
fired.set(e.server, { at: Date.now(), echoed: echo });
|
||||
fn();
|
||||
} else since.delete(e.server);
|
||||
});
|
||||
}
|
||||
|
||||
export function installAvailabilityEvents(): () => void {
|
||||
return onIdeEvent("languageServer", (e) => {
|
||||
if (e.status === "ready") serverBackoff.clear();
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { EditorState, StateEffect } from "@codemirror/state";
|
||||
import { EditorState } from "@codemirror/state";
|
||||
import { EditorView } from "@codemirror/view";
|
||||
import type { CompletionItem } from "@/bindings";
|
||||
import type { EditorDocContext } from "@/editor/api";
|
||||
import { lspDoc } from "./lsp";
|
||||
import {
|
||||
completionSymbolKind,
|
||||
identifierEnd,
|
||||
toCmCompletion,
|
||||
triggerCharacter,
|
||||
typeColumnText,
|
||||
withoutDuplicates,
|
||||
} from "./completionItems";
|
||||
import { completionSymbolKind, identifierEnd, toCmCompletion, triggerCharacter } from "./completionItems";
|
||||
import {
|
||||
applyLspCompletion,
|
||||
callParens,
|
||||
@@ -72,23 +63,6 @@ describe("toCmCompletion", () => {
|
||||
expect(c.displayLabel).toBe("@GetMapping");
|
||||
});
|
||||
|
||||
it("filters on the label when filterText only adds the call or body", () => {
|
||||
for (const filterText of ["String(${0})", "List<>()", "Runnable() {\n\t${0}\n};"]) {
|
||||
const label = filterText.match(/^\w+/)![0];
|
||||
const c = toCmCompletion(item({ label, filterText }));
|
||||
expect(c.label).toBe(label);
|
||||
expect(c.displayLabel).toBeUndefined();
|
||||
}
|
||||
expect(toCmCompletion(item({ label: "foo", filterText: "foo_bar" })).label).toBe("foo_bar");
|
||||
});
|
||||
|
||||
it("lists identical items once", () => {
|
||||
const ctor = item({ label: "String()", kind: "constructor", data: "1" });
|
||||
const overload = item({ label: "String()", kind: "constructor", labelDetail: "(bytes: ByteArray)" });
|
||||
const out = withoutDuplicates([ctor, { ...ctor, data: "2" }, overload, { ...ctor, server: 2 }]);
|
||||
expect(out).toEqual([ctor, overload, { ...ctor, server: 2 }]);
|
||||
});
|
||||
|
||||
it("boosts preselected and demotes deprecated items", () => {
|
||||
expect(toCmCompletion(item({ preselect: true })).boost).toBe(99);
|
||||
expect(toCmCompletion(item({ deprecated: true })).boost).toBeLessThan(0);
|
||||
@@ -148,31 +122,12 @@ describe("applying completions", () => {
|
||||
expect(view.state.selection.main.head).toBe(14);
|
||||
});
|
||||
|
||||
it("keeps overloads sharing a filterText apart", () => {
|
||||
const { req } = setup("x.ti|");
|
||||
const [a, b] = ["times(other: Int)", "times(other: Long)"].map((label) =>
|
||||
makeCompletion(item({ label, filterText: "times" }), req),
|
||||
);
|
||||
expect([a!.label, b!.label]).toEqual(["times", "times"]);
|
||||
expect(a!.apply).not.toBe(b!.apply);
|
||||
});
|
||||
|
||||
it("replaces the rest of the identifier with ⇥", () => {
|
||||
const { view, req } = setup("service.cr|Order()");
|
||||
applyLspCompletion(view, makeCompletion(item({ insertText: "create" }), req), 8, 10, "replace");
|
||||
expect(view.state.doc.toString()).toBe("service.create()");
|
||||
});
|
||||
|
||||
it("leaves the caret inside a call snippet without stops, past `)` once nothing takes arguments", async () => {
|
||||
const { view, req } = setup("new Arr|");
|
||||
view.dispatch({ effects: StateEffect.appendConfig.of(lspDoc.of({ doc: 1 } as EditorDocContext)) });
|
||||
apply(view, makeCompletion(item({ kind: "constructor", insertText: "ArrayList<>()", isSnippet: true }), req), 4);
|
||||
expect(view.state.doc.toString()).toBe("new ArrayList<>()");
|
||||
expect(view.state.selection.main.head).toBe(16);
|
||||
// Signature help fails outside Tauri: nothing to pass.
|
||||
await vi.waitFor(() => expect(view.state.selection.main.head).toBe(17));
|
||||
});
|
||||
|
||||
it("uses the server's ⇥ range when given", () => {
|
||||
const { view, req } = setup("a.cr|Order.x");
|
||||
const c = makeCompletion(
|
||||
@@ -325,27 +280,3 @@ describe("explicit completion", () => {
|
||||
view.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("typeColumnText", () => {
|
||||
const edit = (new_text: string) => [{ range: { start: { line: 0, col: 0 }, end: { line: 0, col: 0 } }, new_text }];
|
||||
|
||||
it("names the module an auto-import comes from", () => {
|
||||
expect(typeColumnText({ detail: "Auto-import", additionalEdits: edit("\nfrom collections import OrderedDict") })).toBe(
|
||||
"collections",
|
||||
);
|
||||
expect(typeColumnText({ detail: "Map<K, V>", additionalEdits: edit("import java.util.HashMap;\n") })).toBe(
|
||||
"Map<K, V> (java.util)",
|
||||
);
|
||||
expect(typeColumnText({ detail: null, additionalEdits: edit("use std::collections::HashMap;\n") })).toBe(
|
||||
"std::collections",
|
||||
);
|
||||
expect(typeColumnText({ detail: null, additionalEdits: edit('import { a } from "./money";\n') })).toBe("./money");
|
||||
});
|
||||
|
||||
it("keeps a detail that already says where", () => {
|
||||
expect(typeColumnText({ detail: "java.util.ArrayList", additionalEdits: edit("import java.util.ArrayList;\n") })).toBe(
|
||||
"java.util.ArrayList",
|
||||
);
|
||||
expect(typeColumnText({ detail: "fn() ", additionalEdits: [] })).toBe("fn() ");
|
||||
});
|
||||
});
|
||||
@@ -35,21 +35,14 @@ import {
|
||||
type RequestId,
|
||||
} from "@/platform/ipc";
|
||||
import { useProject } from "@/platform/project";
|
||||
import {
|
||||
completionSymbolKind,
|
||||
identifierEnd,
|
||||
toCmCompletion,
|
||||
triggerCharacter,
|
||||
typeColumnText,
|
||||
withoutDuplicates,
|
||||
} from "./completionItems";
|
||||
import { completionSymbolKind, identifierEnd, toCmCompletion, triggerCharacter } from "./completionItems";
|
||||
import { lspSnippetToCm, snippetVariables } from "./snippet";
|
||||
import { docOf, isUnavailable, lspDoc, lspRequest, reportLspError } from "./lsp";
|
||||
import { offsetToPos, posToOffset, textEditsToChanges } from "./positions";
|
||||
import { isEmptyMarkup, renderCode, renderMarkup } from "./markdown";
|
||||
import { selectableText } from "@/ui/selectableText";
|
||||
import { iconNode } from "./iconMarkup";
|
||||
import { parameterInfoOrLeave, triggerSignatureHelp } from "./signature";
|
||||
import { triggerSignatureHelp } from "./signature";
|
||||
import { serverBackoff } from "./availability";
|
||||
import { pathCompletionSource } from "./fileReferences";
|
||||
import { editorPrefs } from "@/platform/editorSettings";
|
||||
@@ -78,42 +71,17 @@ const isLsp = (c: Completion): c is LspCompletion => "lsp" in c;
|
||||
// Resolve (documentation, lazily computed edits)
|
||||
|
||||
const resolving = new WeakMap<CompletionItem, Promise<CompletionItem>>();
|
||||
/** Items whose resolve has answered, for accepting them synchronously. */
|
||||
const resolvedItems = new WeakMap<CompletionItem, CompletionItem>();
|
||||
|
||||
function resolveItem(doc: number, item: CompletionItem): Promise<CompletionItem> {
|
||||
if (item.data == null && !isEmptyMarkup(item.documentation)) return Promise.resolve(item);
|
||||
let p = resolving.get(item);
|
||||
if (!p) {
|
||||
p = lspRequest(() => commands.lspResolveCompletion(doc, item)).then(
|
||||
(r) => {
|
||||
resolvedItems.set(item, r);
|
||||
return r;
|
||||
},
|
||||
() => item,
|
||||
);
|
||||
p = lspRequest(() => commands.lspResolveCompletion(doc, item)).catch(() => item);
|
||||
resolving.set(item, p);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the selected lookup item ahead of acceptance: some servers compute
|
||||
* its extra edits (rust-analyzer's `use` import) only on resolve, against the
|
||||
* text as it was, so resolving after the insertion finds nothing.
|
||||
*/
|
||||
const prefetchResolve = ViewPlugin.fromClass(
|
||||
class {
|
||||
private last: Completion | null = null;
|
||||
update(u: ViewUpdate) {
|
||||
const c = selectedCompletion(u.state);
|
||||
if (c === this.last) return;
|
||||
this.last = c;
|
||||
if (c && isLsp(c) && c.lsp.data != null && !c.lsp.additionalEdits.length) void resolveItem(c.req.doc, c.lsp);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* F1 in the lookup (IDEA's documentation popup next to the lookup): docs then
|
||||
* follow the selection until the lookup closes. Without the auto-popup setting
|
||||
@@ -198,7 +166,7 @@ export function applyLspCompletion(
|
||||
) {
|
||||
if (!isLsp(completion)) return;
|
||||
const { req } = completion;
|
||||
const item = completion.resolved ?? resolvedItems.get(completion.lsp) ?? completion.lsp;
|
||||
const item = completion.resolved ?? completion.lsp;
|
||||
const state = view.state;
|
||||
const delta = to - req.pos;
|
||||
const mapOld = (offset: number) =>
|
||||
@@ -223,7 +191,6 @@ export function applyLspCompletion(
|
||||
.filter((c) => c.to <= start || c.from >= end);
|
||||
|
||||
let insertedParens: ReturnType<typeof callParens> = null;
|
||||
let bareCall: number | null = null;
|
||||
if (item.isSnippet) {
|
||||
if (extra.length) {
|
||||
const tr = state.update({ changes: extra, userEvent: "input.complete" });
|
||||
@@ -232,19 +199,6 @@ export function applyLspCompletion(
|
||||
end = tr.changes.mapPos(end, 1);
|
||||
}
|
||||
snippet(lspSnippetToCm(item.insertText, snippetVariables(req.path)))(view, completion, start, end);
|
||||
// A call snippet without a stop (`ArrayList<>()`): the caret goes inside until
|
||||
// signature help says there is nothing to pass.
|
||||
const head = view.state.selection.main.head;
|
||||
if (
|
||||
editorPrefs().completion.insertParentheses &&
|
||||
CALLABLE.has(item.kind ?? "") &&
|
||||
/\(\)$/.test(item.insertText) &&
|
||||
!/\$/.test(item.insertText) &&
|
||||
view.state.sliceDoc(head - 2, head) === "()"
|
||||
) {
|
||||
view.dispatch({ selection: EditorSelection.cursor(head - 1) });
|
||||
bareCall = head - 1;
|
||||
}
|
||||
} else {
|
||||
const parens = editorPrefs().completion.insertParentheses
|
||||
? callParens(item, state.doc.lineAt(start), start, end)
|
||||
@@ -261,15 +215,9 @@ export function applyLspCompletion(
|
||||
});
|
||||
}
|
||||
|
||||
if (item === completion.lsp && !item.additionalEdits.length && item.data != null)
|
||||
if (!completion.resolved && !item.additionalEdits.length && item.data != null)
|
||||
void applyLateEdits(view, completion, start);
|
||||
// Parameter info for a call left open, plain (`()` added here) or a server snippet (`fly(${1})`).
|
||||
const callSnippet = item.isSnippet && CALLABLE.has(item.kind ?? "") && /\(\$\{?\d/.test(item.insertText);
|
||||
// Unless the item's command asks for it itself (other commands, like jdtls's
|
||||
// `java.completion.onDidSelect`, are bookkeeping).
|
||||
const hintsCommand = item.command?.command === "editor.action.triggerParameterHints";
|
||||
if ((insertedParens === "inside" || callSnippet) && !hintsCommand) setTimeout(() => triggerSignatureHelp(view), 0);
|
||||
else if (bareCall !== null) void parameterInfoOrLeave(view, bareCall);
|
||||
if (insertedParens === "inside" && !item.command) setTimeout(() => triggerSignatureHelp(view), 0);
|
||||
runCommand(view, item);
|
||||
}
|
||||
|
||||
@@ -366,13 +314,7 @@ export function makeCompletion(item: CompletionItem, req: RequestContext): LspCo
|
||||
return Object.assign(cm, {
|
||||
lsp: item,
|
||||
req,
|
||||
// CodeMirror merges options with the same label, detail and `apply`: overloads
|
||||
// sharing a filterText (`times(other: Int)`, `times(other: Long)`…) and the same
|
||||
// name imported from different modules need their own.
|
||||
apply:
|
||||
cm.displayLabel || (item.filterText && item.filterText !== item.label) || item.additionalEdits.length
|
||||
? (...a: Parameters<typeof applyLsp>) => applyLsp(...a)
|
||||
: applyLsp,
|
||||
apply: applyLsp,
|
||||
info: (c: Completion) => renderInfo(c as LspCompletion),
|
||||
});
|
||||
}
|
||||
@@ -427,10 +369,7 @@ async function lspCompletionSource(ctx: CompletionContext): Promise<CompletionRe
|
||||
});
|
||||
let list;
|
||||
try {
|
||||
list = await lspRequest(
|
||||
() => commands.lspCompletion(id, doc.doc, offsetToPos(ctx.state.doc, ctx.pos), trigger),
|
||||
() => inflight === id,
|
||||
);
|
||||
list = await lspRequest(() => commands.lspCompletion(id, doc.doc, offsetToPos(ctx.state.doc, ctx.pos), trigger));
|
||||
} catch (e) {
|
||||
if (isUnavailable(e)) {
|
||||
serverBackoff.mark(doc.doc);
|
||||
@@ -444,18 +383,9 @@ async function lspCompletionSource(ctx: CompletionContext): Promise<CompletionRe
|
||||
const req: RequestContext = { doc: doc.doc, path: doc.path, language: doc.uiMode, pos: ctx.pos, text: ctx.state.doc };
|
||||
const prefs = editorPrefs().completion;
|
||||
const typed = word?.text ?? "";
|
||||
let items = withoutDuplicates(
|
||||
prefs.matchCase
|
||||
? list.items.filter((it) => matchesCase(it.filterText ?? it.label, typed, prefs.caseSensitivity))
|
||||
: list.items,
|
||||
);
|
||||
// A server snippet named like a live template (jdtls `sout`, `fori`) would be listed twice; the template wins.
|
||||
if (items.some((it) => it.kind === "snippet")) {
|
||||
const own = await contributedSource(ctx);
|
||||
if (ctx.aborted) return null;
|
||||
const names = new Set(own?.options.map((o) => o.label));
|
||||
if (names.size) items = items.filter((it) => it.kind !== "snippet" || !names.has(it.label));
|
||||
}
|
||||
const items = prefs.matchCase
|
||||
? list.items.filter((it) => matchesCase(it.filterText ?? it.label, typed, prefs.caseSensitivity))
|
||||
: list.items;
|
||||
return {
|
||||
from: word ? word.from : ctx.pos,
|
||||
options: items.map((item) => makeCompletion(item, req)),
|
||||
@@ -686,11 +616,11 @@ function kindBadge(c: Completion): Node | null {
|
||||
}
|
||||
|
||||
function typeColumn(c: Completion): Node | null {
|
||||
const detail = isLsp(c) ? typeColumnText(c.lsp) : (c as RichCompletion).typeText?.replace(/\s+/g, " ");
|
||||
const detail = isLsp(c) ? c.lsp.detail : (c as RichCompletion).typeText;
|
||||
if (!detail) return null;
|
||||
const span = document.createElement("span");
|
||||
span.className = "cm-lsp-type";
|
||||
span.textContent = detail;
|
||||
span.textContent = detail.replace(/\s+/g, " ");
|
||||
return span;
|
||||
}
|
||||
|
||||
@@ -754,7 +684,6 @@ const completionFooter = ViewPlugin.fromClass(
|
||||
export function completionExtension() {
|
||||
return [
|
||||
lookupKeys,
|
||||
prefetchResolve,
|
||||
autocompletion({
|
||||
override: [gated(lspCompletionSource), gated(contributedSource), gated(pathCompletionSource)],
|
||||
icons: false,
|
||||
|
||||
@@ -41,7 +41,7 @@ export function completionSymbolKind(kind: CompletionKind | null): string {
|
||||
* original label is shown through `displayLabel`.
|
||||
*/
|
||||
export function toCmCompletion(item: CompletionItem): Completion {
|
||||
const filter = item.filterText && item.filterText !== item.label && !extendsLabel(item) ? item.filterText : null;
|
||||
const filter = item.filterText && item.filterText !== item.label ? item.filterText : null;
|
||||
const c: Completion = {
|
||||
label: filter ?? item.label,
|
||||
type: completionSymbolKind(item.kind),
|
||||
@@ -55,62 +55,6 @@ export function toCmCompletion(item: CompletionItem): Completion {
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* A `filterText` that is the label plus what the item inserts after it (jdtls
|
||||
* `String(${0})`, `List<>()`): typing a word never reaches that part, and
|
||||
* matching on it would rank the exact `String` like `StringBuilder`.
|
||||
*/
|
||||
function extendsLabel(item: CompletionItem): boolean {
|
||||
const rest = item.filterText!.slice(item.label.length);
|
||||
return item.filterText!.startsWith(item.label) && /^[^\p{L}\p{N}_$]/u.test(rest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Items that look and insert the same, listed once. kotlin-language-server
|
||||
* repeats a class once per classpath entry declaring it (`String()` ×3);
|
||||
* these all have their own `apply` (see `makeCompletion`), so CodeMirror
|
||||
* wouldn't merge them.
|
||||
*/
|
||||
export function withoutDuplicates(items: readonly CompletionItem[]): CompletionItem[] {
|
||||
const seen = new Set<string>();
|
||||
return items.filter((it) => {
|
||||
const key = JSON.stringify([it.server, it.label, it.labelDetail, it.detail, it.kind, it.insertText, it.additionalEdits]);
|
||||
if (seen.has(key)) return false;
|
||||
seen.add(key);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
const IMPORT_SOURCE = [
|
||||
/^\s*from\s+([\w.]+)\s+import\b/m, // Python
|
||||
/^\s*import\s+(?:static\s+)?([\w.]+?)\.\w+;?\s*$/m, // Java, Kotlin
|
||||
/^\s*use\s+([\w:]+)::/m, // Rust
|
||||
/\bfrom\s+["']([^"']+)["']/, // JS / TS
|
||||
];
|
||||
|
||||
/**
|
||||
* Where an auto-import item comes from (`collections`, `java.util`): the
|
||||
* module its import edit names. Servers like pyright put it nowhere else, so
|
||||
* same-named items (`OrderedDict` from typing / collections) look identical.
|
||||
*/
|
||||
export function importSource(item: Pick<CompletionItem, "additionalEdits">): string | null {
|
||||
for (const e of item.additionalEdits) {
|
||||
for (const re of IMPORT_SOURCE) {
|
||||
const m = re.exec(e.new_text);
|
||||
if (m) return m[1]!;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Text of the right-aligned type column: the detail, with the import source when it lacks one. */
|
||||
export function typeColumnText(item: Pick<CompletionItem, "detail" | "additionalEdits">): string | null {
|
||||
const detail = item.detail?.replace(/\s+/g, " ") || null;
|
||||
const source = importSource(item);
|
||||
if (!source || detail?.includes(source)) return detail;
|
||||
return !detail || /^auto[- ]?import$/i.test(detail) ? source : `${detail} (${source})`;
|
||||
}
|
||||
|
||||
const WORD_CHAR = /[\p{L}\p{N}_$]/u;
|
||||
|
||||
/** End of the identifier starting at `pos` in `line` (for ⇥ Replace without a server range). */
|
||||
|
||||
@@ -9,8 +9,7 @@ import { EditorSelection, StateEffect, StateField } from "@codemirror/state";
|
||||
import { EditorView, ViewPlugin } from "@codemirror/view";
|
||||
import { forEachDiagnostic, linter, setDiagnostics, type Diagnostic as LintDiagnostic } from "@codemirror/lint";
|
||||
import type { Diagnostic, Severity } from "@/bindings";
|
||||
import { commands, ideEventsReady, isTauri, onIdeEvent } from "@/platform/ipc";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { onIdeEvent } from "@/platform/ipc";
|
||||
import { publishLocalDiagnostics } from "@/platform/localDiagnostics";
|
||||
import { scrollbarMarks, type ScrollbarMark } from "@/editor/api";
|
||||
import { rangeToOffsets } from "./positions";
|
||||
@@ -90,20 +89,11 @@ export function subscribeDiagnostics(path: string, l: Listener): () => void {
|
||||
|
||||
export function installDiagnosticsEvents(): () => void {
|
||||
const off = onIdeEvent("diagnostics", (e) => storeDiagnostics(e.path, e.source, e.items));
|
||||
// Diagnostics published before this window (re)loaded were missed: ask for them again.
|
||||
const resend = () => {
|
||||
if (isTauri()) void ideEventsReady().then(() => commands.lspResendDiagnostics()).catch(() => {});
|
||||
};
|
||||
if (useProject.getState().project) resend();
|
||||
const offProject = useProject.subscribe((s, prev) => {
|
||||
if (s.project?.root !== prev.project?.root && s.project) resend();
|
||||
});
|
||||
// Another inspection profile (or edits to it) re-filters every open file.
|
||||
const offProfile = subscribeInspectionProfile(() => listeners.forEach((set) => set.forEach((l) => l())));
|
||||
return () => {
|
||||
off();
|
||||
offProfile();
|
||||
offProject();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -128,16 +118,13 @@ export function toLintDiagnostics(doc: Text, items: readonly Diagnostic[]): Lint
|
||||
to,
|
||||
severity: d.severity,
|
||||
message: d.message,
|
||||
source: [d.source, isInternalCode(d.code) ? null : d.code].filter(Boolean).join(" ") || undefined,
|
||||
source: [d.source, d.code].filter(Boolean).join(" ") || undefined,
|
||||
markClass: classes.length ? classes.join(" ") : undefined,
|
||||
};
|
||||
});
|
||||
return out.sort((a, b) => a.from - b.from || SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity]);
|
||||
}
|
||||
|
||||
/** Problem ids that mean nothing to a reader (jdtls: `67109264`); short ones (TS `2322`) stay. */
|
||||
const isInternalCode = (code: string | null | undefined) => !!code && /^\d{6,}$/.test(code);
|
||||
|
||||
const MARK_COLOR: Partial<Record<Severity, string>> = {
|
||||
error: "var(--danger)",
|
||||
warning: "var(--warning)",
|
||||
@@ -231,13 +218,6 @@ const lintTheme = EditorView.theme({
|
||||
},
|
||||
".cm-lintRange.cm-lsp-unnecessary *": { color: "var(--fg-unused, var(--fg-faint))" },
|
||||
".cm-lintRange.cm-lsp-deprecated": { textDecoration: "line-through", textDecorationColor: "var(--fg-muted)" },
|
||||
// An error or warning on the same range (merged into one mark) keeps its underline.
|
||||
".cm-lintRange-error.cm-lsp-typo, .cm-lintRange-error.cm-lsp-unnecessary": {
|
||||
textDecoration: "var(--editor-error-decoration, underline wavy var(--danger))",
|
||||
},
|
||||
".cm-lintRange-warning.cm-lsp-typo, .cm-lintRange-warning.cm-lsp-unnecessary": {
|
||||
textDecoration: "var(--editor-warning-decoration, underline wavy var(--warning))",
|
||||
},
|
||||
".cm-lintRange-active": { backgroundColor: "transparent" },
|
||||
".cm-lintRange-warning.cm-lintRange-active": { backgroundColor: "var(--editor-warning-background, transparent)" },
|
||||
".cm-lintPoint:after": { display: "none" },
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
protectedRegions,
|
||||
type FormatGuardOptions,
|
||||
} from "@/platform/formatGuard";
|
||||
import { dedentsToColumnZero, formattedLines } from "./format";
|
||||
import { formattedLines } from "./format";
|
||||
|
||||
describe("formattedLines", () => {
|
||||
const doc = Text.of(["fn main(){", "let x=1;", "}", "", "fn other() {}"]);
|
||||
@@ -97,11 +97,3 @@ describe("formatter markers and Do not format", () => {
|
||||
expect(formatExcluded("/p/other/docs.md", "/p", globs)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("dedentsToColumnZero", () => {
|
||||
it("spots range formatting done without the surrounding code", () => {
|
||||
expect(dedentsToColumnZero("\n override fun f() { }\n", "\noverride fun f() {}\n")).toBe(true);
|
||||
expect(dedentsToColumnZero("\n\tfun f() {\n\t}\n", "\n fun f() {\n }\n")).toBe(false);
|
||||
expect(dedentsToColumnZero("fun f() {}\n", "fun f() { }\n")).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
import { indentUnit } from "@codemirror/language";
|
||||
import { isolateHistory } from "@codemirror/commands";
|
||||
import type { EditorState, Text } from "@codemirror/state";
|
||||
import type { Text } from "@codemirror/state";
|
||||
import type { EditorView } from "@codemirror/view";
|
||||
import { commands } from "@/platform/ipc";
|
||||
import { shortcutLabel } from "@/platform/keymap";
|
||||
@@ -63,12 +63,6 @@ function formattedHint(view: EditorView, lines: number) {
|
||||
});
|
||||
}
|
||||
|
||||
/** LSP `FormattingOptions`: with spaces the indent width is the indent unit, not the tab size. */
|
||||
export function formatOptionsOf(state: EditorState): { tabSize: number; insertSpaces: boolean } {
|
||||
const unit = state.facet(indentUnit);
|
||||
return unit.includes("\t") ? { tabSize: state.tabSize, insertSpaces: false } : { tabSize: unit.length || state.tabSize, insertSpaces: true };
|
||||
}
|
||||
|
||||
export async function formatDocument(
|
||||
view: EditorView,
|
||||
opts: { explicit: boolean; selectionOnly?: boolean } = { explicit: true },
|
||||
@@ -96,7 +90,7 @@ async function format(view: EditorView, opts: { explicit: boolean; selectionOnly
|
||||
const sel = state.selection.main;
|
||||
const useSelection = (opts.selectionOnly ?? true) && !sel.empty;
|
||||
const range = useSelection ? { start: offsetToPos(state.doc, sel.from), end: offsetToPos(state.doc, sel.to) } : null;
|
||||
const options = formatOptionsOf(state);
|
||||
const options = { tabSize: state.tabSize, insertSpaces: !state.facet(indentUnit).includes("\t") };
|
||||
let edits;
|
||||
try {
|
||||
edits = await lspRequest(() => commands.lspFormat(doc.doc, range, options));
|
||||
@@ -122,45 +116,6 @@ async function format(view: EditorView, opts: { explicit: boolean; selectionOnly
|
||||
return { applied: true, changes: changes.length, lines: formattedLines(state.doc, changes) };
|
||||
}
|
||||
|
||||
/** Whether `after` has a non-blank line at column 0 where all of `before` was indented. */
|
||||
export function dedentsToColumnZero(before: string, after: string): boolean {
|
||||
const minIndent = (t: string) =>
|
||||
Math.min(...t.split("\n").filter((l) => l.trim()).map((l) => l.length - l.trimStart().length));
|
||||
return minIndent(before) > 0 && minIndent(after) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reformats lines `from..to` silently (generated code: quick fixes, Generate),
|
||||
* merged into the edit's undo step. False when the server can't format ranges.
|
||||
*/
|
||||
export async function formatLines(view: EditorView, from: number, to: number): Promise<boolean> {
|
||||
const doc = docOf(view);
|
||||
if (!doc || doc.readOnly) return false;
|
||||
const { project, settings } = useProject.getState();
|
||||
if (formatExcluded(doc.path, project?.root ?? null, formatGuardOptions(settings).doNotFormat)) return false;
|
||||
await whenSynced(view);
|
||||
const state = view.state;
|
||||
const range = { start: offsetToPos(state.doc, from), end: offsetToPos(state.doc, to) };
|
||||
const options = formatOptionsOf(state);
|
||||
let edits;
|
||||
try {
|
||||
edits = await lspRequest(() => commands.lspFormat(doc.doc, range, options));
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
if (view.state.doc !== state.doc) return false;
|
||||
// Only inside the range: some servers answer a range request with whole-file edits.
|
||||
const changes = textEditsToChanges(state.doc, edits).filter((c) => c.from >= from && c.to <= to && state.sliceDoc(c.from, c.to) !== c.insert);
|
||||
if (!changes.length) return true;
|
||||
// A server formatting the range out of context (kotlin-language-server) moves
|
||||
// indented code to column 0: its answer is ignored then.
|
||||
const delta = changes.reduce((d, c) => d + c.insert.length - (c.to - c.from), 0);
|
||||
const next = state.update({ changes }).state.doc;
|
||||
if (dedentsToColumnZero(state.sliceDoc(from, to), next.sliceString(from, to + delta))) return false;
|
||||
view.dispatch({ changes, userEvent: "format", scrollIntoView: false });
|
||||
return true;
|
||||
}
|
||||
|
||||
function applyContributedFormat(
|
||||
view: EditorView,
|
||||
format: ContributedFormatter,
|
||||
|
||||
@@ -31,7 +31,6 @@ import { docWindowVisible, moveDocPopupToWindow, showInDocWindow } from "./docs"
|
||||
import { structure } from "@/editor/structure";
|
||||
import { basename } from "@/platform/project";
|
||||
import { iconNode } from "./iconMarkup";
|
||||
import { applyCodeAction, quickFixesAt } from "./intentions";
|
||||
import { editorPrefs } from "@/platform/editorSettings";
|
||||
import { CONTRIBUTED_HOVER, contributedAt, type ContributedHover } from "@/editor/api";
|
||||
import { navigationModifierHeld, onNavigationModifier, pointerTarget } from "@/platform/navigationModifier";
|
||||
@@ -51,10 +50,7 @@ export async function requestHover(view: EditorView, pos: number): Promise<Hover
|
||||
if (hoverRequest !== null && isTauri()) void commands.cancelRequest(hoverRequest);
|
||||
const id = (hoverRequest = nextRequestId());
|
||||
try {
|
||||
const h = await lspRequest(
|
||||
() => commands.lspHover(id, doc.doc, offsetToPos(view.state.doc, pos)),
|
||||
() => hoverRequest === id,
|
||||
);
|
||||
const h = await lspRequest(() => commands.lspHover(id, doc.doc, offsetToPos(view.state.doc, pos)));
|
||||
return h && !isEmptyMarkup(h.contents) ? h : null;
|
||||
} finally {
|
||||
if (hoverRequest === id) hoverRequest = null;
|
||||
@@ -64,7 +60,7 @@ export async function requestHover(view: EditorView, pos: number): Promise<Hover
|
||||
function renderDiagnostics(view: EditorView, diags: PlacedDiagnostic[]): HTMLElement {
|
||||
const box = document.createElement("div");
|
||||
box.className = "cm-lsp-hover-diagnostics";
|
||||
for (const { diagnostic: d, from, to } of diags) {
|
||||
for (const { diagnostic: d, from } of diags) {
|
||||
const row = document.createElement("div");
|
||||
row.className = `cm-lsp-diag cm-lsp-diag-${d.severity}`;
|
||||
row.appendChild(
|
||||
@@ -91,7 +87,6 @@ function renderDiagnostics(view: EditorView, diags: PlacedDiagnostic[]): HTMLEle
|
||||
fix.className = "cm-lsp-link-button";
|
||||
const keys = shortcutLabel("code.showIntentions");
|
||||
fix.textContent = keys ? `More actions… ${keys}` : "More actions…";
|
||||
if (d.severity === "error" || d.severity === "warning") offerQuickFix(view, meta, fix, from, to);
|
||||
fix.addEventListener("mousedown", (e) => e.preventDefault());
|
||||
fix.addEventListener("click", () => {
|
||||
view.dispatch({ selection: EditorSelection.cursor(from) });
|
||||
@@ -105,28 +100,6 @@ function renderDiagnostics(view: EditorView, diags: PlacedDiagnostic[]): HTMLEle
|
||||
return box;
|
||||
}
|
||||
|
||||
/** IDEA's hover link to the problem's preferred quick fix, shown once the server named one. */
|
||||
function offerQuickFix(view: EditorView, meta: HTMLElement, before: HTMLElement, from: number, to: number) {
|
||||
const doc = view.state.doc;
|
||||
void quickFixesAt(view, from, to)
|
||||
.then(([action]) => {
|
||||
if (!action || view.state.doc !== doc || !before.isConnected) return;
|
||||
const link = document.createElement("button");
|
||||
link.type = "button";
|
||||
link.className = "cm-lsp-link-button";
|
||||
const keys = shortcutLabel("code.applyQuickFix");
|
||||
link.textContent = keys ? `${action.title} ${keys}` : action.title;
|
||||
link.addEventListener("mousedown", (e) => e.preventDefault());
|
||||
link.addEventListener("click", () => {
|
||||
view.dispatch({ effects: closeHoverTooltips });
|
||||
view.focus();
|
||||
void applyCodeAction(view, action);
|
||||
});
|
||||
meta.insertBefore(link, before);
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the plain hover (problems + quick documentation) stays out: while
|
||||
* ⌘/Ctrl is held the ⌘-hover link and its brief info (`navigation.ts`) own the
|
||||
|
||||
@@ -163,9 +163,8 @@ export async function requestInline(view: EditorView, automatic: boolean): Promi
|
||||
const id = (inflight = nextRequestId());
|
||||
const caret = sel.main.head;
|
||||
try {
|
||||
const items = await lspRequest(
|
||||
() => commands.lspInlineCompletion(id, doc.doc, offsetToPos(state.doc, caret), automatic),
|
||||
() => inflight === id,
|
||||
const items = await lspRequest(() =>
|
||||
commands.lspInlineCompletion(id, doc.doc, offsetToPos(state.doc, caret), automatic),
|
||||
);
|
||||
if (view.state.doc !== state.doc || !view.state.selection.eq(sel)) return false;
|
||||
const suggestions = toSuggestions(view.state, caret, items);
|
||||
|
||||
@@ -28,8 +28,7 @@ vi.mock("@/platform/ipc", async (orig) => {
|
||||
return { ...actual, isTauri: () => true, commands: { ...actual.commands, lspResolveCodeAction } };
|
||||
});
|
||||
|
||||
const { bulbLine, changedLines, indentUnderBrace, intentionPreview, lightsBulb, listedCodeActions, withInspectionControls } =
|
||||
await import("./intentions");
|
||||
const { intentionPreview, withInspectionControls } = await import("./intentions");
|
||||
const { setFileDiagnostics } = await import("./diagnostics");
|
||||
const { lspDoc } = await import("./lsp");
|
||||
|
||||
@@ -110,71 +109,3 @@ describe("intention preview", () => {
|
||||
expect(lspResolveCodeAction).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
|
||||
describe("listedCodeActions", () => {
|
||||
const action = (title: string, kind: string): CodeAction => ({ ...resolved, title, kind, edit: null });
|
||||
it("lists one action per title, quick fixes first", () => {
|
||||
const list = listedCodeActions([
|
||||
action("Generate toString()", "quickassist"),
|
||||
action("Add unimplemented methods", "quickfix"),
|
||||
action("Generate toString()", "source.generate.toString"),
|
||||
]);
|
||||
expect(list.map((a) => [a.title, a.kind])).toEqual([
|
||||
["Add unimplemented methods", "quickfix"],
|
||||
["Generate toString()", "quickassist"],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("changedLines", () => {
|
||||
const text = (s: string) => EditorState.create({ doc: s }).doc;
|
||||
it("spans the lines an edit inserted", () => {
|
||||
expect(changedLines(text("class A {\n}\n"), text("class A {\n f() {\n }\n}\n"))).toEqual([{ from: 2, to: 3 }]);
|
||||
});
|
||||
it("keeps separate edits apart", () => {
|
||||
const before = text("package p;\n\nclass A {\n int a;\n int b;\n void f() {\n }\n}\n");
|
||||
const after = text("package p;\n\nimport java.util.List;\n\nclass A {\n int a;\n int b;\n void f() {\n List<String> x = null;\n x.size();\n }\n}\n");
|
||||
expect(changedLines(before, after)).toEqual([
|
||||
{ from: 3, to: 4 },
|
||||
{ from: 9, to: 10 },
|
||||
]);
|
||||
});
|
||||
it("is empty for equal texts", () => {
|
||||
expect(changedLines(text("a\nb"), text("a\nb"))).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("bulbLine", () => {
|
||||
const state = (s: string) => EditorState.create({ doc: s });
|
||||
it("prefers an indented caret line, then the lines around it", () => {
|
||||
expect(bulbLine(state(" x\ny"), 1)).toEqual({ line: 1, gutter: false });
|
||||
expect(bulbLine(state("x\n\ny"), 1)).toEqual({ line: 2, gutter: false });
|
||||
});
|
||||
it("falls back to the gutter when no nearby line has room", () => {
|
||||
expect(bulbLine(state("x\n y\nz"), 1)).toEqual({ line: 1, gutter: true });
|
||||
});
|
||||
});
|
||||
|
||||
describe("lightsBulb", () => {
|
||||
const kinds = (k: string | null) => lightsBulb({ ...resolved, kind: k });
|
||||
it("lights for fixes and refactorings only", () => {
|
||||
expect([null, "quickfix", "refactor.extract", "quickassist"].map(kinds)).toEqual([true, true, true, true]);
|
||||
expect(["source.organizeImports", "source.doc", "gopls.doc.features"].map(kinds)).toEqual([false, false, false]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("indentUnderBrace", () => {
|
||||
const text = (s: string) => EditorState.create({ doc: s }).doc;
|
||||
it("moves code generated at the brace's column one level in", () => {
|
||||
const doc = text("class A : B {\noverride fun f() {\n g()\n}\n}");
|
||||
expect(indentUnderBrace(doc, 2, 4, " ").map((c) => [doc.lineAt(c.from).number, c.insert])).toEqual([
|
||||
[2, " "],
|
||||
[3, " "],
|
||||
[4, " "],
|
||||
]);
|
||||
});
|
||||
it("leaves code already indented, or not under a brace", () => {
|
||||
expect(indentUnderBrace(text("class A {\n f()\n}"), 2, 2, " ")).toEqual([]);
|
||||
expect(indentUnderBrace(text("class A:\npass\nx"), 2, 3, " ")).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -3,19 +3,15 @@
|
||||
* intentions popup (quick fixes first, preferred in bold), Optimize Imports and
|
||||
* Generate. Refactor This and the Refactor menu live in `@/editor/refactor`.
|
||||
*/
|
||||
import { StateEffect, StateField, type Extension, type Text } from "@codemirror/state";
|
||||
import { StateEffect, StateField, type Extension } from "@codemirror/state";
|
||||
import { EditorView, ViewPlugin, type ViewUpdate } from "@codemirror/view";
|
||||
import { forEachDiagnostic } from "@codemirror/lint";
|
||||
import { indentUnit } from "@codemirror/language";
|
||||
import { diff } from "@codemirror/merge";
|
||||
import { commands, isCancelled, type CodeAction } from "@/platform/ipc";
|
||||
import { contributedIntentions, intentionProviders, whenSynced } from "@/editor/api";
|
||||
import { contributedIntentions, whenSynced } from "@/editor/api";
|
||||
import { shortcutLabel } from "@/platform/keymap";
|
||||
import { debounce, docOf, isUnavailable, lspRequest, reportLspError } from "./lsp";
|
||||
import { offsetsToRange } from "./positions";
|
||||
import { showHint } from "./hint";
|
||||
import { formatLines } from "./format";
|
||||
import { pythonMemberIntentions } from "./pythonMembers";
|
||||
import { caretAnchor, openPopup, type ListPopupItem, type ListPreview } from "./popupStore";
|
||||
import { editPreviewLines } from "./workspaceEdit";
|
||||
import { serverBackoff } from "./availability";
|
||||
@@ -92,43 +88,6 @@ async function fetchIntentions(view: EditorView): Promise<CodeAction[]> {
|
||||
return actions;
|
||||
}
|
||||
|
||||
/** Enabled quick fixes of the problem at `from..to`, preferred first. */
|
||||
export async function quickFixesAt(view: EditorView, from: number, to: number): Promise<CodeAction[]> {
|
||||
const doc = docOf(view);
|
||||
if (!doc) return [];
|
||||
await whenSynced(view);
|
||||
const actions = await lspRequest(() => commands.lspCodeActions(doc.doc, offsetsToRange(view.state.doc, from, to), ["quickfix"]));
|
||||
return sortCodeActions(actions.filter((a) => isQuickFix(a) && !a.disabledReason));
|
||||
}
|
||||
|
||||
/**
|
||||
* ⌥⇧↵: applies the preferred (else first) quick fix of the most severe problem
|
||||
* at the caret, or of one elsewhere on the caret line.
|
||||
*/
|
||||
export async function applyQuickFix(view: EditorView) {
|
||||
const state = view.state;
|
||||
const caret = state.selection.main.head;
|
||||
const line = state.doc.lineAt(caret);
|
||||
const problems: Array<PlacedProblem & { rank: number }> = [];
|
||||
forEachDiagnostic(state, (d, from, to) => {
|
||||
if (d.severity === "hint" || to < line.from || from > line.to) return;
|
||||
const rank = (d.severity === "error" ? 0 : d.severity === "warning" ? 1 : 2) + (from <= caret && caret <= to ? 0 : 3);
|
||||
problems.push({ from, to, severity: d.severity, rank });
|
||||
});
|
||||
problems.sort((a, b) => a.rank - b.rank);
|
||||
try {
|
||||
for (const p of problems) {
|
||||
const fix = (await quickFixesAt(view, p.from, p.to))[0];
|
||||
if (view.state.doc !== state.doc) return;
|
||||
if (fix) return applyCodeAction(view, fix);
|
||||
}
|
||||
} catch (e) {
|
||||
reportLspError(view, e, true);
|
||||
return;
|
||||
}
|
||||
showHint(view, "No quick fixes available");
|
||||
}
|
||||
|
||||
export async function applyCodeAction(view: EditorView, action: CodeAction) {
|
||||
const doc = docOf(view);
|
||||
if (!doc) return;
|
||||
@@ -136,82 +95,11 @@ export async function applyCodeAction(view: EditorView, action: CodeAction) {
|
||||
showHint(view, action.disabledReason);
|
||||
return;
|
||||
}
|
||||
const before = view.state.doc;
|
||||
try {
|
||||
await lspRequest(() => commands.lspApplyCodeAction(doc.doc, action));
|
||||
} catch (e) {
|
||||
reportLspError(view, e, true);
|
||||
return;
|
||||
}
|
||||
if (!action.kind?.startsWith("source.organizeImports") && !action.kind?.startsWith("source.fixAll"))
|
||||
await reformatGenerated(view, before);
|
||||
}
|
||||
|
||||
/**
|
||||
* Code the server generated follows its own indentation (jdtls tabs,
|
||||
* tsserver 4 spaces); like IDEA, the lines an action inserted are reformatted
|
||||
* to the file's style.
|
||||
*/
|
||||
async function reformatGenerated(view: EditorView, before: Text) {
|
||||
for (let i = 0; i < 100 && view.state.doc === before; i++) await new Promise((r) => setTimeout(r, 20));
|
||||
// Bottom up, so the line numbers of the hunks above stay valid.
|
||||
for (const lines of changedLines(before, view.state.doc).reverse()) {
|
||||
if (lines.to - lines.from < 1) continue;
|
||||
const doc = view.state.doc;
|
||||
const shift = indentUnderBrace(doc, lines.from, lines.to, view.state.facet(indentUnit));
|
||||
// A server that generated code without its context formats ranges the same
|
||||
// way (back to column 0): its range formatting is skipped then.
|
||||
if (shift.length) view.dispatch({ changes: shift, userEvent: "format", scrollIntoView: false });
|
||||
else if (!(await formatLines(view, doc.line(lines.from).from, doc.line(lines.to).to)) && view.state.doc !== doc) return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated lines right under a `{` line but not indented past it (servers
|
||||
* that format the snippet on its own, kotlin-language-server): the block moves
|
||||
* one level in, keeping its own nesting. Never applies to indentation-based
|
||||
* languages, whose blocks don't open with `{`.
|
||||
*/
|
||||
export function indentUnderBrace(doc: Text, fromLine: number, toLine: number, unit: string): Array<{ from: number; insert: string }> {
|
||||
if (fromLine < 2) return [];
|
||||
const prev = doc.line(fromLine - 1).text;
|
||||
if (!prev.trimEnd().endsWith("{")) return [];
|
||||
const lead = (t: string) => t.slice(0, t.length - t.trimStart().length);
|
||||
const target = lead(prev) + unit;
|
||||
let first: string | null = null;
|
||||
for (let n = fromLine; n <= toLine && first === null; n++) if (doc.line(n).text.trim()) first = lead(doc.line(n).text);
|
||||
if (first === null || first.length > lead(prev).length || !target.startsWith(first)) return [];
|
||||
const extra = target.slice(first.length);
|
||||
const out: Array<{ from: number; insert: string }> = [];
|
||||
for (let n = fromLine; n <= toLine; n++) {
|
||||
const line = doc.line(n);
|
||||
if (line.text.trim()) out.push({ from: line.from, insert: extra });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1-based line spans of `after` that an edit changed, top to bottom: an added
|
||||
* import and the code using it are separate spans, so the user's code between
|
||||
* them is left alone.
|
||||
*/
|
||||
export function changedLines(before: Text, after: Text): Array<{ from: number; to: number }> {
|
||||
if (before.eq(after)) return [];
|
||||
const spans: Array<{ from: number; to: number }> = [];
|
||||
const a = before.toString();
|
||||
const b = after.toString();
|
||||
for (const c of diff(a, b)) {
|
||||
// Text inserted at a line's end or start (`{⏎ added`, `added⏎`) leaves that line as it was.
|
||||
const lead = b[c.fromB] === "\n" && (c.toA === c.fromA || a[c.fromA] === "\n");
|
||||
const trail = c.toB > c.fromB && b[c.toB - 1] === "\n" && (c.toA === c.fromA || a[c.toA - 1] === "\n");
|
||||
const from = after.lineAt(lead ? c.fromB + 1 : c.fromB).number;
|
||||
const end = trail ? c.toB - 1 : c.toB;
|
||||
const to = Math.max(from, after.lineAt(end).number);
|
||||
const last = spans[spans.length - 1];
|
||||
if (last && from <= last.to + 1) last.to = Math.max(last.to, to);
|
||||
else spans.push({ from, to });
|
||||
}
|
||||
return spans;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,17 +127,8 @@ export async function applyKindSilently(view: EditorView, kind: string): Promise
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorted, one action per title: servers can report the same action under two
|
||||
* kinds (jdtls: "Generate toString()" as quickassist and source.generate).
|
||||
*/
|
||||
export function listedCodeActions(actions: readonly CodeAction[]): CodeAction[] {
|
||||
const seen = new Set<string>();
|
||||
return sortCodeActions(actions).filter((a) => !seen.has(a.title) && !!seen.add(a.title));
|
||||
}
|
||||
|
||||
function actionItems(view: EditorView, actions: CodeAction[], resolved?: Map<CodeAction, Promise<CodeAction>>): ListPopupItem[] {
|
||||
return listedCodeActions(actions).map((a, i) => ({
|
||||
return sortCodeActions(actions).map((a, i) => ({
|
||||
id: `${i}`,
|
||||
label: a.title,
|
||||
icon: isQuickFix(a) ? "bulb-fix" : "bulb",
|
||||
@@ -338,7 +217,7 @@ export async function showIntentions(view: EditorView) {
|
||||
} catch (e) {
|
||||
failure = { error: e };
|
||||
}
|
||||
const sorted = listedCodeActions(actions);
|
||||
const sorted = sortCodeActions(actions);
|
||||
const resolved = new Map<CodeAction, Promise<CodeAction>>();
|
||||
const items = withInspectionControls(view, [...local, ...actionItems(view, sorted, resolved)]);
|
||||
if (!items.length) {
|
||||
@@ -426,16 +305,6 @@ function noActionReason(view: EditorView, none: string): string {
|
||||
// ---------------------------------------------------------------------------
|
||||
// Lightbulb
|
||||
|
||||
/**
|
||||
* Fixes and refactorings light the bulb; source actions (organize imports,
|
||||
* generate…) and server extras (gopls "Browse documentation") are offered on
|
||||
* almost every line and only appear in the ⌥↵ list.
|
||||
*/
|
||||
export function lightsBulb(a: CodeAction): boolean {
|
||||
const kind = a.kind ?? "";
|
||||
return !kind || kind === "quickassist" || /^(quickfix|refactor)(\.|$)/.test(kind);
|
||||
}
|
||||
|
||||
interface Bulb {
|
||||
line: number;
|
||||
quickFix: boolean;
|
||||
@@ -462,19 +331,11 @@ const bulbPlugin = ViewPlugin.fromClass(
|
||||
this.lookup();
|
||||
}
|
||||
update(u: ViewUpdate) {
|
||||
if (u.docChanged || u.selectionSet || (u.focusChanged && u.view.hasFocus)) this.lookup();
|
||||
else if (u.focusChanged) {
|
||||
this.lookup.cancel();
|
||||
// A blur dispatched from inside the update is not allowed.
|
||||
queueMicrotask(() => {
|
||||
if (!this.view.hasFocus && this.view.state.field(bulbField, false)) this.view.dispatch({ effects: setBulb.of(null) });
|
||||
});
|
||||
}
|
||||
if (u.docChanged || u.selectionSet) this.lookup();
|
||||
}
|
||||
async run() {
|
||||
const doc = docOf(this.view);
|
||||
// As in IDEA, only the focused editor shows the bulb.
|
||||
if (!doc || doc.readOnly || !this.view.dom.isConnected || !this.view.hasFocus) return;
|
||||
if (!doc || doc.readOnly || !this.view.dom.isConnected) return;
|
||||
const state = this.view.state;
|
||||
const typoFix = spellingIntentions(this.view).length > 0;
|
||||
const local = typoFix || contributedIntentions(this.view).length > 0;
|
||||
@@ -489,9 +350,9 @@ const bulbPlugin = ViewPlugin.fromClass(
|
||||
if (!local) return;
|
||||
}
|
||||
}
|
||||
if (this.view.state.doc !== state.doc || !this.view.state.selection.eq(state.selection) || !this.view.hasFocus) return;
|
||||
if (this.view.state.doc !== state.doc || !this.view.state.selection.eq(state.selection)) return;
|
||||
const line = state.doc.lineAt(state.selection.main.head).number;
|
||||
const any = actions.some(lightsBulb) || local;
|
||||
const any = actions.length > 0 || local;
|
||||
this.view.dispatch({
|
||||
effects: setBulb.of(any ? { line, quickFix: typoFix || actions.some(isQuickFix) } : null),
|
||||
});
|
||||
@@ -504,20 +365,21 @@ const bulbPlugin = ViewPlugin.fromClass(
|
||||
|
||||
/**
|
||||
* New-UI bulb: floats at the start of the text on the caret line, or on the
|
||||
* line below / above when the caret line's text starts at the left edge; in
|
||||
* the gutter when none of them has room.
|
||||
* line below / above when the caret line's text starts at the left edge.
|
||||
*/
|
||||
const BULB_COLUMNS = 3;
|
||||
|
||||
export function bulbLine(state: EditorView["state"], line: number): { line: number; gutter: boolean } {
|
||||
function bulbLine(state: EditorView["state"], line: number): number {
|
||||
const doc = state.doc;
|
||||
const free = (n: number) => {
|
||||
if (n < 1 || n > doc.lines) return false;
|
||||
const text = doc.line(n).text;
|
||||
return text.length - text.trimStart().length >= BULB_COLUMNS || !text.trim();
|
||||
};
|
||||
for (const n of [line, line + 1, line - 1]) if (free(n)) return { line: n, gutter: false };
|
||||
return { line, gutter: true };
|
||||
if (free(line)) return line;
|
||||
if (free(line + 1)) return line + 1;
|
||||
if (free(line - 1)) return line - 1;
|
||||
return line;
|
||||
}
|
||||
|
||||
class FloatingBulb {
|
||||
@@ -531,7 +393,6 @@ class FloatingBulb {
|
||||
this.dom.setAttribute("aria-label", "Show intentions");
|
||||
this.dom.style.display = "none";
|
||||
this.dom.appendChild(iconNode("bulb", 16));
|
||||
this.dom.appendChild(iconNode("bulb-fix", 16, "cm-lsp-bulb-fix-icon"));
|
||||
this.dom.addEventListener("mousedown", (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@@ -559,24 +420,18 @@ class FloatingBulb {
|
||||
this.view.requestMeasure({
|
||||
key: this,
|
||||
read: (view) => {
|
||||
const at = bulbLine(view.state, bulb.line);
|
||||
const line = view.state.doc.line(at.line);
|
||||
const line = view.state.doc.line(bulbLine(view.state, bulb.line));
|
||||
const block = view.lineBlockAt(line.from);
|
||||
const content = view.contentDOM.getBoundingClientRect();
|
||||
const scroller = view.scrollDOM.getBoundingClientRect();
|
||||
// The text row: the line's block also holds inline widgets above it (code vision).
|
||||
const coords = view.coordsAtPos(line.from, 1);
|
||||
const block = view.lineBlockAt(line.from);
|
||||
const textTop = coords ? coords.top - scroller.top : block.top + view.documentTop - scroller.top;
|
||||
return {
|
||||
top: textTop + view.scrollDOM.scrollTop,
|
||||
left: content.left - scroller.left + view.scrollDOM.scrollLeft + (at.gutter ? -20 : 4),
|
||||
height: coords ? coords.bottom - coords.top : block.height,
|
||||
gutter: at.gutter,
|
||||
top: block.top + (view.documentTop - scroller.top) + view.scrollDOM.scrollTop,
|
||||
left: content.left - scroller.left + view.scrollDOM.scrollLeft + 4,
|
||||
height: block.height,
|
||||
};
|
||||
},
|
||||
write: ({ top, left, height, gutter }) => {
|
||||
write: ({ top, left, height }) => {
|
||||
this.dom.style.display = "";
|
||||
this.dom.classList.toggle("cm-lsp-bulb-gutter", gutter);
|
||||
this.dom.style.top = `${top}px`;
|
||||
this.dom.style.left = `${left}px`;
|
||||
this.dom.style.height = `${Math.min(height, this.view.defaultLineHeight)}px`;
|
||||
@@ -592,5 +447,5 @@ class FloatingBulb {
|
||||
const floatingBulb = ViewPlugin.fromClass(FloatingBulb);
|
||||
|
||||
export function intentionsExtension(): Extension {
|
||||
return [bulbField, bulbPlugin, floatingBulb, intentionProviders.of(pythonMemberIntentions)];
|
||||
return [bulbField, bulbPlugin, floatingBulb];
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { EditorState } from "@codemirror/state";
|
||||
import { EditorView } from "@codemirror/view";
|
||||
import { _addEditor, _removeEditor, documentSynced, type EditorDocContext } from "@/editor/api";
|
||||
|
||||
vi.mock("@/platform/ipc", async (orig) => {
|
||||
const actual = await orig<typeof import("@/platform/ipc")>();
|
||||
return { ...actual, isTauri: () => true };
|
||||
});
|
||||
|
||||
const { lspRequest } = await import("./lsp");
|
||||
|
||||
describe("lspRequest", () => {
|
||||
it("waits until open editors' edits reached the backend", async () => {
|
||||
let synced!: () => void;
|
||||
const pending = new Promise<void>((r) => (synced = r));
|
||||
const view = new EditorView({ state: EditorState.create({ extensions: documentSynced.of(() => pending) }) });
|
||||
const handle = { view, ctx: {} as EditorDocContext };
|
||||
_addEditor(handle);
|
||||
const run = vi.fn(async () => ({ status: "ok" as const, data: 1 }));
|
||||
const result = lspRequest(run);
|
||||
await Promise.resolve();
|
||||
expect(run).not.toHaveBeenCalled();
|
||||
synced();
|
||||
expect(await result).toBe(1);
|
||||
_removeEditor(handle);
|
||||
view.destroy();
|
||||
});
|
||||
});
|
||||