дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-28 21:42:27 +02:00
Порівняти коміти
18
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
ba9ab7c16d | ||
|
|
a0b9fba2f2 | ||
|
|
1f6a3bbf0d | ||
|
|
5265455313 | ||
|
|
64cc72ba2e | ||
|
|
b79dbae83f | ||
|
|
e909c50fe4 | ||
|
|
da7125a944 | ||
|
|
e54e309d61 | ||
|
|
8c3371212c | ||
|
|
e08531c458 | ||
|
|
9c9e0e59cb | ||
|
|
1d5d33cf76 | ||
|
|
2bbba9b945 | ||
|
|
14f143b703 | ||
|
|
f2a372428c | ||
|
|
89524bd583 | ||
|
|
f90d94538d |
No files matched your search
@@ -30,6 +30,67 @@ pub(super) fn transcript(config_dir: &Path, cwd: &Path, id: &str) -> PathBuf {
|
||||
.unwrap_or(direct)
|
||||
}
|
||||
|
||||
/// Brings session `id` into `config_dir` when it is missing there but another Claude Code
|
||||
/// configuration directory beside it (`~/.claude`, `~/.claude-work`...) has it: switching
|
||||
/// `CLAUDE_CONFIG_DIR` (another account) would otherwise lose every earlier conversation.
|
||||
/// Copies the transcript and its folder (subagents, tool results) under the same project
|
||||
/// directory name. Returns whether the session is in `config_dir` now.
|
||||
pub(super) fn adopt(config_dir: &Path, cwd: &Path, id: &str) -> bool {
|
||||
if transcript(config_dir, cwd, id).exists() {
|
||||
return true;
|
||||
}
|
||||
let file = format!("{id}.jsonl");
|
||||
let home = std::env::var_os("HOME").or_else(|| std::env::var_os("USERPROFILE")).map(PathBuf::from);
|
||||
let mut homes: Vec<PathBuf> = config_dir
|
||||
.parent()
|
||||
.into_iter()
|
||||
.chain(home.as_deref())
|
||||
.flat_map(|dir| std::fs::read_dir(dir).into_iter().flatten().flatten())
|
||||
.filter(|d| d.file_name().to_string_lossy().starts_with(".claude"))
|
||||
.map(|d| d.path())
|
||||
.filter(|p| p != config_dir && p.join("projects").is_dir())
|
||||
.collect();
|
||||
homes.sort();
|
||||
homes.dedup();
|
||||
let found = homes.iter().find_map(|other| {
|
||||
let projects = other.join("projects");
|
||||
let direct = projects.join(escape(cwd));
|
||||
std::iter::once(direct.clone())
|
||||
.chain(std::fs::read_dir(&projects).into_iter().flatten().flatten().map(|d| d.path()))
|
||||
.find(|dir| dir.join(&file).is_file())
|
||||
});
|
||||
let Some(source) = found else { return false };
|
||||
let Some(name) = source.file_name() else { return false };
|
||||
let target = config_dir.join("projects").join(name);
|
||||
let copied = std::fs::create_dir_all(&target)
|
||||
.and_then(|()| copy_tree(&source.join(id), &target.join(id)))
|
||||
.and_then(|()| std::fs::copy(source.join(&file), target.join(&file)).map(drop));
|
||||
match copied {
|
||||
Ok(()) => true,
|
||||
Err(e) => {
|
||||
tracing::warn!("claude session {id}: copying it from {}: {e}", source.display());
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn copy_tree(from: &Path, to: &Path) -> std::io::Result<()> {
|
||||
if !from.is_dir() {
|
||||
return Ok(());
|
||||
}
|
||||
std::fs::create_dir_all(to)?;
|
||||
for entry in std::fs::read_dir(from)? {
|
||||
let entry = entry?;
|
||||
let dest = to.join(entry.file_name());
|
||||
if entry.file_type()?.is_dir() {
|
||||
copy_tree(&entry.path(), &dest)?;
|
||||
} else if !dest.exists() {
|
||||
std::fs::copy(entry.path(), dest)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The project directory name Claude Code uses for `cwd`.
|
||||
pub(crate) fn escape(cwd: &Path) -> String {
|
||||
cwd.to_string_lossy().chars().map(|c| if c.is_ascii_alphanumeric() { c } else { '-' }).collect()
|
||||
@@ -207,6 +268,26 @@ mod tests {
|
||||
json!({"type": "assistant", "uuid": id, "parentUuid": parent, "message": {"role": "assistant", "content": content}})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_session_from_another_config_dir_is_copied_in() {
|
||||
let root = tempfile::tempdir().unwrap();
|
||||
let (old, new) = (root.path().join(".claude-2"), root.path().join(".claude-3"));
|
||||
let cwd = Path::new("/work/app");
|
||||
let project = old.join("projects").join(escape(cwd));
|
||||
std::fs::create_dir_all(project.join("s1/subagents")).unwrap();
|
||||
std::fs::write(project.join("s1.jsonl"), "{}\n").unwrap();
|
||||
std::fs::write(project.join("s1/subagents/a.jsonl"), "{}\n").unwrap();
|
||||
std::fs::create_dir_all(new.join("projects")).unwrap();
|
||||
|
||||
assert!(!adopt(&new, cwd, "missing"));
|
||||
assert!(adopt(&new, cwd, "s1"));
|
||||
let copied = new.join("projects").join(escape(cwd));
|
||||
assert_eq!(transcript(&new, cwd, "s1"), copied.join("s1.jsonl"));
|
||||
assert!(copied.join("s1/subagents/a.jsonl").is_file());
|
||||
assert!(project.join("s1.jsonl").is_file(), "the original stays");
|
||||
assert!(adopt(&new, cwd, "s1"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_newest_branch_is_the_conversation() {
|
||||
let entries = vec![
|
||||
|
||||
@@ -334,6 +334,12 @@ impl Shim {
|
||||
Some(history::transcript(self.config.config_dir.as_deref()?, cwd, id))
|
||||
}
|
||||
|
||||
/// Whether session `id` is in the configuration directory, copied there from another one
|
||||
/// if need be (see [`history::adopt`]).
|
||||
fn adopt(&self, cwd: &Path, id: &str) -> bool {
|
||||
self.config.config_dir.as_deref().is_some_and(|dir| history::adopt(dir, cwd, id))
|
||||
}
|
||||
|
||||
/// The conversation a session started with `start` begins with.
|
||||
fn base_chain(&self, cwd: &Path, start: &Start) -> Result<Vec<Value>, String> {
|
||||
let (id, at) = match start {
|
||||
@@ -435,10 +441,13 @@ impl Shim {
|
||||
let id = params.get("sessionId").and_then(Value::as_str).ok_or_else(|| invalid("no sessionId"))?;
|
||||
let cwd = self.cwd_of(¶ms);
|
||||
let (start, pending) = match self.load_pending(id) {
|
||||
Some(s) => (s, true),
|
||||
None if self.transcript(&cwd, id).is_some_and(|p| p.exists()) => {
|
||||
(Start::Resume { id: id.to_owned(), at: None }, false)
|
||||
Some(s) => {
|
||||
if let Start::Resume { id: from, .. } | Start::Fork { from, .. } = &s {
|
||||
self.adopt(&cwd, from);
|
||||
}
|
||||
(s, true)
|
||||
}
|
||||
None if self.adopt(&cwd, id) => (Start::Resume { id: id.to_owned(), at: None }, false),
|
||||
None => return Err(invalid(format!("no Claude Code session {id} in {}", cwd.display()))),
|
||||
};
|
||||
let chain = self.base_chain(&cwd, &start).map_err(internal)?;
|
||||
|
||||
@@ -34,7 +34,7 @@ use std::path::{Component, Path, PathBuf};
|
||||
|
||||
pub const MANIFEST_FILE: &str = "plugin.toml";
|
||||
/// The plugin API (engine) version this host implements.
|
||||
pub const ENGINE_VERSION: &str = "1.17.0";
|
||||
pub const ENGINE_VERSION: &str = "1.18.0";
|
||||
/// The 0.1 API, still accepted for contribution-only packages and 0.1 components.
|
||||
pub const LEGACY_API: &str = "0.1";
|
||||
/// Marketplace categories, in the order they are shown.
|
||||
@@ -168,6 +168,7 @@ pub const EVENT_KINDS: &[&str] = &[
|
||||
"action-performed",
|
||||
"vcs-changed",
|
||||
"problems-changed",
|
||||
"project-closed",
|
||||
];
|
||||
|
||||
impl std::fmt::Display for ActivationEvent {
|
||||
@@ -403,6 +404,9 @@ impl Manifest {
|
||||
if matches!(event, ActivationEvent::Event(kind) if kind == "files-changed") {
|
||||
self.needs_api("`on-event:files-changed`", 3)?;
|
||||
}
|
||||
if matches!(event, ActivationEvent::Event(kind) if kind == "project-closed") {
|
||||
self.needs_api("`on-event:project-closed`", 18)?;
|
||||
}
|
||||
if !seen.insert(event) {
|
||||
return Err(format!("duplicate activation event {event}"));
|
||||
}
|
||||
@@ -962,4 +966,19 @@ mod net_ask_api_tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_closed_event_requires_api_1_18() {
|
||||
for engine in ["^1.17", "^1.18"] {
|
||||
let manifest = format!(
|
||||
"id = 'test'\nname = 'Test'\nversion = '0.1.0'\nwasm = 'plugin.wasm'\nengines.openidea = '{engine}'\nactivation = [\"on-event:project-closed\"]\n"
|
||||
);
|
||||
let parsed = Manifest::parse(&manifest);
|
||||
if engine == "^1.18" {
|
||||
parsed.unwrap();
|
||||
} else {
|
||||
assert!(parsed.unwrap_err().contains("new in plugin API 1.18"), "{engine}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -386,10 +386,12 @@ impl Host {
|
||||
// After the cancels: a capture or open still running then discards what it registers.
|
||||
ops::heap::close_window_snapshots(self, window);
|
||||
let project = self.projects.write().remove(window)?;
|
||||
if self.windows_for_root(&project.root).is_empty()
|
||||
&& let Some(plugins) = self.plugin_host()
|
||||
{
|
||||
plugins.withdraw_project_run_targets(&project.root);
|
||||
if let Some(plugins) = self.plugin_host() {
|
||||
if self.windows_for_root(&project.root).is_empty() {
|
||||
plugins.project_closed(&project.root, window);
|
||||
} else {
|
||||
plugins.forget_client(window);
|
||||
}
|
||||
}
|
||||
project.files_events_active.store(false, std::sync::atomic::Ordering::Release);
|
||||
project.plugin_diagnostics.close();
|
||||
|
||||
@@ -446,9 +446,15 @@ pub fn stop_run() -> Tool {
|
||||
"Stops the running command of an agent tab, the way the Run tool window's Stop does: it asks the \
|
||||
process tree to exit and, with `force`, kills it. Waits up to `timeout` milliseconds (default {STOP_TIMEOUT_MS}) \
|
||||
for it to end and returns the tab's status (`stoppedByAgent` once it ended). A process that ignores the request \
|
||||
keeps `stopping`: call again with `force`. The tab stays open with its output."
|
||||
keeps `stopping`: call again with `force`. The tab stays open with its output.
|
||||
|
||||
Pass `runId` instead of `name` to stop a run `execute_run_configuration` started and left running; the result is \
|
||||
its `state` (`stopped` or `stopping`) and `exitCode` when it has one."
|
||||
),
|
||||
|call| async move {
|
||||
if let Some(id) = call.opt_i64("runId")? {
|
||||
return stop_configuration_run(&call, id).await;
|
||||
}
|
||||
let run = find(&call)?;
|
||||
let id = run.live_process().ok_or_else(|| IdeError::invalid(format!("`{}` is not running", run.name)))?;
|
||||
let force = call.flag("force", false)?;
|
||||
@@ -467,11 +473,48 @@ keeps `stopping`: call again with `force`. The tab stays open with its output."
|
||||
},
|
||||
)
|
||||
.write()
|
||||
.param(Param::required("name", ParamType::String, NAME))
|
||||
.param(Param::optional("name", ParamType::String, NAME))
|
||||
.param(Param::optional("runId", ParamType::Integer, "`runId` from `execute_run_configuration`, instead of `name`"))
|
||||
.param(Param::optional("force", ParamType::Boolean, "Kill the process tree instead of asking it to exit"))
|
||||
.param(Param::optional("timeout", ParamType::Integer, "Milliseconds to wait for the command to end"))
|
||||
}
|
||||
|
||||
/// `stop_run` for a run `execute_run_configuration` started (#6127).
|
||||
async fn stop_configuration_run(call: &Call, raw: i64) -> IdeResult<Output> {
|
||||
use super::configs::{forget_started, run_exit, started_by_mcp, wait_exit};
|
||||
if call.opt_str("name")?.is_some() {
|
||||
return Err(IdeError::invalid("pass either `name` or `runId`, not both"));
|
||||
}
|
||||
let id = u32::try_from(raw)
|
||||
.ok()
|
||||
.map(ide_core::RunId)
|
||||
.filter(|id| started_by_mcp(*id))
|
||||
.ok_or_else(|| IdeError::not_found(format!("no run {raw} started by execute_run_configuration")))?;
|
||||
let host = call.host();
|
||||
let deadline = std::time::Instant::now() + timeout(call, STOP_TIMEOUT_MS)?;
|
||||
let exit = match run_exit(&host, id) {
|
||||
Some(exit) => Some(exit),
|
||||
None => {
|
||||
crate::ops::run::run_stop(&host, call.window(), id)?;
|
||||
if call.flag("force", false)? {
|
||||
// A second Stop kills the tree.
|
||||
crate::ops::run::run_stop(&host, call.window(), id)?;
|
||||
}
|
||||
wait_exit(call, id, Some(deadline)).await?
|
||||
}
|
||||
};
|
||||
if exit.is_some() {
|
||||
forget_started(id);
|
||||
}
|
||||
let mut out = Map::new();
|
||||
out.insert("runId".into(), id.0.into());
|
||||
out.insert("state".into(), if exit.is_some() { "stopped" } else { "stopping" }.into());
|
||||
if let Some(Some(code)) = exit {
|
||||
out.insert("exitCode".into(), code.into());
|
||||
}
|
||||
Output::json(Value::Object(out))
|
||||
}
|
||||
|
||||
pub fn tools() -> Vec<Tool> {
|
||||
vec![run_command(), wait_for_run(), read_run_output(), get_run_status(), send_run_input(), stop_run(), list_runs()]
|
||||
}
|
||||
|
||||
@@ -15,8 +15,9 @@ use ide_core::{IdeError, IdeResult, RunId, Severity};
|
||||
use ide_run::{OutputChunk, RunConfig};
|
||||
use parking_lot::Mutex;
|
||||
use serde_json::{Map, Value, json};
|
||||
use std::collections::HashSet;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, LazyLock};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
const DEFAULT_TIMEOUT_MS: usize = 10_000;
|
||||
@@ -281,7 +282,19 @@ workingDirectory, envs).",
|
||||
}
|
||||
|
||||
/// Polls how run `id` ended: `None` while running, else its exit code (if known).
|
||||
fn run_exit(host: &crate::Host, id: RunId) -> Option<Option<i32>> {
|
||||
/// The runs `execute_run_configuration` started: `stop_run` takes their `runId`, and only theirs,
|
||||
/// not the user's own runs.
|
||||
static STARTED: LazyLock<Mutex<HashSet<RunId>>> = LazyLock::new(Default::default);
|
||||
|
||||
pub(super) fn started_by_mcp(id: RunId) -> bool {
|
||||
STARTED.lock().contains(&id)
|
||||
}
|
||||
|
||||
pub(super) fn forget_started(id: RunId) {
|
||||
STARTED.lock().remove(&id);
|
||||
}
|
||||
|
||||
pub(super) fn run_exit(host: &crate::Host, id: RunId) -> Option<Option<i32>> {
|
||||
match host.processes.exit_code(id) {
|
||||
Ok(exit) => exit,
|
||||
// Remote (SSH) runs, or a finished run already forgotten: the run list knows whether it runs.
|
||||
@@ -294,7 +307,7 @@ fn run_exit(host: &crate::Host, id: RunId) -> Option<Option<i32>> {
|
||||
|
||||
/// Waits for run `id` to exit, until `deadline`: `None` when it is still running. Cancelling
|
||||
/// the call stops the run.
|
||||
async fn wait_exit(call: &Call, id: RunId, deadline: Option<Instant>) -> IdeResult<Option<Option<i32>>> {
|
||||
pub(super) async fn wait_exit(call: &Call, id: RunId, deadline: Option<Instant>) -> IdeResult<Option<Option<i32>>> {
|
||||
let host = call.host();
|
||||
loop {
|
||||
if let Some(exit) = run_exit(&host, id) {
|
||||
@@ -741,7 +754,8 @@ Behavior:
|
||||
Returns the execution result including current output snapshot, optional exit code, and optional `fullOutputPath`.
|
||||
In OpenIDEA the user is asked first for every call; `programArguments` replace the configuration's \
|
||||
arguments (appended to a command that is one shell line, such as `npm run dev`); the run does not appear in the Run \
|
||||
tool window; output files are private and deleted after a day.",
|
||||
tool window: while it is still running, the result carries `runId`, which `stop_run` stops; output files are private \
|
||||
and deleted after a day.",
|
||||
|call| async move {
|
||||
let target = execution_target(
|
||||
call.opt_str("configurationName")?,
|
||||
@@ -807,14 +821,24 @@ one by one",
|
||||
}
|
||||
};
|
||||
|
||||
STARTED.lock().insert(info.id);
|
||||
let exit = match limit {
|
||||
Some(limit) if !limit.is_zero() => wait_exit(&call, info.id, Some(Instant::now() + limit)).await?,
|
||||
_ => None,
|
||||
};
|
||||
if exit.is_some() {
|
||||
STARTED.lock().remove(&info.id);
|
||||
}
|
||||
let c = collector.lock();
|
||||
let mut result = Map::new();
|
||||
if let Some(Some(code)) = exit {
|
||||
result.insert("exitCode".into(), code.into());
|
||||
match exit {
|
||||
Some(Some(code)) => {
|
||||
result.insert("exitCode".into(), code.into());
|
||||
}
|
||||
Some(None) => {}
|
||||
None => {
|
||||
result.insert("runId".into(), info.id.0.into());
|
||||
}
|
||||
}
|
||||
result.insert("output".into(), c.preview().into());
|
||||
// An exited run whose whole output is in `output` needs no file.
|
||||
|
||||
@@ -81,8 +81,8 @@ pub async fn doc_set_line_ending(host: &Host, window: &str, doc: DocId, line_end
|
||||
|
||||
/// Structure view: LSP document symbols when available (with tree-sitter
|
||||
/// visibility and type-alias kinds), tree-sitter otherwise.
|
||||
/// Tree-sitter answers come from the per-document tree cache (incremental
|
||||
/// re-parse); large documents get no syntax structure.
|
||||
/// Normal files reuse the per-document tree cache. Large Markdown files use
|
||||
/// the syntax parser's size limit for heading outlines.
|
||||
#[command(trust = always)]
|
||||
pub async fn doc_outline(host: &Host, window: &str, doc: DocId) -> IdeResult<Vec<OutlineItem>> {
|
||||
let project = host.project(window)?;
|
||||
@@ -118,7 +118,7 @@ pub async fn doc_outline(host: &Host, window: &str, doc: DocId) -> IdeResult<Vec
|
||||
}
|
||||
items
|
||||
}
|
||||
None if snap.large => Vec::new(),
|
||||
None if snap.large && snap.language.as_str() != "markdown" => Vec::new(),
|
||||
None => syntax(),
|
||||
})
|
||||
})
|
||||
|
||||
@@ -697,6 +697,7 @@ pub(super) struct Shared {
|
||||
pub subscriptions: Mutex<super::event_paths::Subscriptions>,
|
||||
/// plugin → files it shows problems for, withdrawn when it stops.
|
||||
diagnostics: Mutex<HashMap<String, BTreeSet<PathBuf>>>,
|
||||
project_generations: Mutex<HashMap<PathBuf, u64>>,
|
||||
pub secrets: RwLock<Arc<dyn SecretStore>>,
|
||||
/// (plugin, `process:` capability) → the approved program.
|
||||
pub pins: Arc<RwLock<HashMap<(String, String), ProgramPin>>>,
|
||||
@@ -774,10 +775,33 @@ impl Shared {
|
||||
closed_clients: Mutex::default(),
|
||||
subscriptions: Mutex::default(),
|
||||
diagnostics: Mutex::default(),
|
||||
project_generations: Mutex::default(),
|
||||
log_tabs: Mutex::default(),
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn project_generation(&self, root: &Path) -> Result<u64, HostError> {
|
||||
let workspace = self.workspace().ok_or(HostError::Cancelled)?;
|
||||
if !workspace.projects().iter().any(|r| r == root) {
|
||||
return Err(HostError::NotFound("project is not open".into()));
|
||||
}
|
||||
let mut gens = self.project_generations.lock();
|
||||
Ok(*gens.entry(root.to_path_buf()).or_insert(1))
|
||||
}
|
||||
|
||||
pub(super) fn bump_project_generation(&self, root: &Path) -> u64 {
|
||||
let mut gens = self.project_generations.lock();
|
||||
let cur = gens.entry(root.to_path_buf()).or_insert(1);
|
||||
*cur = cur.saturating_add(1);
|
||||
*cur
|
||||
}
|
||||
|
||||
/// Moves a closed project's generation on rather than forgetting it, so a handle
|
||||
/// taken before the close stays stale if the project is opened again.
|
||||
pub(super) fn close_project_generation(&self, root: &Path) {
|
||||
self.bump_project_generation(root);
|
||||
}
|
||||
|
||||
pub(super) fn workspace(&self) -> Option<Arc<dyn PluginWorkspace>> {
|
||||
self.workspace.read().clone()
|
||||
}
|
||||
@@ -1561,8 +1585,13 @@ impl HostApi for PluginApi {
|
||||
}
|
||||
}
|
||||
|
||||
fn register_run_target(&self, root: &Path, target: ide_plugin::PluginRunTarget) -> Result<(), HostError> {
|
||||
self.register_target(root, target)
|
||||
fn register_run_target(
|
||||
&self,
|
||||
root: &Path,
|
||||
target: ide_plugin::PluginRunTarget,
|
||||
generation: Option<u64>,
|
||||
) -> Result<(), HostError> {
|
||||
self.register_target(root, target, generation)
|
||||
}
|
||||
fn unregister_run_target(&self, root: &Path, id: &str) {
|
||||
self.unregister_target(root, id);
|
||||
@@ -2196,7 +2225,10 @@ impl HostApi for PluginApi {
|
||||
|
||||
fn reveal_view(&self, client: Option<&str>, view: &str) -> Result<(), HostError> {
|
||||
let client = from_window(client, "reveal a view")?;
|
||||
let declared = self.shared.ui.items(super::ui_points::VIEWS, Some(self.id())).iter().any(|i| i.key == view);
|
||||
// A tool window comes to the front; a dialog (API 1.18) opens.
|
||||
let declared = [super::ui_points::VIEWS, super::ui_points::DIALOGS]
|
||||
.into_iter()
|
||||
.any(|point| self.shared.ui.items(point, Some(self.id())).iter().any(|i| i.key == view));
|
||||
if !declared {
|
||||
return Err(HostError::NotFound(format!("the plugin declares no view {view:?}")));
|
||||
}
|
||||
@@ -2932,14 +2964,32 @@ impl HostApi for PluginApi {
|
||||
}
|
||||
}
|
||||
|
||||
fn subscribe_paths(&self, kind: &str, globs: Vec<String>) -> Result<(), HostError> {
|
||||
let filter = super::event_paths::PathFilter::new(kind, globs)?;
|
||||
fn subscribe_paths_with_options(
|
||||
&self,
|
||||
kind: &str,
|
||||
globs: Vec<String>,
|
||||
debounce_ms: Option<u32>,
|
||||
) -> Result<(), HostError> {
|
||||
let debounce = match debounce_ms {
|
||||
Some(ms) if ms > 60_000 => return Err(HostError::Invalid("debounce must not exceed 60000 ms".into())),
|
||||
Some(ms) => Some(Duration::from_millis(ms as u64)),
|
||||
None => None,
|
||||
};
|
||||
let filter = super::event_paths::PathFilter::with_debounce(kind, globs, debounce)?;
|
||||
if self.shared.subscriptions.lock().set_paths(self.id(), kind, filter) {
|
||||
self.shared.sink.emit(None, PluginEvent::SubscriptionsChanged);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn subscribe_paths(&self, kind: &str, globs: Vec<String>) -> Result<(), HostError> {
|
||||
self.subscribe_paths_with_options(kind, globs, None)
|
||||
}
|
||||
|
||||
fn project_generation(&self, root: &Path) -> Result<u64, HostError> {
|
||||
self.shared.project_generation(root)
|
||||
}
|
||||
|
||||
fn unsubscribe(&self, kind: &str) {
|
||||
if self.shared.subscriptions.lock().unsubscribe(self.id(), kind) {
|
||||
self.shared.sink.emit(None, PluginEvent::SubscriptionsChanged);
|
||||
|
||||
@@ -17,11 +17,21 @@ pub(super) struct Subscriptions {
|
||||
#[derive(Clone)]
|
||||
pub(super) struct PathFilter {
|
||||
pub globs: Vec<String>,
|
||||
pub debounce: Option<std::time::Duration>,
|
||||
matchers: Vec<GlobMatcher>,
|
||||
}
|
||||
|
||||
impl PathFilter {
|
||||
#[allow(dead_code)]
|
||||
pub fn new(kind: &str, globs: Vec<String>) -> Result<Self, HostError> {
|
||||
Self::with_debounce(kind, globs, None)
|
||||
}
|
||||
|
||||
pub fn with_debounce(
|
||||
kind: &str,
|
||||
globs: Vec<String>,
|
||||
debounce: Option<std::time::Duration>,
|
||||
) -> Result<Self, HostError> {
|
||||
if !matches!(kind, "file-opened" | "file-saved" | "files-changed" | "document-changed") {
|
||||
return Err(HostError::Invalid(
|
||||
"subscribe-paths supports file-opened, file-saved, files-changed and document-changed".into(),
|
||||
@@ -53,7 +63,7 @@ impl PathFilter {
|
||||
.compile_matcher(),
|
||||
);
|
||||
}
|
||||
Ok(Self { globs, matchers })
|
||||
Ok(Self { globs, debounce, matchers })
|
||||
}
|
||||
|
||||
pub fn matches(&self, root: &Path, path: &Path) -> bool {
|
||||
@@ -78,7 +88,7 @@ impl Subscriptions {
|
||||
changed = self.kinds.entry(plugin.to_owned()).or_default().insert(kind);
|
||||
}
|
||||
let previous = self.paths.entry(plugin.to_owned()).or_default().insert(kind.to_owned(), filter.clone());
|
||||
previous.is_none_or(|old| old.globs != filter.globs) | changed
|
||||
previous.is_none_or(|old| old.globs != filter.globs || old.debounce != filter.debounce) | changed
|
||||
}
|
||||
pub fn unsubscribe(&mut self, plugin: &str, kind: &str) -> bool {
|
||||
let removed = self.paths.get_mut(plugin).is_some_and(|filters| filters.remove(kind).is_some());
|
||||
@@ -120,6 +130,8 @@ impl PluginHost {
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
let batch = ide_plugin::FilesChanged {
|
||||
project: batch.project.clone(),
|
||||
generation: batch.generation,
|
||||
created: paths(&batch.created),
|
||||
modified: paths(&batch.modified),
|
||||
removed: paths(&batch.removed),
|
||||
|
||||
@@ -244,12 +244,16 @@ impl PluginHost {
|
||||
if self.shared.client_closed(client) {
|
||||
return;
|
||||
}
|
||||
self.queues
|
||||
.lock()
|
||||
.entry((plugin.into(), Some(client.into())))
|
||||
.or_insert_with(|| EventQueue { since: Instant::now(), events: Vec::new(), files_source: None })
|
||||
.events
|
||||
.push(event);
|
||||
let now = Instant::now();
|
||||
let mut queues = self.queues.lock();
|
||||
let queue = queues.entry((plugin.into(), Some(client.into()))).or_insert_with(|| EventQueue {
|
||||
since: now,
|
||||
last_event: now,
|
||||
events: Vec::new(),
|
||||
files_source: None,
|
||||
});
|
||||
queue.last_event = now;
|
||||
queue.events.push(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,9 @@ pub(super) fn append(events: &mut Vec<WorkbenchEvent>, incoming: Vec<WorkbenchEv
|
||||
paths.insert(path.clone(), kind);
|
||||
}
|
||||
}
|
||||
*previous = FilesChanged::default();
|
||||
let project = batch.project.clone().or_else(|| previous.project.clone());
|
||||
let generation = batch.generation.or(previous.generation);
|
||||
*previous = FilesChanged { project, generation, ..Default::default() };
|
||||
for (path, kind) in paths {
|
||||
match kind {
|
||||
Created => previous.created.push(path),
|
||||
@@ -88,14 +90,15 @@ impl PluginHost {
|
||||
}
|
||||
let paths =
|
||||
|paths: &[PathBuf]| paths.iter().filter(|p| p.starts_with(root)).map(|p| to_ipc(p)).collect::<Vec<_>>();
|
||||
let batch = FilesChanged {
|
||||
created: paths(&batch.created),
|
||||
modified: paths(&batch.modified),
|
||||
removed: paths(&batch.removed),
|
||||
};
|
||||
if batch.created.is_empty() && batch.modified.is_empty() && batch.removed.is_empty() {
|
||||
let created = paths(&batch.created);
|
||||
let modified = paths(&batch.modified);
|
||||
let removed = paths(&batch.removed);
|
||||
if created.is_empty() && modified.is_empty() && removed.is_empty() {
|
||||
return;
|
||||
}
|
||||
let generation = self.shared.bump_project_generation(root);
|
||||
let batch =
|
||||
FilesChanged { project: Some(to_ipc(root)), generation: Some(generation), created, modified, removed };
|
||||
self.post_events_from(
|
||||
Some(client),
|
||||
vec![WorkbenchEvent::FilesChanged(batch)],
|
||||
@@ -189,7 +192,15 @@ mod tests {
|
||||
let queues = host.queues.lock();
|
||||
let queue = queues.values().next().expect("new session queue");
|
||||
assert!(queue.files_source.as_ref().unwrap().same(&Source { active: Arc::downgrade(&new) }));
|
||||
assert_eq!(queue.events, [delta(0, &to_ipc(&root.join("new.rs")))]);
|
||||
assert_eq!(
|
||||
queue.events,
|
||||
[WorkbenchEvent::FilesChanged(FilesChanged {
|
||||
project: Some(to_ipc(&root)),
|
||||
generation: Some(2),
|
||||
created: vec![to_ipc(&root.join("new.rs"))],
|
||||
..Default::default()
|
||||
})]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -291,6 +302,7 @@ mod tests {
|
||||
created: vec![to_ipc(&root.join("config/a.yaml")), to_ipc(&root.join("src/a.rs"))],
|
||||
modified: vec![to_ipc(&root.join("config/b.yaml"))],
|
||||
removed: vec![to_ipc(&root.join("config/c.yaml"))],
|
||||
..Default::default()
|
||||
})],
|
||||
);
|
||||
host.flush_events();
|
||||
@@ -306,6 +318,7 @@ mod tests {
|
||||
created: vec![to_ipc(&root.join("config/a.yaml"))],
|
||||
modified: vec![to_ipc(&root.join("config/b.yaml"))],
|
||||
removed: vec![to_ipc(&root.join("config/c.yaml"))],
|
||||
..Default::default()
|
||||
}]
|
||||
);
|
||||
} else {
|
||||
@@ -437,6 +450,7 @@ mod tests {
|
||||
PendingFiles {
|
||||
queue: super::super::EventQueue {
|
||||
since: std::time::Instant::now(),
|
||||
last_event: std::time::Instant::now(),
|
||||
events: vec![delta(0, "/project/new")],
|
||||
files_source: None,
|
||||
},
|
||||
@@ -475,6 +489,7 @@ mod tests {
|
||||
created: vec![format!("/project/{i}")],
|
||||
modified: vec!["/project/shared".into()],
|
||||
removed: vec!["/project/gone".into()],
|
||||
..Default::default()
|
||||
})],
|
||||
);
|
||||
}
|
||||
@@ -616,7 +631,15 @@ mod tests {
|
||||
};
|
||||
let data = host.run_command("files-events", "events", None, inv).unwrap().unwrap();
|
||||
let received: Vec<FilesChanged> = serde_json::from_str(&data).unwrap();
|
||||
assert_eq!(received, [FilesChanged { created: vec![to_ipc(&root.join("new.rs"))], ..Default::default() }]);
|
||||
assert_eq!(
|
||||
received,
|
||||
[FilesChanged {
|
||||
project: Some(to_ipc(&root)),
|
||||
generation: Some(3),
|
||||
created: vec![to_ipc(&root.join("new.rs"))],
|
||||
..Default::default()
|
||||
}]
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn queued_filter_replacement_and_pause_do_not_activate() {
|
||||
@@ -656,4 +679,226 @@ mod tests {
|
||||
host.post_files_changed("main", &root, &active, &batch);
|
||||
assert!(host.queues.lock().is_empty(), "paused paths never queue work");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn files_changed_debounce_coalesces_bursts_of_edits_without_repeated_delivery() {
|
||||
use super::super::event_paths::PathFilter;
|
||||
use std::time::Duration;
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = dunce::canonicalize(tmp.path()).unwrap();
|
||||
let host = files_changed_host(&root);
|
||||
host.shared.subscriptions.lock().set_paths(
|
||||
"files-events",
|
||||
"files-changed",
|
||||
PathFilter::with_debounce("files-changed", vec!["**/*".into()], Some(Duration::from_millis(80))).unwrap(),
|
||||
);
|
||||
|
||||
let active = Arc::new(AtomicBool::new(true));
|
||||
// Post 3 bursts of file changes quickly within debounce window
|
||||
host.post_files_changed(
|
||||
"main",
|
||||
&root,
|
||||
&active,
|
||||
&ide_vfs::FsBatch { created: vec![root.join("file1.rs")], ..Default::default() },
|
||||
);
|
||||
host.flush_events();
|
||||
assert_eq!(host.instances(), 0, "first change must be debounced, not delivered immediately");
|
||||
|
||||
std::thread::sleep(Duration::from_millis(20));
|
||||
host.post_files_changed(
|
||||
"main",
|
||||
&root,
|
||||
&active,
|
||||
&ide_vfs::FsBatch { modified: vec![root.join("file2.rs")], ..Default::default() },
|
||||
);
|
||||
host.flush_events();
|
||||
assert_eq!(host.instances(), 0, "second change within debounce window resets debounce");
|
||||
|
||||
std::thread::sleep(Duration::from_millis(20));
|
||||
host.post_files_changed(
|
||||
"main",
|
||||
&root,
|
||||
&active,
|
||||
&ide_vfs::FsBatch { removed: vec![root.join("file3.rs")], ..Default::default() },
|
||||
);
|
||||
host.flush_events();
|
||||
assert_eq!(host.instances(), 0, "third change still debouncing");
|
||||
|
||||
// Wait until debounce expires (> 80 ms since last event)
|
||||
std::thread::sleep(Duration::from_millis(100));
|
||||
host.flush_events();
|
||||
assert!(host.wait_events(Duration::from_secs(5)));
|
||||
|
||||
let inv = ide_plugin::Invocation {
|
||||
client: Some("main".into()),
|
||||
workspace_root: Some(root.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
let data = host.run_command("files-events", "events", None, inv).unwrap().unwrap();
|
||||
let batches: Vec<FilesChanged> = serde_json::from_str(&data).unwrap();
|
||||
assert_eq!(batches.len(), 1, "rapid edit bursts must coalesce into exactly 1 batch");
|
||||
assert_eq!(batches[0].created, [to_ipc(&root.join("file1.rs"))]);
|
||||
assert_eq!(batches[0].modified, [to_ipc(&root.join("file2.rs"))]);
|
||||
assert_eq!(batches[0].removed, [to_ipc(&root.join("file3.rs"))]);
|
||||
assert_eq!(host.shared.project_generation(&root).unwrap(), 4);
|
||||
}
|
||||
|
||||
struct MultiWorkspace(std::sync::Mutex<Vec<PathBuf>>);
|
||||
impl super::super::PluginWorkspace for MultiWorkspace {
|
||||
fn projects(&self) -> Vec<PathBuf> {
|
||||
self.0.lock().unwrap().clone()
|
||||
}
|
||||
fn buffer_text(&self, _: &Path) -> Option<String> {
|
||||
None
|
||||
}
|
||||
fn document(&self, _: &Path) -> Option<(u64, String)> {
|
||||
None
|
||||
}
|
||||
fn apply_edits(
|
||||
&self,
|
||||
_: &Path,
|
||||
_: u64,
|
||||
_: &[ide_core::TextEdit],
|
||||
_: bool,
|
||||
) -> Result<u64, ide_plugin::HostError> {
|
||||
unreachable!()
|
||||
}
|
||||
fn trusted(&self, _: &Path) -> bool {
|
||||
true
|
||||
}
|
||||
fn project_of(&self, window: &str) -> Option<PathBuf> {
|
||||
let projects = self.0.lock().unwrap();
|
||||
match window {
|
||||
"main" => projects.first().cloned(),
|
||||
"other" => projects.get(1).cloned(),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
fn publish_diagnostics(
|
||||
&self,
|
||||
_: &str,
|
||||
_: &Path,
|
||||
_: Vec<ide_core::Diagnostic>,
|
||||
) -> Result<(), ide_plugin::HostError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stale_run_target_registration_rejected_after_generation_bump() {
|
||||
use ide_plugin::HostError;
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = dunce::canonicalize(tmp.path()).unwrap();
|
||||
let host = files_changed_host(&root);
|
||||
let dummy = root.join("dummy");
|
||||
std::fs::write(&dummy, b"dummy").unwrap();
|
||||
host.shared.pins.write().insert(
|
||||
("files-events".into(), "process:dummy".into()),
|
||||
ide_language::ProgramPin::approve(&dummy).unwrap(),
|
||||
);
|
||||
let plugin = host.get("files-events").unwrap();
|
||||
let api = super::super::api::PluginApi { pkg: plugin.pkg.clone(), shared: host.shared.clone() };
|
||||
|
||||
let target = ide_plugin::PluginRunTarget {
|
||||
id: "target-1".into(),
|
||||
name: "Target 1".into(),
|
||||
program: "dummy".into(),
|
||||
args: vec!["test".into()],
|
||||
workdir_args: vec![],
|
||||
container_root: None,
|
||||
commands: vec![],
|
||||
};
|
||||
|
||||
// Generation starts at 1
|
||||
let gen1 = host.shared.project_generation(&root).unwrap();
|
||||
assert_eq!(gen1, 1);
|
||||
|
||||
// Registering with matching generation succeeds
|
||||
assert!(api.register_target(&root, target.clone(), Some(gen1)).is_ok());
|
||||
|
||||
// Bump generation (simulating filesystem change or manual bump)
|
||||
let gen2 = host.shared.bump_project_generation(&root);
|
||||
assert_eq!(gen2, 2);
|
||||
|
||||
// Registering with old generation is rejected with Stale
|
||||
let err = api.register_target(&root, target.clone(), Some(gen1)).unwrap_err();
|
||||
assert!(matches!(err, HostError::Stale));
|
||||
|
||||
// Registering with new generation succeeds
|
||||
assert!(api.register_target(&root, target, Some(gen2)).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_isolation_and_project_closed_lifecycle() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root_a = dunce::canonicalize(tmp.path()).unwrap().join("project_a");
|
||||
let root_b = dunce::canonicalize(tmp.path()).unwrap().join("project_b");
|
||||
std::fs::create_dir_all(&root_a).unwrap();
|
||||
std::fs::create_dir_all(&root_b).unwrap();
|
||||
let host = files_changed_host(&root_a);
|
||||
let ws = Arc::new(MultiWorkspace(std::sync::Mutex::new(vec![root_a.clone(), root_b.clone()])));
|
||||
host.set_workspace(Some(ws.clone()));
|
||||
|
||||
let dummy = tmp.path().join("dummy");
|
||||
std::fs::write(&dummy, b"dummy").unwrap();
|
||||
host.shared.pins.write().insert(
|
||||
("files-events".into(), "process:dummy".into()),
|
||||
ide_language::ProgramPin::approve(&dummy).unwrap(),
|
||||
);
|
||||
let plugin = host.get("files-events").unwrap();
|
||||
let api = super::super::api::PluginApi { pkg: plugin.pkg.clone(), shared: host.shared.clone() };
|
||||
|
||||
let active_a = Arc::new(AtomicBool::new(true));
|
||||
let active_b = Arc::new(AtomicBool::new(true));
|
||||
|
||||
// Post changes to Project A and B
|
||||
host.post_files_changed(
|
||||
"main",
|
||||
&root_a,
|
||||
&active_a,
|
||||
&ide_vfs::FsBatch { created: vec![root_a.join("a.rs")], ..Default::default() },
|
||||
);
|
||||
host.post_files_changed(
|
||||
"other",
|
||||
&root_b,
|
||||
&active_b,
|
||||
&ide_vfs::FsBatch { created: vec![root_b.join("b.rs")], ..Default::default() },
|
||||
);
|
||||
|
||||
assert_eq!(host.shared.project_generation(&root_a).unwrap(), 2);
|
||||
assert_eq!(host.shared.project_generation(&root_b).unwrap(), 2);
|
||||
|
||||
// Bumping project A does not bump project B
|
||||
let bump_a = host.shared.bump_project_generation(&root_a);
|
||||
assert_eq!(bump_a, 3);
|
||||
assert_eq!(host.shared.project_generation(&root_b).unwrap(), 2);
|
||||
|
||||
// Register target for project A and B
|
||||
let target = ide_plugin::PluginRunTarget {
|
||||
id: "run".into(),
|
||||
name: "Run".into(),
|
||||
program: "dummy".into(),
|
||||
args: vec![],
|
||||
workdir_args: vec![],
|
||||
container_root: None,
|
||||
commands: vec![],
|
||||
};
|
||||
assert!(api.register_target(&root_a, target.clone(), None).is_ok());
|
||||
assert!(api.register_target(&root_b, target.clone(), None).is_ok());
|
||||
|
||||
assert_eq!(host.run_targets(&root_a).len(), 1);
|
||||
assert_eq!(host.run_targets(&root_b).len(), 1);
|
||||
|
||||
// Close project A
|
||||
ws.0.lock().unwrap().retain(|p| p != &root_a);
|
||||
host.project_closed(&root_a, "main");
|
||||
|
||||
// Project A targets withdrawn, Project B untouched
|
||||
assert!(host.run_targets(&root_a).is_empty());
|
||||
assert_eq!(host.run_targets(&root_b).len(), 1);
|
||||
|
||||
// Project A generation closed (NotFound on lookup), Project B intact
|
||||
assert!(host.shared.project_generation(&root_a).is_err());
|
||||
assert_eq!(host.shared.project_generation(&root_b).unwrap(), 2);
|
||||
}
|
||||
}
|
||||
@@ -211,6 +211,7 @@ const LATENCY_WINDOW: usize = 128;
|
||||
/// Events waiting for one plugin (from one window).
|
||||
struct EventQueue {
|
||||
since: Instant,
|
||||
last_event: Instant,
|
||||
events: Vec<WorkbenchEvent>,
|
||||
files_source: Option<files_changed::Source>,
|
||||
}
|
||||
@@ -220,6 +221,8 @@ const MAX_QUEUED_EVENTS: usize = 500;
|
||||
/// How long events for a plugin that is not running are collected before it
|
||||
/// is activated to receive them.
|
||||
const IDLE_BATCH: Duration = Duration::from_secs(2);
|
||||
/// Maximum delay for debounced events before forcing delivery.
|
||||
const MAX_DEBOUNCE_WAIT: Duration = Duration::from_secs(5);
|
||||
|
||||
struct LoadedPlugin {
|
||||
pkg: Package,
|
||||
@@ -1809,6 +1812,51 @@ impl PluginHost {
|
||||
self.forget_web_ptys(label);
|
||||
}
|
||||
|
||||
/// A project closed (or the last window for it detached). Closes the project
|
||||
/// generation, drops queued events for that window and project, withdraws run
|
||||
/// targets and run configurations, and delivers
|
||||
/// `project-closed` to subscribed plugins.
|
||||
pub fn project_closed(&self, root: &Path, window: &str) {
|
||||
self.shared.close_project_generation(root);
|
||||
self.withdraw_project_run_targets(root);
|
||||
self.shared.run_configurations.write().retain(|(_, r), _| r != root);
|
||||
|
||||
let root_ipc = ide_core::ipc_path::to_ipc(root);
|
||||
{
|
||||
let mut queues = self.queues.lock();
|
||||
queues.retain(|(_, client), q| {
|
||||
if client.as_deref() == Some(window) {
|
||||
return false;
|
||||
}
|
||||
q.events.retain(|e| {
|
||||
if let WorkbenchEvent::FilesChanged(f) = e
|
||||
&& f.project.as_deref() == Some(&root_ipc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
true
|
||||
});
|
||||
!q.events.is_empty()
|
||||
});
|
||||
}
|
||||
|
||||
let plugins = self.plugins.read();
|
||||
for p in plugins.values() {
|
||||
{
|
||||
let mut batches = p.batches.lock();
|
||||
batches.files_pending.retain(|(client, ws_root), _| {
|
||||
client.as_deref() != Some(window) && ws_root.as_deref() != Some(root)
|
||||
});
|
||||
}
|
||||
}
|
||||
drop(plugins);
|
||||
// In-flight work is not cancelled: an instance serves every project, and its
|
||||
// results for this one are refused now that the project's generation moved on.
|
||||
|
||||
self.post_events(None, vec![WorkbenchEvent::ProjectClosed(root_ipc)]);
|
||||
self.flush_events();
|
||||
}
|
||||
|
||||
/// The user cancelled a plugin task (`task_id` from `TaskStarted`).
|
||||
pub fn cancel_task(&self, task_id: &str) -> bool {
|
||||
task_id.parse().is_ok_and(|id| self.shared.cancel_task(id))
|
||||
@@ -1998,9 +2046,11 @@ impl PluginHost {
|
||||
}
|
||||
let queue = queues.entry((p.id().to_owned(), client.map(str::to_owned))).or_insert_with(|| EventQueue {
|
||||
since: now,
|
||||
last_event: now,
|
||||
events: Vec::new(),
|
||||
files_source: None,
|
||||
});
|
||||
queue.last_event = now;
|
||||
if let Some(source) = &source {
|
||||
if !queue.files_source.as_ref().is_some_and(|old| old.same(source)) {
|
||||
queue.events.retain(|e| !matches!(e, WorkbenchEvent::FilesChanged(_)));
|
||||
@@ -2042,21 +2092,74 @@ impl PluginHost {
|
||||
let due: Vec<(QueueKey, EventQueue)> = {
|
||||
let mut queues = self.queues.lock();
|
||||
let plugins = self.plugins.read();
|
||||
let keys: Vec<_> = queues
|
||||
.iter()
|
||||
.filter(|((id, _), q)| {
|
||||
let running =
|
||||
plugins.get(id).is_some_and(|p| p.runtime.lock().as_ref().is_some_and(|a| a.is_alive()));
|
||||
running
|
||||
let subs = self.shared.subscriptions.lock();
|
||||
let mut due = Vec::new();
|
||||
let mut keys_to_remove = Vec::new();
|
||||
|
||||
for (key, q) in queues.iter_mut() {
|
||||
let (id, _client) = key;
|
||||
let running = plugins.get(id).is_some_and(|p| p.runtime.lock().as_ref().is_some_and(|a| a.is_alive()));
|
||||
let has_files = q.events.iter().any(|e| matches!(e, WorkbenchEvent::FilesChanged(_)));
|
||||
let has_scheduled = q.events.iter().any(|e| matches!(e, WorkbenchEvent::Scheduled));
|
||||
let debounce = subs.paths.get(id).and_then(|p| p.get("files-changed")).and_then(|f| f.debounce);
|
||||
|
||||
let (files_due, files_debouncing) = if has_files {
|
||||
if let Some(debounce) = debounce {
|
||||
let elapsed = now.saturating_duration_since(q.last_event) >= debounce
|
||||
|| now.saturating_duration_since(q.since) >= MAX_DEBOUNCE_WAIT;
|
||||
(elapsed, !elapsed)
|
||||
} else {
|
||||
(true, false)
|
||||
}
|
||||
} else {
|
||||
(false, false)
|
||||
};
|
||||
|
||||
let other_events_due = (running
|
||||
|| now.saturating_duration_since(q.since) >= IDLE_BATCH
|
||||
|| q.events.len() >= MAX_QUEUED_EVENTS / 2
|
||||
|| has_scheduled)
|
||||
&& q.events.iter().any(|e| !matches!(e, WorkbenchEvent::FilesChanged(_)));
|
||||
|
||||
if files_debouncing {
|
||||
if other_events_due {
|
||||
let mut other_events = Vec::new();
|
||||
q.events.retain(|e| {
|
||||
if matches!(e, WorkbenchEvent::FilesChanged(_)) {
|
||||
true
|
||||
} else {
|
||||
other_events.push(e.clone());
|
||||
false
|
||||
}
|
||||
});
|
||||
due.push((
|
||||
key.clone(),
|
||||
EventQueue {
|
||||
since: q.since,
|
||||
last_event: q.last_event,
|
||||
events: other_events,
|
||||
files_source: None,
|
||||
},
|
||||
));
|
||||
}
|
||||
} else {
|
||||
let is_due = files_due
|
||||
|| running
|
||||
|| now.saturating_duration_since(q.since) >= IDLE_BATCH
|
||||
|| q.events.len() >= MAX_QUEUED_EVENTS / 2
|
||||
|| q.events
|
||||
.iter()
|
||||
.any(|e| matches!(e, WorkbenchEvent::FilesChanged(_) | WorkbenchEvent::Scheduled))
|
||||
})
|
||||
.map(|(k, _)| k.clone())
|
||||
.collect();
|
||||
keys.into_iter().filter_map(|k| queues.remove(&k).map(|q| (k, q))).collect()
|
||||
|| has_scheduled;
|
||||
if is_due {
|
||||
keys_to_remove.push(key.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for k in keys_to_remove {
|
||||
if let Some(q) = queues.remove(&k) {
|
||||
due.push((k, q));
|
||||
}
|
||||
}
|
||||
due
|
||||
};
|
||||
let mut changed = false;
|
||||
for ((id, client), queue) in due {
|
||||
@@ -2081,9 +2184,10 @@ impl PluginHost {
|
||||
pub fn wait_events(&self, timeout: Duration) -> bool {
|
||||
let deadline = Instant::now() + timeout;
|
||||
loop {
|
||||
let busy = self.plugins.read().values().any(|p| p.batches.lock().pending > 0);
|
||||
self.flush_events_at(Instant::now());
|
||||
let busy =
|
||||
self.plugins.read().values().any(|p| p.batches.lock().pending > 0) || !self.queues.lock().is_empty();
|
||||
if !busy {
|
||||
self.flush_events_at(Instant::now());
|
||||
return true;
|
||||
}
|
||||
if Instant::now() >= deadline {
|
||||
@@ -2125,12 +2229,20 @@ impl PluginHost {
|
||||
&& queue.events.iter().any(|e| !matches!(e, WorkbenchEvent::FilesChanged(_)))
|
||||
{
|
||||
let (files, other) = queue.events.into_iter().partition(|e| matches!(e, WorkbenchEvent::FilesChanged(_)));
|
||||
let changed =
|
||||
self.deliver(id, client.clone(), EventQueue { since: queue.since, events: other, files_source: None });
|
||||
let changed = self.deliver(
|
||||
id,
|
||||
client.clone(),
|
||||
EventQueue { since: queue.since, last_event: queue.last_event, events: other, files_source: None },
|
||||
);
|
||||
return self.deliver(
|
||||
id,
|
||||
client,
|
||||
EventQueue { since: queue.since, events: files, files_source: queue.files_source },
|
||||
EventQueue {
|
||||
since: queue.since,
|
||||
last_event: queue.last_event,
|
||||
events: files,
|
||||
files_source: queue.files_source,
|
||||
},
|
||||
) | changed;
|
||||
}
|
||||
let Ok(plugin) = self.get(id) else { return false };
|
||||
@@ -2451,12 +2563,15 @@ impl PluginHost {
|
||||
let restricted = p.dev_root.as_deref().is_some_and(|root| !(self.project_policy.read())(root));
|
||||
if due && !restricted && self.startup_finished.load(Ordering::Acquire) {
|
||||
// Activates it if needed and calls `handle([scheduled])`.
|
||||
self.queues
|
||||
.lock()
|
||||
.entry((p.id().to_owned(), None))
|
||||
.or_insert_with(|| EventQueue { since: now, events: Vec::new(), files_source: None })
|
||||
.events
|
||||
.push(WorkbenchEvent::Scheduled);
|
||||
let mut q = self.queues.lock();
|
||||
let queue = q.entry((p.id().to_owned(), None)).or_insert_with(|| EventQueue {
|
||||
since: now,
|
||||
last_event: now,
|
||||
events: Vec::new(),
|
||||
files_source: None,
|
||||
});
|
||||
queue.last_event = now;
|
||||
queue.events.push(WorkbenchEvent::Scheduled);
|
||||
}
|
||||
}
|
||||
if changed {
|
||||
|
||||
@@ -95,6 +95,8 @@ pub fn register_builtin_points(
|
||||
registry.register(Arc::new(UiPoint::new(p::VIEWS, ui.clone(), p::view)))?;
|
||||
registry.register(Arc::new(UiPoint::new(p::CUSTOM_EDITORS, ui.clone(), p::custom_editor)))?;
|
||||
registry.register(Arc::new(UiPoint::new(p::EDITOR_PANELS, ui.clone(), p::editor_panel)))?;
|
||||
registry.register(Arc::new(UiPoint::new(p::OVERLAYS, ui.clone(), p::overlay)))?;
|
||||
registry.register(Arc::new(UiPoint::new(p::DIALOGS, ui.clone(), p::dialog)))?;
|
||||
registry.register(Arc::new(UiPoint::new(p::MARKER_ICONS, ui.clone(), p::marker_icon)))?;
|
||||
registry.register(Arc::new(UiPoint::new(p::FILE_ICONS, ui.clone(), p::file_icon)))?;
|
||||
registry.register(Arc::new(UiPoint::new(p::FILE_TEMPLATES, ui.clone(), p::file_template)))?;
|
||||
|
||||
@@ -39,7 +39,12 @@ impl Shared {
|
||||
}
|
||||
}
|
||||
impl PluginApi {
|
||||
pub(super) fn register_target(&self, root: &Path, target: PluginRunTarget) -> Result<(), HostError> {
|
||||
pub(super) fn register_target(
|
||||
&self,
|
||||
root: &Path,
|
||||
target: PluginRunTarget,
|
||||
generation: Option<u64>,
|
||||
) -> Result<(), HostError> {
|
||||
ide_remote::plugin_target::validate(&target).map_err(|e| HostError::Invalid(e.to_string()))?;
|
||||
let workspace = self.shared.workspace().ok_or(HostError::Cancelled)?;
|
||||
if !workspace.projects().iter().any(|r| r == root) {
|
||||
@@ -48,6 +53,12 @@ impl PluginApi {
|
||||
if !workspace.trusted(root) {
|
||||
return Err(HostError::Denied("project is not trusted".into()));
|
||||
}
|
||||
if let Some(expected) = generation {
|
||||
let current = self.shared.project_generation(root)?;
|
||||
if expected < current {
|
||||
return Err(HostError::Stale);
|
||||
}
|
||||
}
|
||||
self.approved_program_in_project(&target.program, Some(root))?;
|
||||
let blocked = self.shared.prompts_blocked.lock();
|
||||
if blocked.contains(self.pkg.id()) {
|
||||
|
||||
@@ -44,6 +44,22 @@
|
||||
//! width = 110 # pixels, 40–400
|
||||
//! when = "plugin.<id>.enabled" # optional
|
||||
//!
|
||||
//! [[contributes.overlays]]
|
||||
//! id = "stage"
|
||||
//! web = "web/stage.html" # floats over the workbench, never takes the focus (API 1.18)
|
||||
//! width = 320 # pixels, 40–800; the page can resize it within those bounds
|
||||
//! height = 240
|
||||
//! anchor = "bottom-right" # top-left … bottom-right (nine); the page can move it
|
||||
//! when = "plugin.<id>.showing" # optional
|
||||
//! interactive = true # optional; false lets every click through to the IDE
|
||||
//!
|
||||
//! [[contributes.dialogs]]
|
||||
//! id = "preview"
|
||||
//! title = "SQL Preview" # the dialog's title bar
|
||||
//! web = "web/preview.html" # modal, resizable; opened by `views.reveal("preview")` (API 1.18)
|
||||
//! width = 900 # pixels, 320–1600
|
||||
//! height = 600 # pixels, 200–1200
|
||||
//!
|
||||
//! [[contributes.fileIcons]]
|
||||
//! id = "drawing"
|
||||
//! patterns = ["*.excalidraw"]
|
||||
@@ -82,8 +98,10 @@ pub const SETTINGS: &str = "settings";
|
||||
pub const VIEWS: &str = "views";
|
||||
pub const CUSTOM_EDITORS: &str = "customEditors";
|
||||
pub const EDITOR_PANELS: &str = "editorPanels";
|
||||
pub const OVERLAYS: &str = "overlays";
|
||||
pub const DIALOGS: &str = "dialogs";
|
||||
/// The points whose declarations can name a `web` page (served, messaged, sent view events).
|
||||
pub const WEB_POINTS: [&str; 3] = [VIEWS, CUSTOM_EDITORS, EDITOR_PANELS];
|
||||
pub const WEB_POINTS: [&str; 5] = [VIEWS, CUSTOM_EDITORS, EDITOR_PANELS, OVERLAYS, DIALOGS];
|
||||
pub const FILE_ICONS: &str = "fileIcons";
|
||||
pub const MARKER_ICONS: &str = "markerIcons";
|
||||
pub const FILE_TEMPLATES: &str = "fileTemplates";
|
||||
@@ -887,6 +905,109 @@ pub(super) fn editor_panel(pkg: &Package, decl: toml::Value) -> Result<UiDecl, S
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct OverlayDecl {
|
||||
id: String,
|
||||
web: String,
|
||||
width: u32,
|
||||
height: u32,
|
||||
#[serde(default = "default_overlay_anchor")]
|
||||
anchor: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
when: Option<String>,
|
||||
#[serde(default = "default_true")]
|
||||
interactive: bool,
|
||||
}
|
||||
|
||||
fn default_overlay_anchor() -> String {
|
||||
"bottom-right".into()
|
||||
}
|
||||
|
||||
fn default_true() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Where an overlay can sit in the window (the page may move it to another).
|
||||
pub const OVERLAY_ANCHORS: [&str; 9] = [
|
||||
"top-left",
|
||||
"top-center",
|
||||
"top-right",
|
||||
"middle-left",
|
||||
"center",
|
||||
"middle-right",
|
||||
"bottom-left",
|
||||
"bottom-center",
|
||||
"bottom-right",
|
||||
];
|
||||
const OVERLAY_SIZE: std::ops::RangeInclusive<u32> = 40..=800;
|
||||
|
||||
/// `[[contributes.overlays]]` (API 1.18): a web page floating over the workbench at
|
||||
/// one of nine anchors, shown while `when` holds. It never takes the keyboard focus,
|
||||
/// sits under dialogs and popups, and sees nothing of the IDE, so it needs no
|
||||
/// capability.
|
||||
pub(super) fn overlay(pkg: &Package, decl: toml::Value) -> Result<UiDecl, String> {
|
||||
let d: OverlayDecl = decode(OVERLAYS, decl)?;
|
||||
pkg.manifest.needs_api(&format!("contributes.{OVERLAYS}"), 18)?;
|
||||
validate_item_id(&d.id, "overlay id")?;
|
||||
let what = format!("overlay {:?}", d.id);
|
||||
for (name, value) in [("width", d.width), ("height", d.height)] {
|
||||
if !OVERLAY_SIZE.contains(&value) {
|
||||
return Err(format!("{what}: `{name}` is {}–{} pixels", OVERLAY_SIZE.start(), OVERLAY_SIZE.end()));
|
||||
}
|
||||
}
|
||||
if !OVERLAY_ANCHORS.contains(&d.anchor.as_str()) {
|
||||
return Err(format!("{what}: `anchor` is one of {}", OVERLAY_ANCHORS.join(", ")));
|
||||
}
|
||||
if let Some(when) = &d.when {
|
||||
validate_when(when).map_err(|e| format!("{what}: {e}"))?;
|
||||
}
|
||||
let files = super::web::web_files(pkg, &d.web, &what)?;
|
||||
let mut out = UiDecl::new(d.id.clone(), d.id.clone(), json(&d)?);
|
||||
out.files = files;
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct DialogDecl {
|
||||
id: String,
|
||||
title: String,
|
||||
web: String,
|
||||
width: u32,
|
||||
height: u32,
|
||||
}
|
||||
|
||||
const DIALOG_WIDTH: std::ops::RangeInclusive<u32> = 320..=1600;
|
||||
const DIALOG_HEIGHT: std::ops::RangeInclusive<u32> = 200..=1200;
|
||||
|
||||
/// `[[contributes.dialogs]]` (API 1.18): a package web page in a modal, resizable IDE
|
||||
/// dialog with a title bar, opened by the plugin's code with `views.reveal(id)` in the
|
||||
/// invoking window. Like a web view it sees nothing of the IDE beyond its messages, so
|
||||
/// it needs no capability.
|
||||
pub(super) fn dialog(pkg: &Package, decl: toml::Value) -> Result<UiDecl, String> {
|
||||
let d: DialogDecl = decode(DIALOGS, decl)?;
|
||||
pkg.manifest.needs_api(&format!("contributes.{DIALOGS}"), 18)?;
|
||||
validate_item_id(&d.id, "dialog id")?;
|
||||
let what = format!("dialog {:?}", d.id);
|
||||
// `views.reveal(id)` opens it, so it can't share an id with a tool window.
|
||||
if pkg.manifest.declarations(VIEWS).iter().any(|v| v.get("id").and_then(|i| i.as_str()) == Some(&d.id)) {
|
||||
return Err(format!("{what}: a view has the same id"));
|
||||
}
|
||||
if d.title.trim().is_empty() || d.title.len() > 256 {
|
||||
return Err(format!("{what}: `title` is 1–256 bytes"));
|
||||
}
|
||||
for (name, value, range) in [("width", d.width, DIALOG_WIDTH), ("height", d.height, DIALOG_HEIGHT)] {
|
||||
if !range.contains(&value) {
|
||||
return Err(format!("{what}: `{name}` is {}–{} pixels", range.start(), range.end()));
|
||||
}
|
||||
}
|
||||
let files = super::web::web_files(pkg, &d.web, &what)?;
|
||||
let mut out = UiDecl::new(d.id.clone(), d.title.clone(), json(&d)?);
|
||||
out.files = files;
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
struct FileIconDecl {
|
||||
@@ -1518,6 +1639,104 @@ web = "web/view.html"
|
||||
assert!(check(VIEWS, &view_with(r#"["https://example.com"]"#), &ask).unwrap_err().contains("capability"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn overlays_validate_api_size_anchor_when_and_page() {
|
||||
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../ide-plugin/tests/fixtures/overlay");
|
||||
// A Windows checkout may have CRLF line ends; the edits below match on `\n`.
|
||||
let source = std::fs::read_to_string(root.join("plugin.toml")).unwrap().replace("\r\n", "\n");
|
||||
let check = |source: &str| {
|
||||
let manifest = ide_extension::Manifest::parse(source)?;
|
||||
let decl = manifest.declarations(OVERLAYS).into_iter().next().unwrap();
|
||||
overlay(&Package::new(manifest, root.clone()), decl)
|
||||
};
|
||||
let valid = check(&source).unwrap();
|
||||
assert_eq!(valid.key, "probe");
|
||||
assert_eq!(
|
||||
valid.json,
|
||||
serde_json::json!({
|
||||
"id": "probe", "web": "web/index.html", "width": 260, "height": 140,
|
||||
"anchor": "bottom-right", "interactive": true,
|
||||
})
|
||||
);
|
||||
assert_eq!(valid.files, [PathBuf::from("web/index.html")]);
|
||||
let placed =
|
||||
check(&source.replace("height = 140", "height = 140\nanchor = \"top-center\"\ninteractive = false"));
|
||||
let placed = placed.unwrap();
|
||||
assert_eq!(placed.json["anchor"], "top-center");
|
||||
assert_eq!(placed.json["interactive"], false);
|
||||
let when = source.replace("height = 140", "height = 140\nwhen = \"plugin.overlay.showing\"");
|
||||
assert_eq!(check(&when).unwrap().json["when"], "plugin.overlay.showing");
|
||||
for size in ["40", "800"] {
|
||||
assert!(check(&source.replace("width = 260", &format!("width = {size}"))).is_ok(), "{size}");
|
||||
}
|
||||
for (bad, error) in [
|
||||
(source.replace("^1.18", "^1.17"), "1.18"),
|
||||
(source.replace("width = 260", "width = 39"), "40–800"),
|
||||
(source.replace("height = 140", "height = 801"), "`height`"),
|
||||
(source.replace("height = 140\n", ""), "height"),
|
||||
(source.replace("height = 140", "height = 140\nanchor = \"left\""), "anchor"),
|
||||
(source.replace("height = 140", "height = 140\nwhen = \"a &&\""), "when"),
|
||||
(source.replace("height = 140", "height = 140\nfocus = true"), "focus"),
|
||||
(source.replace("web/index.html", "index.html"), "directory of its own"),
|
||||
(source.replace("web/index.html", "web/missing.html"), "no such file"),
|
||||
(source.replace(r#"id = "probe""#, r#"id = "Pro Be""#), "id"),
|
||||
] {
|
||||
let err = check(&bad).unwrap_err();
|
||||
assert!(err.contains(error), "{bad}\n→ {err}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dialogs_validate_api_title_size_id_and_page() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
std::fs::create_dir(dir.path().join("web")).unwrap();
|
||||
std::fs::write(dir.path().join("web/preview.html"), "<p>SQL</p>").unwrap();
|
||||
let source = r#"id = "sql"
|
||||
name = "SQL"
|
||||
version = "0.1.0"
|
||||
engines.openidea = "^1.18"
|
||||
|
||||
[[contributes.dialogs]]
|
||||
id = "preview"
|
||||
title = "SQL Preview"
|
||||
web = "web/preview.html"
|
||||
width = 900
|
||||
height = 600
|
||||
"#;
|
||||
let check = |source: &str| {
|
||||
let manifest = ide_extension::Manifest::parse(source)?;
|
||||
let decl = manifest.declarations(DIALOGS).into_iter().next().unwrap();
|
||||
dialog(&Package::new(manifest, dir.path().to_path_buf()), decl)
|
||||
};
|
||||
let valid = check(source).unwrap();
|
||||
assert_eq!((valid.key.as_str(), valid.label.as_str()), ("preview", "SQL Preview"));
|
||||
assert_eq!(
|
||||
valid.json,
|
||||
serde_json::json!({"id": "preview", "title": "SQL Preview", "web": "web/preview.html", "width": 900, "height": 600})
|
||||
);
|
||||
assert_eq!(valid.files, [PathBuf::from("web/preview.html")]);
|
||||
for (bad, error) in [
|
||||
(source.replace("^1.18", "^1.17"), "1.18"),
|
||||
(source.replace("width = 900", "width = 319"), "320–1600"),
|
||||
(source.replace("height = 600", "height = 1201"), "`height`"),
|
||||
(source.replace(r#"title = "SQL Preview""#, r#"title = " ""#), "title"),
|
||||
(
|
||||
source.replace(
|
||||
"height = 600",
|
||||
"height = 600
|
||||
modal = false",
|
||||
),
|
||||
"modal",
|
||||
),
|
||||
(source.replace("web/preview.html", "web/missing.html"), "no such file"),
|
||||
(source.replace(r#"id = "preview""#, r#"id = "Pre View""#), "id"),
|
||||
(format!("{source}\n[[contributes.views]]\nid = \"preview\"\ntitle = \"P\"\n"), "same id"),
|
||||
] {
|
||||
let err = check(&bad).unwrap_err();
|
||||
assert!(err.contains(error), "{bad}\n→ {err}");
|
||||
}
|
||||
}
|
||||
|
||||
fn package_with_catalogs(files: &[(&str, &str)]) -> (tempfile::TempDir, Package) {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
std::fs::create_dir(dir.path().join(LOCALES_DIR)).unwrap();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
mod common;
|
||||
|
||||
use ide_core::{ChangeSet, TextChange};
|
||||
use ide_core::{ChangeSet, Pos, Range, SymbolKind, TextChange};
|
||||
use ide_host::{Host, catalogue::TrustClass, ops};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
@@ -51,6 +51,33 @@ async fn edits_loose_files_without_project_services() {
|
||||
assert!(!Arc::ptr_eq(&project, &light));
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn large_markdown_has_structure_after_embedded_images() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let path = tmp.path().join("paper.md");
|
||||
let image = format!("\n\n", "A".repeat(64 * 1024));
|
||||
let text = format!("# Paper\n\n{}```text\n## Inside code\n```\n\n## Results\n", image.repeat(84));
|
||||
std::fs::write(&path, text).unwrap();
|
||||
let host = host(&tmp.path().join("app"));
|
||||
host.open_light("main", &path).unwrap();
|
||||
|
||||
let doc = ops::doc::doc_open(&host, "main", path).await.unwrap();
|
||||
assert!(doc.large);
|
||||
let outline = ops::doc::doc_outline(&host, "main", doc.id).await.unwrap();
|
||||
|
||||
assert_eq!(outline.len(), 1);
|
||||
let paper = &outline[0];
|
||||
assert_eq!(paper.kind, SymbolKind::Key);
|
||||
assert_eq!(paper.name, "Paper");
|
||||
assert_eq!(paper.selection_range, Range::new(Pos::new(0, 2), Pos::new(0, 7)));
|
||||
assert_eq!(paper.children.len(), 1);
|
||||
let results = &paper.children[0];
|
||||
assert_eq!(results.kind, SymbolKind::Key);
|
||||
assert_eq!(results.name, "Results");
|
||||
assert_eq!(results.selection_range, Range::new(Pos::new(174, 3), Pos::new(174, 10)));
|
||||
assert!(results.children.is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn light_windows_ignore_project_scoped_settings() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -775,6 +775,42 @@ async fn execute_reports_output_exit_code_and_requires_confirmation() {
|
||||
assert!(result["output"].as_str().unwrap().contains("captured-output"));
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn a_configuration_left_running_is_stopped_by_its_run_id() {
|
||||
let h = Harness::new();
|
||||
h.trust().await;
|
||||
let config = ide_run::RunConfig {
|
||||
id: "server".into(),
|
||||
name: "Server".into(),
|
||||
kind: "shell".into(),
|
||||
command: if cfg!(windows) { "ping -n 60 127.0.0.1" } else { "sleep 60" }.into(),
|
||||
args: vec![],
|
||||
cwd: None,
|
||||
env: Default::default(),
|
||||
detected: false,
|
||||
is_test: false,
|
||||
debug_adapter: None,
|
||||
allow_parallel: false,
|
||||
extras: Default::default(),
|
||||
};
|
||||
ide_run::save_user_configs(&h.root, &[config]).unwrap();
|
||||
h.host.mcp_requests.set_ready("main", true);
|
||||
let run = h.json("execute_run_configuration", json!({"configurationName":"Server","waitForExit":false}));
|
||||
let allow = async {
|
||||
let id = h.request().await;
|
||||
h.host.mcp_requests.answer("main", id, true, None).unwrap();
|
||||
};
|
||||
let (result, ()) = tokio::join!(run, allow);
|
||||
assert!(result.get("exitCode").is_none());
|
||||
let id = result["runId"].as_u64().expect("a run left running carries its id");
|
||||
|
||||
let user_run = id + 1000;
|
||||
assert!(h.error("stop_run", json!({"runId": user_run})).await.contains("started by execute_run_configuration"));
|
||||
let stopped = h.json("stop_run", json!({"runId": id, "force": true, "timeout": 10000})).await;
|
||||
assert_eq!(stopped["state"], "stopped", "{stopped}");
|
||||
assert!(h.error("stop_run", json!({"runId": id})).await.contains("started by execute_run_configuration"));
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[ignore = "requires rust-analyzer, like language_smoke::rust"]
|
||||
async fn rust_references_and_rename_through_mcp() {
|
||||
|
||||
@@ -6125,6 +6125,7 @@ fn files_changed_wakes_idle_once_and_keeps_every_delta() {
|
||||
created: vec![to_ipc(&f.project.join(format!("新建😀-{i}.rs")))],
|
||||
modified: vec![to_ipc(&f.project.join("shared.rs"))],
|
||||
removed: vec![to_ipc(&f.project.join("gone.rs"))],
|
||||
..Default::default()
|
||||
})],
|
||||
);
|
||||
}
|
||||
@@ -6262,6 +6263,7 @@ fn files_changed_filters_each_category_before_waking_idle_plugins() {
|
||||
created: vec![path("src/unrelated.rs")],
|
||||
modified: vec![path("notes.txt")],
|
||||
removed: vec![path("elsewhere/a.yaml")],
|
||||
..Default::default()
|
||||
})],
|
||||
);
|
||||
f.host.flush_events();
|
||||
@@ -6272,6 +6274,7 @@ fn files_changed_filters_each_category_before_waking_idle_plugins() {
|
||||
created: vec![path("config/new.yaml"), path("src/unrelated.rs")],
|
||||
modified: vec![path("config/changed.yaml"), path("notes.txt")],
|
||||
removed: vec![path("config/gone.yaml"), path("elsewhere/a.yaml")],
|
||||
..Default::default()
|
||||
})],
|
||||
);
|
||||
f.host.flush_events();
|
||||
@@ -6284,6 +6287,7 @@ fn files_changed_filters_each_category_before_waking_idle_plugins() {
|
||||
created: vec![path("config/new.yaml")],
|
||||
modified: vec![path("config/changed.yaml")],
|
||||
removed: vec![path("config/gone.yaml")],
|
||||
..Default::default()
|
||||
}]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ use views_bindings::exports::openidea::plugin::view_provider as wit_view;
|
||||
use views_bindings::openidea::plugin::view_types as wit_vt;
|
||||
|
||||
/// The API version of the world above, `major.minor` of [`host_api`].
|
||||
pub const API_VERSION: &str = "1.17";
|
||||
pub const API_VERSION: &str = "1.18";
|
||||
const EPOCH_TICK: Duration = Duration::from_millis(10);
|
||||
pub(crate) const MAX_TEXT: usize = 1 << 20;
|
||||
/// The most text, and the most PNG bytes, `ui.read-clipboard` returns.
|
||||
@@ -115,7 +115,12 @@ pub trait HostApi: Send + Sync {
|
||||
fn extension_contributions(&self, point: &str) -> Result<Vec<(String, String)>, HostError>;
|
||||
|
||||
/// Registers a project-scoped wrapper after validating its process grant and pin.
|
||||
fn register_run_target(&self, root: &Path, target: crate::PluginRunTarget) -> Result<(), HostError>;
|
||||
fn register_run_target(
|
||||
&self,
|
||||
root: &Path,
|
||||
target: crate::PluginRunTarget,
|
||||
generation: Option<u64>,
|
||||
) -> Result<(), HostError>;
|
||||
/// Withdraws this plugin's target, preserving the user's remembered prompt answer.
|
||||
fn unregister_run_target(&self, root: &Path, id: &str);
|
||||
|
||||
@@ -417,7 +422,18 @@ pub trait HostApi: Send + Sync {
|
||||
/// Delivers every event of `kind`, dropping its path filter.
|
||||
fn subscribe(&self, kind: EventKind);
|
||||
/// Delivers `kind` (`file-opened`, `file-saved`, `files-changed`) only for matching paths.
|
||||
fn subscribe_paths(&self, kind: &str, globs: Vec<String>) -> Result<(), HostError>;
|
||||
fn subscribe_paths(&self, kind: &str, globs: Vec<String>) -> Result<(), HostError> {
|
||||
self.subscribe_paths_with_options(kind, globs, None)
|
||||
}
|
||||
/// Delivers `kind` with optional debounce window in milliseconds (API 1.18).
|
||||
fn subscribe_paths_with_options(
|
||||
&self,
|
||||
kind: &str,
|
||||
globs: Vec<String>,
|
||||
debounce_ms: Option<u32>,
|
||||
) -> Result<(), HostError>;
|
||||
/// Monotonically increasing project generation (API 1.18).
|
||||
fn project_generation(&self, root: &Path) -> Result<u64, HostError>;
|
||||
fn unsubscribe(&self, kind: &str);
|
||||
/// Starts `cmd` and returns the handle to it without waiting.
|
||||
fn start_process(&self, cmd: ProcessCommand, cwd: Option<&Path>, client: Option<&str>) -> Result<u64, HostError>;
|
||||
@@ -966,6 +982,10 @@ fn event_to_wit(e: WorkbenchEvent) -> wit_events::Event {
|
||||
WorkbenchEvent::ProblemsChanged => {
|
||||
wit_events::Event::Other(wit_types::Extension { kind: "problems-changed".into(), data: "{}".into() })
|
||||
}
|
||||
WorkbenchEvent::ProjectClosed(p) => wit_events::Event::Other(wit_types::Extension {
|
||||
kind: "project-closed".into(),
|
||||
data: serde_json::to_string(&p).expect("path serializes"),
|
||||
}),
|
||||
WorkbenchEvent::Scheduled => wit_events::Event::Scheduled,
|
||||
WorkbenchEvent::ActionPerformed(a) => wit_events::Event::ActionPerformed(wit_events::ActionPerformed {
|
||||
action: a.action,
|
||||
@@ -2391,6 +2411,7 @@ fn event_to_wit_view(e: ViewEvent) -> wit_vt::ViewEvent {
|
||||
kind: "sort".into(),
|
||||
data: format!(r#"{{"column":{column},"descending":{descending}}}"#),
|
||||
}),
|
||||
ViewEvent::Closed => W::Other(wit_types::Extension { kind: "closed".into(), data: "{}".into() }),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2844,6 +2865,12 @@ mod tests {
|
||||
assert_eq!(fields[2].value, FieldValue::ReadonlyText { text: "author".into(), multiline: false });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_closed_dialog_leaves_as_an_other_event() {
|
||||
let wit_vt::ViewEvent::Other(extension) = event_to_wit_view(ViewEvent::Closed) else { panic!("other") };
|
||||
assert_eq!((extension.kind.as_str(), extension.data.as_str()), ("closed", "{}"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_row_events_leave_through_released_extension_case() {
|
||||
for (event, kind) in [
|
||||
|
||||
@@ -169,11 +169,13 @@ pub enum EventKind {
|
||||
VcsChanged,
|
||||
/// Problems of the window's files changed (a language server or a report).
|
||||
ProblemsChanged,
|
||||
/// A project was closed (or its window closed): the project root path.
|
||||
ProjectClosed,
|
||||
Scheduled,
|
||||
}
|
||||
|
||||
impl EventKind {
|
||||
pub const ALL: [Self; 18] = [
|
||||
pub const ALL: [Self; 19] = [
|
||||
Self::DocumentChanged,
|
||||
Self::WebsocketReady,
|
||||
Self::FileClosed,
|
||||
@@ -191,6 +193,7 @@ impl EventKind {
|
||||
Self::ActionPerformed,
|
||||
Self::VcsChanged,
|
||||
Self::ProblemsChanged,
|
||||
Self::ProjectClosed,
|
||||
Self::Scheduled,
|
||||
];
|
||||
|
||||
@@ -213,6 +216,7 @@ impl EventKind {
|
||||
Self::ActionPerformed => "action-performed",
|
||||
Self::VcsChanged => "vcs-changed",
|
||||
Self::ProblemsChanged => "problems-changed",
|
||||
Self::ProjectClosed => "project-closed",
|
||||
Self::Scheduled => "scheduled",
|
||||
}
|
||||
}
|
||||
@@ -274,6 +278,12 @@ pub struct ActionPerformed {
|
||||
/// Debounced worktree changes. Paths use the same absolute form as `file-saved`.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
pub struct FilesChanged {
|
||||
/// Canonical absolute root of the project where changes occurred (API 1.18).
|
||||
#[serde(default)]
|
||||
pub project: Option<String>,
|
||||
/// Project state generation at the time this batch was emitted (API 1.18).
|
||||
#[serde(default)]
|
||||
pub generation: Option<u64>,
|
||||
pub created: Vec<String>,
|
||||
pub modified: Vec<String>,
|
||||
pub removed: Vec<String>,
|
||||
@@ -367,6 +377,8 @@ pub enum WorkbenchEvent {
|
||||
VcsChanged(String),
|
||||
/// Problems of the window's files changed; plugins re-read `problems`.
|
||||
ProblemsChanged,
|
||||
/// A project closed (API 1.18); payload is the canonical absolute root path.
|
||||
ProjectClosed(String),
|
||||
Scheduled,
|
||||
}
|
||||
|
||||
@@ -390,6 +402,7 @@ impl WorkbenchEvent {
|
||||
Self::ActionPerformed(_) => EventKind::ActionPerformed,
|
||||
Self::VcsChanged(_) => EventKind::VcsChanged,
|
||||
Self::ProblemsChanged => EventKind::ProblemsChanged,
|
||||
Self::ProjectClosed(_) => EventKind::ProjectClosed,
|
||||
Self::Scheduled => EventKind::Scheduled,
|
||||
}
|
||||
}
|
||||
@@ -943,6 +956,9 @@ pub enum ViewEvent {
|
||||
Sort { column: u32, descending: bool },
|
||||
TableSelect { row: u32 },
|
||||
TableActivate { row: u32 },
|
||||
// A plugin dialog closed (API 1.18): its close button, Escape or its page.
|
||||
// Leaves as an `other` view-event, kind `closed`.
|
||||
Closed,
|
||||
}
|
||||
|
||||
/// A plugin's HTTP route declaration in a project.
|
||||
|
||||
@@ -237,9 +237,10 @@ use bindings::openidea::plugin::{
|
||||
settings, storage, tasks, types as wit, ui, vcs, views, workspace,
|
||||
};
|
||||
|
||||
/// A project handle: its root.
|
||||
/// A project handle: its root and generation when borrowed.
|
||||
pub struct ProjectRes {
|
||||
root: PathBuf,
|
||||
pub(crate) root: PathBuf,
|
||||
pub(crate) generation: u64,
|
||||
}
|
||||
|
||||
/// A program a plugin started behind a handle (`process.start`); dropping the
|
||||
@@ -896,7 +897,13 @@ impl workspace::Host for StoreData {
|
||||
}
|
||||
|
||||
fn project_of(&mut self, path: String) -> wasmtime::Result<Option<Resource<ProjectRes>>> {
|
||||
self.host.project_of(Path::new(&path)).map(|root| self.push(ProjectRes { root })).transpose()
|
||||
self.host
|
||||
.project_of(Path::new(&path))
|
||||
.map(|root| {
|
||||
let generation = self.host.project_generation(&root).unwrap_or(0);
|
||||
self.push(ProjectRes { root, generation })
|
||||
})
|
||||
.transpose()
|
||||
}
|
||||
|
||||
fn projects(&mut self) -> Fallible<Vec<Resource<ProjectRes>>> {
|
||||
@@ -905,7 +912,8 @@ impl workspace::Host for StoreData {
|
||||
}
|
||||
let mut out = Vec::new();
|
||||
for root in self.host.projects() {
|
||||
out.push(self.push(ProjectRes { root })?);
|
||||
let generation = self.host.project_generation(&root).unwrap_or(0);
|
||||
out.push(self.push(ProjectRes { root, generation })?);
|
||||
}
|
||||
Ok(Ok(out))
|
||||
}
|
||||
@@ -1092,6 +1100,17 @@ impl workspace::HostProject for StoreData {
|
||||
Ok(self.host.write_text_file(&real, &text).map_err(to_wit))
|
||||
}
|
||||
|
||||
fn generation(&mut self, this: Resource<ProjectRes>) -> Fallible<u64> {
|
||||
if let Err(e) = self.require(Capability::ProjectRead) {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
if let Err(e) = self.host.require_api("project.generation", 18) {
|
||||
return Ok(Err(to_wit(e)));
|
||||
}
|
||||
let root = self.table.get(&this)?.root.clone();
|
||||
Ok(self.host.project_generation(&root).map_err(to_wit))
|
||||
}
|
||||
|
||||
fn drop(&mut self, rep: Resource<ProjectRes>) -> wasmtime::Result<()> {
|
||||
self.table.delete(rep)?;
|
||||
Ok(())
|
||||
@@ -1320,7 +1339,10 @@ impl invocation::Host for StoreData {}
|
||||
impl invocation::HostInvocation for StoreData {
|
||||
fn project(&mut self, _this: Resource<InvocationRes>) -> wasmtime::Result<Option<Resource<ProjectRes>>> {
|
||||
match self.invocation.workspace_root.clone() {
|
||||
Some(root) => Ok(Some(self.push(ProjectRes { root })?)),
|
||||
Some(root) => {
|
||||
let generation = self.host.project_generation(&root).unwrap_or(0);
|
||||
Ok(Some(self.push(ProjectRes { root, generation })?))
|
||||
}
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
@@ -1592,6 +1614,11 @@ impl events::Host for StoreData {
|
||||
{
|
||||
return Ok(Err(to_wit(e)));
|
||||
}
|
||||
if kind == EventKind::ProjectClosed
|
||||
&& let Err(e) = self.host.require_api(kind.name(), 18)
|
||||
{
|
||||
return Ok(Err(to_wit(e)));
|
||||
}
|
||||
if kind == EventKind::DocumentChanged {
|
||||
return Ok(Err(wit::Error::Invalid(
|
||||
"document-changed is delivered only for paths named with subscribe-paths".into(),
|
||||
@@ -1621,6 +1648,28 @@ impl events::Host for StoreData {
|
||||
Ok(self.host.subscribe_paths(&kind, globs).map_err(to_wit))
|
||||
}
|
||||
|
||||
fn subscribe_paths_with_options(
|
||||
&mut self,
|
||||
kind: String,
|
||||
options: bindings::openidea::plugin::events::SubscriptionOptions,
|
||||
) -> Fallible<()> {
|
||||
if let Err(e) = self.require(Capability::Events) {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
if let Err(e) = self.host.require_api("subscribe-paths-with-options", 18) {
|
||||
return Ok(Err(to_wit(e)));
|
||||
}
|
||||
if kind == EventKind::DocumentChanged.name() {
|
||||
if let Err(e) = self.host.require_api(&kind, 6) {
|
||||
return Ok(Err(to_wit(e)));
|
||||
}
|
||||
if let Err(e) = self.require(Capability::ProjectRead).and_then(|_| self.require(Capability::EditorRead)) {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
}
|
||||
Ok(self.host.subscribe_paths_with_options(&kind, options.globs, options.debounce_ms).map_err(to_wit))
|
||||
}
|
||||
|
||||
fn unsubscribe(&mut self, kind: String) -> wasmtime::Result<()> {
|
||||
self.host.unsubscribe(&kind);
|
||||
Ok(())
|
||||
@@ -2558,8 +2607,12 @@ impl StoreData {
|
||||
if let Err(e) = self.require(Capability::Process(target.program.clone())) {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
let root = self.table.get(&project)?.root.clone();
|
||||
Ok(self.host.register_run_target(&root, target).map_err(to_wit))
|
||||
let res = self.table.get(&project)?;
|
||||
let root = res.root.clone();
|
||||
// Components built for API 1.18 or later have a registration from an outdated
|
||||
// handle refused; older ones keep registering whatever the generation.
|
||||
let generation = self.host.require_api("project.generation", 18).is_ok().then_some(res.generation);
|
||||
Ok(self.host.register_run_target(&root, target, generation).map_err(to_wit))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ fn the_sdk_carries_the_hosts_wit() {
|
||||
|
||||
#[test]
|
||||
fn the_version_check_runs_compatible_components_and_explains_the_rest() {
|
||||
let host = v("1.17.0");
|
||||
let host = v("1.18.0");
|
||||
for ok in [
|
||||
"1.0.0",
|
||||
"1.3.0",
|
||||
@@ -113,15 +113,16 @@ fn the_version_check_runs_compatible_components_and_explains_the_rest() {
|
||||
"1.15.0",
|
||||
"1.16.0",
|
||||
"1.17.0",
|
||||
"1.18.0",
|
||||
"1.0.0-rc.1",
|
||||
] {
|
||||
assert_eq!(check_api(&v(ok), &host), Ok(()), "{ok}");
|
||||
}
|
||||
let newer = check_api(&v("1.18.0"), &host).unwrap_err();
|
||||
assert!(newer.contains("1.18") && newer.contains("update OpenIDEA"), "{newer}");
|
||||
let newer = check_api(&v("1.19.0"), &host).unwrap_err();
|
||||
assert!(newer.contains("1.19") && newer.contains("update OpenIDEA"), "{newer}");
|
||||
assert!(check_api(&v("2.0.0"), &host).unwrap_err().contains("update OpenIDEA"));
|
||||
let older = check_api(&v("0.2.0"), &host).unwrap_err();
|
||||
assert!(older.contains("rebuild it with the 1.17 SDK"), "{older}");
|
||||
assert!(older.contains("rebuild it with the 1.18 SDK"), "{older}");
|
||||
// 0.x: every minor is its own API.
|
||||
assert_eq!(check_api(&v("0.2.0"), &v("0.2.5")), Ok(()));
|
||||
assert!(check_api(&v("0.1.0"), &v("0.2.0")).is_err());
|
||||
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
98e9c2b886df177bafb68a712fc1efadc4f3a7b82e8425cd1b3f4c2355bdb785
|
||||
2d0bb09d07cdf7cbc3d2a9618bb32e35b75ff8ec40fc378c756815865ba47725
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
bb77bc0963451ca4259591bf68c72ae3eb70b1c6f855fa29dfc84d2be675404c
|
||||
d6e0036ccff4096968cea93ef656a52005131ef4b45117a6e1486242873a79e7
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
f381b0e20520bccf5acd46b95641f5542885184352e52ec2fed3fd53665c353b
|
||||
9db4e34b54a2acd5e7586174e8d4354aac83d5dabf9450e25ab8d524dff67b7c
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
f72a53e7b800b8c5408c7ac67034821f814da7b1d66f527949450431bcf52e02
|
||||
aa6ec897e2c59c139c968dd36214cda359c95987399306874030fc9c5b958ccd
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
3cd2f02738b07d9a6294025cbcc6e906716d3e91db50a6f39485df9b1d6a4ead
|
||||
52869943d267af05daa68772a178bca7a23a7a053089dcd129cc67631681ea2c
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
d77b80884163628791b292acc59324d3b9a7c2236034b88f87e8f56af5929a48
|
||||
bfaff884686b1592ddc028ed0825f6861c1872b2506f0f74dbe094559749d395
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
5a79d35e9fc1560a39b6459312a14c27c73739fd385f6c2568f9b1c1bf8fe4a1
|
||||
3d73ed4a08fcf254554f7b64a0b66b778e86b9545b5918cf07a8a347141b6927
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
264be0e527b0cc200e2d97e982b7b297ef6181a7669506ccf09159531f91124d
|
||||
131e030a6bee0b1bb3e70506df350425b187ccac3d6a96e7cb058f301cd20a95
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
6230dce145f2cce3033c4797566cbbff8c98e5d8c85d41f9342693b19a10b638
|
||||
728049d4340823120e1824cdeb58f7dbdfa8199ab1d013c0eac316176e5d069a
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
3d7d853fa40ce14ae6781dbf5607153c4f38b2663a31f1ca29a753e8eba79f03
|
||||
622867d8d6ce8d3319ad18ce3f1f14ed8fd9601de694e1e9793cb6ee5c939124
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
a128c5f640b42d323059a7be1bd2e89cb9de1ea1ea635b5af4e9f69b66bfd04c
|
||||
6f738d8dca89c5c641586ab9bdc014e8e71c30528cd8d5beae75f4935fb3be41
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
9e00f4bcad39a99f05c35ac66962a574f7edd5713f1aa404ef72fd7ef945d1e8
|
||||
81e08cf108648dfc1840305c130c57d114d458144fbaff61e10382eaf147772f
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
7e0ae6bfc8217c37a68e9010920a5bd3478f654b6cfaf3f54e0ef5aacae546b8
|
||||
7444e3a5a34311e130484629f17a903bf4637fbc5f88558e48e99fa43022d934
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
97c4d6aaf88d552d736021e21bb1f1e1594800ceb771644eb1f3356c0efbc42a
|
||||
e6ce585b9f3b2cf0696589a705e4b67d151f7ca2411dda797c4d7fa5aef941a2
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
5a65f921bb1f0ed0f0f10811f8960d9ea9e7ded59d5172356e7cc93f05b4bd5e
|
||||
101bdc411e11194a9d21af7b11672251f82ca8be8938904d94cc468abd81bad0
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
2d148151a9b0a2ab4c479183e3d2ab07d0432d8645dbf95c0e04385ef25830d8
|
||||
26f79e9410134c994e3edb364e27ca0c63817ff3924e3196e300db3d2eb6ced4
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
63136a78f4279b140c74ff07146b79ca2ce6c7a4fffd6176e811828aad911e0e
|
||||
945ebbfc10374403b1d48615d98db427c33c8f22635a48ca37f6411149cfd38a
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
e6bf5c74e18ab47577c1e88294fa4961fe8a1e56fb3e34fec5154dab74dfd805
|
||||
40b27db08ef90163db19773b300f7c9ad69ca0da224b0267f6e0fa453b816c2a
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
ad5a9fef07a6e9db8fe0375d0ba9d2e92247c28303876ac52db2dbf938bf96ae
|
||||
c3e1c21305aaf34b6ccff59893bc480b11b3a40f5c6b5cebb313881300f47547
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
fdbcd1afce0d106be463ef43d31245fcb4b9e84287ede78fb8abe740ea28b247
|
||||
794abcda7f1ec4b5b42caae651fd6862b672701d6c287d562adb282c0c16931d
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
c9eb17c9f7e334b05bc5104204fb12a88dceafe36dbd04510e439539f2a1d464
|
||||
205d5d2c5232e0ad0c3761ca9722c06bd9f6e61ab8078cb11e9beab73810ae41
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
14ba72bbc8013b8e2a7f87e85a7046edc4fb4a2256f3fae3ac735241096e4428
|
||||
b0bbfbabaf1c9f08d0e6fb383a103753b7bda6bacd9df850b7b82645597b04a8
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
91b190eb62077bde52916a09d76a474584725e73cf3acf45613aecbc8c37c421
|
||||
e216e7b567d8570f5fd69fc439db1c69ea04dd293a57bd554757f191560d7459
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
90b20d5ec2d36fa585e3f921672b6477c9691f184151f7059dd429fd7ccc09cf
|
||||
d43b48a9e2250f059164a44569b2c9ac253870156267106baf576081924cdf99
|
||||
@@ -5,9 +5,9 @@ wit_bindgen::generate!({
|
||||
inline: "
|
||||
package fixture:misbehave;
|
||||
world misbehave {
|
||||
include openidea:plugin/plugin-syntax@1.17.0;
|
||||
export openidea:plugin/providers@1.17.0;
|
||||
export openidea:plugin/file-actions@1.17.0;
|
||||
include openidea:plugin/plugin-syntax@1.18.0;
|
||||
export openidea:plugin/providers@1.18.0;
|
||||
export openidea:plugin/file-actions@1.18.0;
|
||||
}
|
||||
",
|
||||
path: "../../../../../wit",
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
id = "overlay"
|
||||
name = "Overlay Probe"
|
||||
version = "0.1.0"
|
||||
description = "Test fixture for [[contributes.overlays]]: a card floating over the workbench that moves itself around with openidea.overlay.place, no code."
|
||||
engines.openidea = "^1.18"
|
||||
|
||||
[[contributes.overlays]]
|
||||
id = "probe"
|
||||
web = "web/index.html"
|
||||
width = 260
|
||||
height = 140
|
||||
@@ -0,0 +1,44 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
html, body { margin: 0; height: 100%; background: transparent; }
|
||||
.card {
|
||||
box-sizing: border-box;
|
||||
height: 100%;
|
||||
padding: 12px;
|
||||
border-radius: 10px;
|
||||
background: var(--openidea-bg-elevated);
|
||||
border: 1px solid var(--openidea-border);
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
|
||||
font: var(--openidea-font-size) var(--openidea-font-ui);
|
||||
color: var(--openidea-fg);
|
||||
}
|
||||
button { font: inherit; margin: 8px 6px 0 0; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="card">
|
||||
<strong>Overlay probe</strong>
|
||||
<div id="where"></div>
|
||||
<button id="move" type="button">Next anchor</button>
|
||||
<button id="grow" type="button">Toggle size</button>
|
||||
</div>
|
||||
<script>
|
||||
const anchors = ["top-left", "top-center", "top-right", "middle-right", "bottom-right", "bottom-center", "bottom-left", "middle-left", "center"];
|
||||
let at = anchors.indexOf("bottom-right");
|
||||
let big = false;
|
||||
const show = (p) => { document.getElementById("where").textContent = `${p.anchor}, ${p.width}×${p.height}`; };
|
||||
openidea.overlay.get().then(show);
|
||||
document.getElementById("move").onclick = () => {
|
||||
at = (at + 1) % anchors.length;
|
||||
openidea.overlay.place({ anchor: anchors[at] }).then(show);
|
||||
};
|
||||
document.getElementById("grow").onclick = () => {
|
||||
big = !big;
|
||||
openidea.overlay.place(big ? { width: 360, height: 220 } : { width: 260, height: 140 }).then(show);
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
0f7fc3035725b0262925b9e062bb72bf1e875eab4aa1eb040df4c1708db7c4bd
|
||||
93b7f8dc31585d6a051a86516caaa9154052cdd8026ddd111b174ac0546eae7d
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
0dc9ad2f7c8c73c92e36cf709e5275d13ed4f5067b1322f0a76160ff92bf8bdc
|
||||
1e36cfed570acfd91c33c0c3dda6b152718952be9a6601a6f6ba4becdd2ecc19
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
6e17ea89659c70e925075d2825d34c61252ab511ccb2bdbad7af29d76b97b84e
|
||||
fcac7e5247c63d7a805cb8fce2394f0f28e4ada9c5f76f6452fb4d93824ade82
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
2d221e76206dac71941d749626700537e003642fc862934e832366f73b862831
|
||||
cfc728324c24b473fdcc50cd76d1575f737abb1d1440bdc1050f83a63685b36a
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
b6ac119e4a85cf0c53bce81d1fe70a3c086c7c3764f1cbc6bd19878da124cc97
|
||||
acfaa586ed58043475302adef73e7d7a9d99a28bb170fd0b64fecfed51b5f068
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
c71e5ea2112f545be3b3c1afadd20c46f931632ee78feeb06e0945a550bc76d3
|
||||
8030c07227ca7fa8dab0492d099b007e2fc32e5c50a28b00c706b93b006d4497
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
1b29775537e80017a5d1e5999bbc611204c696f0951818664533b51e3903f3d6
|
||||
f655de0e10d2c3cbb9dcd38635a294aba45f88878da4310f136068166088541e
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
92b03822689a82c8479751af6b6dfd593ad7a1f0a8e55071819520fdccd90570
|
||||
9f6ca223bfa6fb8f69230ba0be2e95b17d07f28f7cf4637bf43550390992515a
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
a8a8b4b2fd8f506f22734d07aa3375dca027aae9eac1d4b243997482c46561c1
|
||||
d52f7d9e005a195a881886fbdb4f43b0004466d71ce750fcfd79f401f9f21abf
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
51b39ce770af475df93655210932a43616d43653209ade5c5402183f4b63950a
|
||||
8fe92b78ef2f6cab1a14b4748fec206065a1e477161ac113c2ce9e4c172ffdc8
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
0bc832accea72dae9df6e95c985ee5ac330cb9b8fb6a0608d9ddeabcd9668610
|
||||
0bffd160819041d96d81ebf5ae6961c232dff8dda381a6889813c260196a2202
|
||||
@@ -8,8 +8,7 @@ use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
|
||||
/// Files above this size open with expensive features (LSP, tree-sitter
|
||||
/// structure, folding) disabled.
|
||||
/// Files above this size open with reduced editor features.
|
||||
pub const LARGE_FILE_THRESHOLD: u64 = 5 * 1024 * 1024;
|
||||
/// Files above this size open read-only.
|
||||
pub const READ_ONLY_THRESHOLD: u64 = 50 * 1024 * 1024;
|
||||
|
||||
@@ -29,8 +29,8 @@ pub struct DocumentInfo {
|
||||
/// (archive entries, JDT sources with an editable attachment encoding,
|
||||
/// Git revisions); false for server-generated content (decompiled code).
|
||||
pub can_reload_encoding: bool,
|
||||
/// Larger than `ide_vfs::LARGE_FILE_THRESHOLD`: language servers, syntax
|
||||
/// structure and folding are disabled; the editor should drop heavy features.
|
||||
/// Marks files above `ide_vfs::LARGE_FILE_THRESHOLD` for reduced editor
|
||||
/// features such as disabling language servers and folding.
|
||||
#[specta(optional)]
|
||||
pub large: bool,
|
||||
/// Effective `.editorconfig` properties, when any section applies.
|
||||
|
||||
@@ -116,6 +116,8 @@ Each contribution point is a table (`[contributes.settings]`) or an array of tab
|
||||
| `customEditors` | `id`, `title`, `patterns`, `priority`, `layout?`, `web?` | without `web` | [Views and decorations](/en/plugins/guides/views) |
|
||||
| `markerIcons` | `id`, `icon`, `iconDark?`, `markers?`, `tooltip?` (API 1.3): gutter marker icons | no | [Language features](/en/plugins/guides/language-features) |
|
||||
| `editorPanels` | `id`, `web`, `width`, `when?` (API 1.9; needs `editor.read`) | no | [README: Editor panels](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#editor-panels) |
|
||||
| `overlays` | `id`, `web`, `width`, `height`, `anchor?`, `when?`, `interactive?` (API 1.18) | no | [README: Overlays](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#overlays) |
|
||||
| `dialogs` | `id`, `title`, `web`, `width`, `height` (API 1.18) | no | [README: Dialogs](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#dialogs) |
|
||||
| `fileIcons` | `id`, `patterns`, `icon`, `iconDark?` | no | [Icon themes](/en/plugins/guides/icon-themes) |
|
||||
| `fileTemplates` | `id`, `name`, `extension`, `path`; API 1.3: `fileName`, `variables` | no | [File actions](/en/plugins/guides/file-actions) |
|
||||
| `snippets` | `language`, `path` (API 1.4) | no | [Language features](/en/plugins/guides/language-features) |
|
||||
|
||||
@@ -12,26 +12,27 @@ The plugin API has one version number: the version of the WIT package in [`wit/`
|
||||
|
||||
## Versions
|
||||
|
||||
| API | Shipped with | Highlights |
|
||||
| ------ | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 1.0.0 | OpenIDEA 0.1.36 | The base API: commands, events, storage, tasks, project and editor access, VCS, diagnostics, network and secrets, processes, declarative views and custom editors, settings, editor providers, syntax provider |
|
||||
| 1.1.0 | OpenIDEA 0.1.37 | `vcs.remotes`, `ui.copy-to-clipboard`, `ui.open-url`, opening a project file at a line from a view |
|
||||
| 1.2.0 | OpenIDEA 0.1.38 | Background document indexers, pickers, input boxes and confirmations, plugin context keys for `when` clauses, the files selected in the Project view, a manifest `icon`, the `viewItem.context` menu |
|
||||
| 1.3.0 | OpenIDEA 0.1.39 | Commit message and before-commit checks, Services detail panes, diagnostics while typing, hover, inlay hints, semantic tokens, file-changing code actions, HTTP endpoints, files outside the project (`fs.read`/`fs.write`, `project.write`, private plugin directory), batched `files-changed` events and path filters, workspace symbols, long-running processes, notifications with buttons, translations, multi-page settings, file template variables, web view PTYs, log tabs and content tabs |
|
||||
| 1.4.0 | OpenIDEA 0.1.40 | `net.http:`, `ipc:`, `ide.commands` and `database.sources` capabilities; editor and project snapshots, decorations, text search, Problems, Git log/blame/diff; output channels; OAuth loopback; runs, terminal sessions, run configurations, test result parsing and run targets; formatting and other language features; embedded languages; snippets; more menu locations; database sources; MCP tools |
|
||||
| 1.5.0 | OpenIDEA 0.1.41 | `Project::notify` (a notification in one project's window), the `net:ask` capability, run target validation, per-command run target working-directory arguments |
|
||||
| 1.6.0 | OpenIDEA 0.1.43 | Bounded, project-bound background WebSockets for event-stream plugins |
|
||||
| 1.7.0 | OpenIDEA 0.1.44 | `views.open-diff`: two texts in the diff viewer, such as a review's file before and after |
|
||||
| 1.8.0 | OpenIDEA 0.1.45 | The `problems-changed` workbench event: the host keeps every producer's diagnostics per file, so an annotation follows the file rather than the invoking window |
|
||||
| 1.9.0 | OpenIDEA 0.1.46 | Run configurations with an environment and a debugger, requests to a running language server (`lsp:<server>`), server commands routed to plugins, editor panels |
|
||||
| 1.10.0 | OpenIDEA 0.1.47 | `build.dependencies`: the Maven / Gradle dependency graph the IDE resolved (`build.read`) |
|
||||
| 1.11.0 | In development on `main` | `ui.read-clipboard`: the clipboard's text and image in commands the user ran (`clipboard.read`) |
|
||||
| 1.12.0 | In development on `main` | `ui.set-console-rules`: highlight rules (regex, palette colours, styles) for Run and Debug console output |
|
||||
| 1.13.0 | OpenIDEA 0.1.49 | Optional `search-provider` export and `searchCategories`: custom Search Everywhere tabs with cancellable queries |
|
||||
| 1.14.0 | In development on `main` | Optional `hover-actions` export: left-edge line actions revealed by line-edge hover, with an anchor line and inclusive trigger range; `[[contributes.javaAgents]]` `vmOptions` / `jdk`: JVM flags (optionally JetBrains Runtime–only) before `-javaagent:`; `ui.set-status-item-menu` / `set-window-status-item-menu`: a menu on a status bar item |
|
||||
| 1.15.0 | In development on `main` | `caret-moved` event; declarative `[[contributes.skills]]` (`path = "skills/<name>/SKILL.md"`) for bundling agent skills in plugins |
|
||||
| 1.16.0 | OpenIDEA 0.1.52 | Optional `completion-list-provider` export: completion marked incomplete is asked again while typing on, without re-asking the language server or other plugins; `decorations.set-markdown`: line-end decorations whose hover is a Markdown card |
|
||||
| 1.17.0 | In development on `main` | `decorations.set-styled`: editor decorations with their own `#rrggbb` / `#rrggbbaa` foreground and background, for colors outside the theme palette |
|
||||
| API | Shipped with | Highlights |
|
||||
| ------ | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 1.0.0 | OpenIDEA 0.1.36 | The base API: commands, events, storage, tasks, project and editor access, VCS, diagnostics, network and secrets, processes, declarative views and custom editors, settings, editor providers, syntax provider |
|
||||
| 1.1.0 | OpenIDEA 0.1.37 | `vcs.remotes`, `ui.copy-to-clipboard`, `ui.open-url`, opening a project file at a line from a view |
|
||||
| 1.2.0 | OpenIDEA 0.1.38 | Background document indexers, pickers, input boxes and confirmations, plugin context keys for `when` clauses, the files selected in the Project view, a manifest `icon`, the `viewItem.context` menu |
|
||||
| 1.3.0 | OpenIDEA 0.1.39 | Commit message and before-commit checks, Services detail panes, diagnostics while typing, hover, inlay hints, semantic tokens, file-changing code actions, HTTP endpoints, files outside the project (`fs.read`/`fs.write`, `project.write`, private plugin directory), batched `files-changed` events and path filters, workspace symbols, long-running processes, notifications with buttons, translations, multi-page settings, file template variables, web view PTYs, log tabs and content tabs |
|
||||
| 1.4.0 | OpenIDEA 0.1.40 | `net.http:`, `ipc:`, `ide.commands` and `database.sources` capabilities; editor and project snapshots, decorations, text search, Problems, Git log/blame/diff; output channels; OAuth loopback; runs, terminal sessions, run configurations, test result parsing and run targets; formatting and other language features; embedded languages; snippets; more menu locations; database sources; MCP tools |
|
||||
| 1.5.0 | OpenIDEA 0.1.41 | `Project::notify` (a notification in one project's window), the `net:ask` capability, run target validation, per-command run target working-directory arguments |
|
||||
| 1.6.0 | OpenIDEA 0.1.43 | Bounded, project-bound background WebSockets for event-stream plugins |
|
||||
| 1.7.0 | OpenIDEA 0.1.44 | `views.open-diff`: two texts in the diff viewer, such as a review's file before and after |
|
||||
| 1.8.0 | OpenIDEA 0.1.45 | The `problems-changed` workbench event: the host keeps every producer's diagnostics per file, so an annotation follows the file rather than the invoking window |
|
||||
| 1.9.0 | OpenIDEA 0.1.46 | Run configurations with an environment and a debugger, requests to a running language server (`lsp:<server>`), server commands routed to plugins, editor panels |
|
||||
| 1.10.0 | OpenIDEA 0.1.47 | `build.dependencies`: the Maven / Gradle dependency graph the IDE resolved (`build.read`) |
|
||||
| 1.11.0 | In development on `main` | `ui.read-clipboard`: the clipboard's text and image in commands the user ran (`clipboard.read`) |
|
||||
| 1.12.0 | In development on `main` | `ui.set-console-rules`: highlight rules (regex, palette colours, styles) for Run and Debug console output |
|
||||
| 1.13.0 | OpenIDEA 0.1.49 | Optional `search-provider` export and `searchCategories`: custom Search Everywhere tabs with cancellable queries |
|
||||
| 1.14.0 | In development on `main` | Optional `hover-actions` export: left-edge line actions revealed by line-edge hover, with an anchor line and inclusive trigger range; `[[contributes.javaAgents]]` `vmOptions` / `jdk`: JVM flags (optionally JetBrains Runtime–only) before `-javaagent:`; `ui.set-status-item-menu` / `set-window-status-item-menu`: a menu on a status bar item |
|
||||
| 1.15.0 | In development on `main` | `caret-moved` event; declarative `[[contributes.skills]]` (`path = "skills/<name>/SKILL.md"`) for bundling agent skills in plugins |
|
||||
| 1.16.0 | OpenIDEA 0.1.52 | Optional `completion-list-provider` export: completion marked incomplete is asked again while typing on, without re-asking the language server or other plugins; `decorations.set-markdown`: line-end decorations whose hover is a Markdown card |
|
||||
| 1.17.0 | OpenIDEA 0.1.53 | `decorations.set-styled`: editor decorations with their own `#rrggbb` / `#rrggbbaa` foreground and background, for colors outside the theme palette |
|
||||
| 1.18.0 | In development on `main` | `[[contributes.overlays]]`: a package web page floating over the workbench that never takes the keyboard focus, placed and resized through `openidea.overlay`; `[[contributes.dialogs]]`: a package web page in a modal, resizable IDE dialog opened with `views.reveal`, with a `closed` view event and `openidea.dialog.close()`; `events.subscribe-paths-with-options` (`debounce-ms`), `workspace.project.generation` and `FilesChanged` project/generation fields, stale run target/configuration rejection, and the `project-closed` lifecycle event |
|
||||
|
||||
The full list of what each version added is in [`plugins/README.md`](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md).
|
||||
|
||||
|
||||
@@ -100,35 +100,37 @@ optional = ["net:api.openai.com", "secrets"]
|
||||
|
||||
每个贡献点是一张表(`[contributes.settings]`)或一个表数组(`[[contributes.commands]]`)。插件启用后贡献立即生效,不需要等代码加载。
|
||||
|
||||
| 贡献点 | 声明字段 | 需要代码 | 指南 |
|
||||
| ------------------- | ---------------------------------------------------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `commands` | `id`、`title`、`category?`、`when?`、`icon?` | 执行时需要 | [命令与动作](/zh/plugins/guides/commands) |
|
||||
| `menus` | `menu`、`command`、`when?`、`view?`、`submenu?` | 否 | [命令与动作](/zh/plugins/guides/commands) |
|
||||
| `keymaps` | `command`、`key`、`mac?`、`when?`(仅 Escape) | 否 | [命令与动作](/zh/plugins/guides/commands) |
|
||||
| `statusBar` | `id`、`text`、`tooltip?`、`command?`、`align?`、`priority?` | 否 | [视图与装饰](/zh/plugins/guides/views) |
|
||||
| `settings` | `schema`(JSON 文件)或 `pages`(API 1.3)、`title?` | 否 | [生命周期与事件](/zh/plugins/lifecycle) |
|
||||
| `secrets` | `name`、`label`、`description?` | 使用时需要 | [权限与能力](/zh/plugins/capabilities) |
|
||||
| `providers` | `kinds`、`languages` | 是 | [语言功能](/zh/plugins/guides/language-features) |
|
||||
| `documentIndexers` | `extensions` | 是 | [索引](/zh/plugins/guides/indexing) |
|
||||
| `endpoints` | `files`(API 1.3) | 是 | [README:Project HTTP endpoints](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#project-http-endpoints-api-13) |
|
||||
| `searchCategories` | `id`、`title`(API 1.13) | 是 | [自定义搜索分类](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#custom-search-everywhere-categories-api-111) |
|
||||
| `views` | `id`、`title`、`icon?`、`location`、`web?`、`group?`、`when?` | 无 `web` 时需要 | [视图与装饰](/zh/plugins/guides/views) |
|
||||
| `customEditors` | `id`、`title`、`patterns`、`priority`、`layout?`、`web?` | 无 `web` 时需要 | [视图与装饰](/zh/plugins/guides/views) |
|
||||
| `markerIcons` | `id`、`icon`、`iconDark?`、`markers?`、`tooltip?`(API 1.3):装订区标记图标 | 否 | [语言功能](/zh/plugins/guides/language-features) |
|
||||
| `editorPanels` | `id`、`web`、`width`、`when?`(API 1.9;需要 `editor.read`) | 否 | [README:Editor panels](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#editor-panels) |
|
||||
| `fileIcons` | `id`、`patterns`、`icon`、`iconDark?` | 否 | [图标主题](/zh/plugins/guides/icon-themes) |
|
||||
| `fileTemplates` | `id`、`name`、`extension`、`path`;API 1.3:`fileName`、`variables` | 否 | [文件操作](/zh/plugins/guides/file-actions) |
|
||||
| `snippets` | `language`、`path`(API 1.4) | 否 | [语言功能](/zh/plugins/guides/language-features) |
|
||||
| `commitChecks` | `id`、`title` | 是 | [README:Commits](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#commits) |
|
||||
| `serverCommands` | `server`、`command`、`run`(API 1.9) | 是 | [README:Commands a server hands to the client](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#commands-a-server-hands-to-the-client) |
|
||||
| `runDetectors` | `id`、`name`、`files`、`command`、`args?`、`test?`、`framework?` | 否 | [运行目标](/zh/plugins/guides/run-targets) |
|
||||
| `runConfigurations` | `files`(API 1.4) | 是 | [运行目标](/zh/plugins/guides/run-targets) |
|
||||
| `javaAgents` | `path`、`args?`(API 1.10);`vmOptions?`、`jdk?`(API 1.14) | 否 | [README:Java agents](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#java-agents-api-110) |
|
||||
| `skills` | `path`(`skills/<name>/SKILL.md`,API 1.15) | 否 | [README:API 1.15](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#api-115) |
|
||||
| `mcpTools` | `name`、`description`、`inputSchema`、`readOnly`、`destructive`(API 1.4) | 是 | [MCP 工具](/zh/plugins/guides/mcp) |
|
||||
| `themes` | `path`、`editor-scheme?` | 否 | [主题](/zh/plugins/guides/themes) |
|
||||
| `iconThemes` | `id`、`label`、`path` | 否 | [图标主题](/zh/plugins/guides/icon-themes) |
|
||||
| `languages` | `path`(`languages/<id>.toml` 格式的文件) | 否 | [添加语言](/zh/languages/adding) |
|
||||
| 贡献点 | 声明字段 | 需要代码 | 指南 |
|
||||
| ------------------- | ------------------------------------------------------------------------------ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `commands` | `id`、`title`、`category?`、`when?`、`icon?` | 执行时需要 | [命令与动作](/zh/plugins/guides/commands) |
|
||||
| `menus` | `menu`、`command`、`when?`、`view?`、`submenu?` | 否 | [命令与动作](/zh/plugins/guides/commands) |
|
||||
| `keymaps` | `command`、`key`、`mac?`、`when?`(仅 Escape) | 否 | [命令与动作](/zh/plugins/guides/commands) |
|
||||
| `statusBar` | `id`、`text`、`tooltip?`、`command?`、`align?`、`priority?` | 否 | [视图与装饰](/zh/plugins/guides/views) |
|
||||
| `settings` | `schema`(JSON 文件)或 `pages`(API 1.3)、`title?` | 否 | [生命周期与事件](/zh/plugins/lifecycle) |
|
||||
| `secrets` | `name`、`label`、`description?` | 使用时需要 | [权限与能力](/zh/plugins/capabilities) |
|
||||
| `providers` | `kinds`、`languages` | 是 | [语言功能](/zh/plugins/guides/language-features) |
|
||||
| `documentIndexers` | `extensions` | 是 | [索引](/zh/plugins/guides/indexing) |
|
||||
| `endpoints` | `files`(API 1.3) | 是 | [README:Project HTTP endpoints](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#project-http-endpoints-api-13) |
|
||||
| `searchCategories` | `id`、`title`(API 1.13) | 是 | [自定义搜索分类](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#custom-search-everywhere-categories-api-111) |
|
||||
| `views` | `id`、`title`、`icon?`、`location`、`web?`、`group?`、`when?` | 无 `web` 时需要 | [视图与装饰](/zh/plugins/guides/views) |
|
||||
| `customEditors` | `id`、`title`、`patterns`、`priority`、`layout?`、`web?` | 无 `web` 时需要 | [视图与装饰](/zh/plugins/guides/views) |
|
||||
| `markerIcons` | `id`、`icon`、`iconDark?`、`markers?`、`tooltip?`(API 1.3):装订区标记图标 | 否 | [语言功能](/zh/plugins/guides/language-features) |
|
||||
| `editorPanels` | `id`、`web`、`width`、`when?`(API 1.9;需要 `editor.read`) | 否 | [README:Editor panels](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#editor-panels) |
|
||||
| `overlays` | `id`、`web`、`width`、`height`、`anchor?`、`when?`、`interactive?`(API 1.18) | 否 | [README:Overlays](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#overlays) |
|
||||
| `dialogs` | `id`、`title`、`web`、`width`、`height`(API 1.18) | 否 | [README:Dialogs](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#dialogs) |
|
||||
| `fileIcons` | `id`、`patterns`、`icon`、`iconDark?` | 否 | [图标主题](/zh/plugins/guides/icon-themes) |
|
||||
| `fileTemplates` | `id`、`name`、`extension`、`path`;API 1.3:`fileName`、`variables` | 否 | [文件操作](/zh/plugins/guides/file-actions) |
|
||||
| `snippets` | `language`、`path`(API 1.4) | 否 | [语言功能](/zh/plugins/guides/language-features) |
|
||||
| `commitChecks` | `id`、`title` | 是 | [README:Commits](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#commits) |
|
||||
| `serverCommands` | `server`、`command`、`run`(API 1.9) | 是 | [README:Commands a server hands to the client](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#commands-a-server-hands-to-the-client) |
|
||||
| `runDetectors` | `id`、`name`、`files`、`command`、`args?`、`test?`、`framework?` | 否 | [运行目标](/zh/plugins/guides/run-targets) |
|
||||
| `runConfigurations` | `files`(API 1.4) | 是 | [运行目标](/zh/plugins/guides/run-targets) |
|
||||
| `javaAgents` | `path`、`args?`(API 1.10);`vmOptions?`、`jdk?`(API 1.14) | 否 | [README:Java agents](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#java-agents-api-110) |
|
||||
| `skills` | `path`(`skills/<name>/SKILL.md`,API 1.15) | 否 | [README:API 1.15](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#api-115) |
|
||||
| `mcpTools` | `name`、`description`、`inputSchema`、`readOnly`、`destructive`(API 1.4) | 是 | [MCP 工具](/zh/plugins/guides/mcp) |
|
||||
| `themes` | `path`、`editor-scheme?` | 否 | [主题](/zh/plugins/guides/themes) |
|
||||
| `iconThemes` | `id`、`label`、`path` | 否 | [图标主题](/zh/plugins/guides/icon-themes) |
|
||||
| `languages` | `path`(`languages/<id>.toml` 格式的文件) | 否 | [添加语言](/zh/languages/adding) |
|
||||
|
||||
条目 id(命令、视图、主题等)匹配 `[a-z0-9][a-z0-9._-]*`,不超过 64 个字符。菜单、快捷键和状态栏项只能引用插件自己声明的命令;在 IDE 内部,命令的操作 id 是 `plugin.<plugin id>.<command id>`。
|
||||
|
||||
|
||||
Loaded 100 of 293 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Заблокувати користувача