diff --git a/crates/ide-extension/src/manifest.rs b/crates/ide-extension/src/manifest.rs index f46e043b8..75beb83e4 100644 --- a/crates/ide-extension/src/manifest.rs +++ b/crates/ide-extension/src/manifest.rs @@ -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.9.0"; +pub const ENGINE_VERSION: &str = "1.10.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. diff --git a/crates/ide-host/src/plugins/api.rs b/crates/ide-host/src/plugins/api.rs index 4d902d451..c6fc0d49d 100644 --- a/crates/ide-host/src/plugins/api.rs +++ b/crates/ide-host/src/plugins/api.rs @@ -1551,13 +1551,8 @@ impl HostApi for PluginApi { } Ok(()) } - fn open_diff( - &self, - client: &str, - diff: ide_plugin::ContentDiff, - file_name: Option, - ) -> Result<(), HostError> { - super::execution::validate_diff(&diff)?; + fn open_diff(&self, client: &str, diff: ide_plugin::FileDiff, file_name: Option) -> Result<(), HostError> { + super::execution::validate_file_diff(&diff)?; if let Some(name) = &file_name { super::execution::label(name, 256)?; } diff --git a/crates/ide-host/src/plugins/execution.rs b/crates/ide-host/src/plugins/execution.rs index ff3cbcf62..eb80b1e0e 100644 --- a/crates/ide-host/src/plugins/execution.rs +++ b/crates/ide-host/src/plugins/execution.rs @@ -91,12 +91,31 @@ fn diff_side(value: &str, side: &str) -> Result<(), HostError> { } pub(super) fn validate_diff(diff: &ide_plugin::ContentDiff) -> Result<(), HostError> { - diff_side(&diff.left, "left")?; - diff_side(&diff.right, "right")?; - for value in [&diff.left_label, &diff.right_label].into_iter().flatten() { + validate_diff_parts([Some(&diff.left), Some(&diff.right)], [&diff.left_label, &diff.right_label], &diff.title) +} + +/// A `None` side doesn't exist (an added or deleted file); at least one side does. +pub(super) fn validate_file_diff(diff: &ide_plugin::FileDiff) -> Result<(), HostError> { + validate_diff_parts([diff.left.as_ref(), diff.right.as_ref()], [&diff.left_label, &diff.right_label], &diff.title) +} + +fn validate_diff_parts( + sides: [Option<&String>; 2], + labels: [&Option; 2], + title: &Option, +) -> Result<(), HostError> { + if sides.iter().all(Option::is_none) { + return Err(HostError::Invalid("a diff needs at least one side".into())); + } + for (value, side) in sides.into_iter().zip(["left", "right"]) { + if let Some(value) = value { + diff_side(value, side)?; + } + } + for value in labels.into_iter().flatten() { label(value, 128)?; } - if let Some(title) = &diff.title { + if let Some(title) = title { label(title, 256)?; } Ok(()) @@ -713,6 +732,28 @@ mod tests { ); } + #[test] + fn a_file_diff_may_miss_one_side_but_not_both() { + let side = |left: Option<&str>, right: Option<&str>| ide_plugin::FileDiff { + left: left.map(Into::into), + right: right.map(Into::into), + ..Default::default() + }; + assert!(validate_file_diff(&side(None, Some("added\n"))).is_ok()); + assert!(validate_file_diff(&side(Some("deleted\n"), None)).is_ok()); + assert!(validate_file_diff(&side(Some(""), Some(""))).is_ok()); + assert!( + matches!(validate_file_diff(&side(None, None)), Err(HostError::Invalid(m)) if m == "a diff needs at least one side") + ); + let huge = "y".repeat(MAX_DIFF_SIDE + 1); + assert!( + matches!(validate_file_diff(&side(None, Some(&huge))), Err(HostError::Invalid(m)) if m == "diff too large: the right side is over 8 MiB") + ); + assert!( + matches!(validate_file_diff(&side(Some("a\0"), None)), Err(HostError::Invalid(m)) if m.contains("NUL")) + ); + } + fn launch( env: Vec<(&str, &str)>, debugger: Option, diff --git a/crates/ide-host/src/plugins/types.rs b/crates/ide-host/src/plugins/types.rs index 96867791c..3023bad23 100644 --- a/crates/ide-host/src/plugins/types.rs +++ b/crates/ide-host/src/plugins/types.rs @@ -220,7 +220,7 @@ pub enum PluginEvent { ContentTabReply { plugin_id: String, request_id: String, reply: ide_plugin::ContentTabReply }, /// Open two texts in this window's diff viewer. #[serde(rename_all = "camelCase")] - OpenDiff { plugin_id: String, diff: ide_plugin::ContentDiff, file_name: Option }, + OpenDiff { plugin_id: String, diff: ide_plugin::FileDiff, file_name: Option }, /// Plugins, their status or their contributions changed: re-fetch `plugin_list`. CommandsChanged, diff --git a/crates/ide-host/tests/plugins.rs b/crates/ide-host/tests/plugins.rs index 0571a4e22..8d1670946 100644 --- a/crates/ide-host/tests/plugins.rs +++ b/crates/ide-host/tests/plugins.rs @@ -6518,8 +6518,8 @@ fn a_plugin_command_opens_a_diff_in_its_window() { client.as_deref() == Some("main") && matches!(event, PluginEvent::OpenDiff { plugin_id, diff, file_name } if plugin_id == "execution" - && diff.left == "before\n" - && diff.right == "after\n" + && diff.left.as_deref() == Some("before\n") + && diff.right.as_deref() == Some("after\n") && diff.title.as_deref() == Some("Review") && file_name.as_deref() == Some("src/review.rs")) }) diff --git a/crates/ide-plugin/src/execution.rs b/crates/ide-plugin/src/execution.rs index a2c5bf46e..82854d421 100644 --- a/crates/ide-plugin/src/execution.rs +++ b/crates/ide-plugin/src/execution.rs @@ -38,6 +38,29 @@ pub struct ContentDiff { pub title: Option, } +/// A diff opened by a plugin (API 1.10): `None` is a side where the file doesn't exist. +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] +#[serde(rename_all = "camelCase")] +pub struct FileDiff { + pub left: Option, + pub right: Option, + pub left_label: Option, + pub right_label: Option, + pub title: Option, +} + +impl From for FileDiff { + fn from(v: ContentDiff) -> Self { + Self { + left: Some(v.left), + right: Some(v.right), + left_label: v.left_label, + right_label: v.right_label, + title: v.title, + } + } +} + /// ContentTabReply data exchanged with the IDE. #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] diff --git a/crates/ide-plugin/src/runtime.rs b/crates/ide-plugin/src/runtime.rs index f0aa39a25..d95af157c 100644 --- a/crates/ide-plugin/src/runtime.rs +++ b/crates/ide-plugin/src/runtime.rs @@ -56,7 +56,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.9"; +pub const API_VERSION: &str = "1.10"; const EPOCH_TICK: Duration = Duration::from_millis(10); pub(crate) const MAX_TEXT: usize = 1 << 20; pub(crate) const MAX_TITLE: usize = 256; @@ -188,8 +188,8 @@ pub trait HostApi: Send + Sync { let _ = (client, tab, cancel, timeout); Err(HostError::Failed("content tabs unavailable".into())) } - /// Opens a diff of two texts in the invoking window. - fn open_diff(&self, client: &str, diff: crate::ContentDiff, file_name: Option) -> Result<(), HostError> { + /// Opens a diff of two texts in the invoking window; a `None` side doesn't exist. + fn open_diff(&self, client: &str, diff: crate::FileDiff, file_name: Option) -> Result<(), HostError> { let _ = (client, diff, file_name); Err(HostError::Failed("diffs unavailable".into())) } diff --git a/crates/ide-plugin/src/wit_host.rs b/crates/ide-plugin/src/wit_host.rs index b0da66986..fd7f4dc2b 100644 --- a/crates/ide-plugin/src/wit_host.rs +++ b/crates/ide-plugin/src/wit_host.rs @@ -1782,6 +1782,13 @@ impl views::Host for StoreData { .map_err(to_wit)) } fn open_diff(&mut self, diff: views::ContentDiff, file_name: Option) -> Fallible<()> { + if let Err(e) = self.require_window() { + return Ok(Err(e)); + } + let diff = crate::FileDiff::from(crate::ContentDiff::from(diff)); + Ok(self.host.open_diff(self.invocation.client.as_deref().unwrap(), diff, file_name).map_err(to_wit)) + } + fn open_file_diff(&mut self, diff: views::FileDiff, file_name: Option) -> Fallible<()> { if let Err(e) = self.require_window() { return Ok(Err(e)); } @@ -2146,6 +2153,12 @@ impl From for crate::ContentDiff } } +impl From for crate::FileDiff { + fn from(v: bindings::openidea::plugin::views::FileDiff) -> Self { + Self { left: v.left, right: v.right, left_label: v.left_label, right_label: v.right_label, title: v.title } + } +} + impl From for crate::ContentTabReply { fn from(v: bindings::openidea::plugin::views::ContentTabReply) -> Self { Self { diff --git a/crates/ide-plugin/tests/api_compat.rs b/crates/ide-plugin/tests/api_compat.rs index 0cf92886f..e3be4b4e5 100644 --- a/crates/ide-plugin/tests/api_compat.rs +++ b/crates/ide-plugin/tests/api_compat.rs @@ -91,15 +91,15 @@ fn the_sdk_carries_the_hosts_wit() { #[test] fn the_version_check_runs_compatible_components_and_explains_the_rest() { - let host = v("1.9.0"); - for ok in ["1.0.0", "1.3.0", "1.4.7", "1.5.0", "1.6.0", "1.7.0", "1.8.0", "1.9.0", "1.0.0-rc.1"] { + let host = v("1.10.0"); + for ok in ["1.0.0", "1.3.0", "1.4.7", "1.5.0", "1.6.0", "1.7.0", "1.8.0", "1.9.0", "1.10.0", "1.0.0-rc.1"] { assert_eq!(check_api(&v(ok), &host), Ok(()), "{ok}"); } - let newer = check_api(&v("1.10.0"), &host).unwrap_err(); - assert!(newer.contains("1.10") && newer.contains("update OpenIDEA"), "{newer}"); + let newer = check_api(&v("1.11.0"), &host).unwrap_err(); + assert!(newer.contains("1.11") && 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.9 SDK"), "{older}"); + assert!(older.contains("rebuild it with the 1.10 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()); diff --git a/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm index fcfb43783..02e27f099 100644 Binary files a/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm.sources index 5e501f9ce..54bc3031a 100644 --- a/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm.sources @@ -1 +1 @@ -75123cf60f87ec9bdd36e0b7f75efb69d000136d74c3e9da893ecd1534bdf534 +47eb797508a8b7c4f2b8de276656a936cb7b603edf6d5cb0997fd55f06c18d74 diff --git a/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm index 4911ffedd..67097a44b 100644 Binary files a/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm.sources index 02dda1880..054f36b59 100644 --- a/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm.sources @@ -1 +1 @@ -60d66ec578e3adc7adaebbcd01aa92a74a8a7e4cfd4d1aa778f9b033c75234a6 +baabfa459d287fe78389fc5d71951248942902b9cf029ab3782cc929c1ca7bf3 diff --git a/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm index 4dc5ebf2b..42cc0c533 100644 Binary files a/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm.sources index 7cb6c39ef..d5915ad80 100644 --- a/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm.sources @@ -1 +1 @@ -df55973ed77e734e48fe1d2b7bb5d1e4eb68153b17452e4385599145427292b6 +e86a42a3716d37a7e5034d922a097487f3659691dc8879ad16e4efa63e4e030f diff --git a/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm index ed427c6c0..31b707261 100644 Binary files a/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm.sources index 56c43e0eb..7ceb25758 100644 --- a/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm.sources @@ -1 +1 @@ -94f1c4a8192e15961bd136cf9dc3416fca7b295bce0d563608a3ee9fdf81c28e +d5f2d8b20bfbd0f2dbd566dae490645f6f266f0dd87498e5476ead56ca1fe09e diff --git a/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm index 623e0827a..47b83e39c 100644 Binary files a/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm.sources index 5c5cbf847..494cb0742 100644 --- a/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm.sources @@ -1 +1 @@ -db140480eaf4352fa8db8d87aab95cb07944e19c28d2cc08e299b37c5deb4230 +65748dfb8348c17e464c2378e6b66ae0e30883aee0e1b27130078e3b970c3bf7 diff --git a/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm index 68caa11ca..a8d965c4a 100644 Binary files a/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm.sources index c55fe9846..8f18b2c27 100644 --- a/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm.sources @@ -1 +1 @@ -5fd76f6168d3a7b3259281171f375cf01da6ceabdf4ffd382c5fe7034b2e94f2 +2f25d04ba6260c54e1010b310b696428672975c3c0986aab952f534be2783847 diff --git a/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm index 3e53d3e3e..bae6b3f77 100644 Binary files a/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm.sources index 3782bb820..0ea527b5f 100644 --- a/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm.sources @@ -1 +1 @@ -5d9049fa006194e92e06de47ab933d249118706a8ba92100493318a1582f2b65 +f2bcf27e33c50fcffd3dcb3a9f7029f4774105b143d881e78b5b1c80b10f04f3 diff --git a/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm index 02eb79ab6..3d809ac8c 100644 Binary files a/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm.sources index 8e7c89900..2fbfd68e2 100644 --- a/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm.sources @@ -1 +1 @@ -c723d915b69292740a863b3a94db6f6f8c218ecda46c527229d621084f2df3b1 +88d11e9fc45c98000f296e46e8105cc83e7fbe6c248a993d82f333caab51e152 diff --git a/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm index bdcd3ac46..f31bf1ab0 100644 Binary files a/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm.sources index d806900fa..d979da399 100644 --- a/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm.sources @@ -1 +1 @@ -2dbab98cfc473650675b2691c7d0f2d5b088ffd6208e31ef30aaa54dd3b1b4b0 +52768373487be5388e5de2cc577d9c3d74eb0877ecd78a0b641188aed2d18004 diff --git a/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm index 75d6161a1..7076883b8 100644 Binary files a/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm.sources index aae459873..d8408ec6b 100644 --- a/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm.sources @@ -1 +1 @@ -1fa1515aae810e588f2c1d25728755c25fd51c78d35d96d823583052372c34dd +63368e7ba560204b6913261bc631579387e42a178cd39d106985ef114a88e54a diff --git a/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm index 200d59d0a..8c962831a 100644 Binary files a/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm.sources index a2b56dcd4..9d62cb490 100644 --- a/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm.sources @@ -1 +1 @@ -69eaf24b0ed3260a6b3656563b1d0b8b268de81899f05bc984c668b0765e361f +6466e46285c132256a03dee9814d3a8f899eab1aaedd389a7087601d2f236bcc diff --git a/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm index 56df0029f..8a861aeff 100644 Binary files a/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm.sources index fd7955a42..db2cacc4b 100644 --- a/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm.sources @@ -1 +1 @@ -c6bd0a45a6cc3b09114be55c8b63563bea4ca6b748ee27c7843bb4ab05d7ce26 +e9fa2ec856fd9c3b19a1a0b233ce55b6e844d0a6f0909018062814eff63c7d6b diff --git a/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm index 4cce5194e..26a944661 100644 Binary files a/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm.sources index f73c889ba..83d09779a 100644 --- a/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm.sources @@ -1 +1 @@ -f870210add7c920df42e276a4cefcd1eaf01b3869f238c0a366beeb052e4adc3 +26893acfd5486f2df35efb28a1719bf3306118a10b1ad346ad74e4b3318f8258 diff --git a/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm index 2fcd5b1e8..5eae31d15 100644 Binary files a/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm.sources index 97948d074..1a659b4f4 100644 --- a/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm.sources @@ -1 +1 @@ -3a3c0d4e5a1564eaa2ca35b698cd4b553722476cf68995495b9f277631b08266 +b6ebe9a4c121e4a1f6d2b4d932c8e6a89e52ab3bb957dc241fb6087130c9fe56 diff --git a/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm index 5311dd0ae..dcf1da710 100644 Binary files a/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm.sources index ce7547fea..99e9df9dd 100644 --- a/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm.sources @@ -1 +1 @@ -aab9d674d5d94b7488fe088e5c355511403edf7878c6fe124e2a2be86598ead6 +a6d0fe560d3492db63fb58a1f898d7090860f2c9dd4dc4e8b97079cd7a97c0b1 diff --git a/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm index 86cfcc3aa..c070a8335 100644 Binary files a/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm.sources index 62507af8f..668e437c9 100644 --- a/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm.sources @@ -1 +1 @@ -391ce453aa40de84ca4a6ed5f5b8ee88f5d659e8699029fa3a8940dac7d6dc9b +3eee2fe2eab305a66a5650dcc9892fed7cc028538d31ab31ed448edbdfa0cdf9 diff --git a/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm index e31948c91..4e7b2252f 100644 Binary files a/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm.sources index d3ee0fe79..ba164e3d7 100644 --- a/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm.sources @@ -1 +1 @@ -ccbb5abb90a0bb49c0f51d0e2865d1c4092e28e9168e4c57e5f7b6ea971721ac +3d76b858a8fbf868c36d19897cf85c72e516340eb3e47f27c59b8323dc53b8a3 diff --git a/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm index 5f8592957..d9bf2c034 100644 Binary files a/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm.sources index 56c86fac0..89321dfae 100644 --- a/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm.sources @@ -1 +1 @@ -6a36bd56db7148032c1fe101bec8c38e326528b1de1ee26b5d7c5b9dd80b3e94 +8d80e89b4b5025c874e467abbea578da52f61a48eeea4573645d362c530fef70 diff --git a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm index 5aeb04285..9382115ac 100644 Binary files a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources index bae4a4ca6..4908dfdc0 100644 --- a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources @@ -1 +1 @@ -9b5d0e40e7fef9e48e1a894549e4b96853b8217ad7d12fe29d238a599772a329 +f052bab94de44b140f957d360f16e6c8dd2bc5d80dd7732b62536b6e74f4e868 diff --git a/crates/ide-plugin/tests/fixtures/misbehave/src/lib.rs b/crates/ide-plugin/tests/fixtures/misbehave/src/lib.rs index 41f13f3fb..8cc33f8d1 100644 --- a/crates/ide-plugin/tests/fixtures/misbehave/src/lib.rs +++ b/crates/ide-plugin/tests/fixtures/misbehave/src/lib.rs @@ -5,9 +5,9 @@ wit_bindgen::generate!({ inline: " package fixture:misbehave; world misbehave { - include openidea:plugin/plugin-syntax@1.9.0; - export openidea:plugin/providers@1.9.0; - export openidea:plugin/file-actions@1.9.0; + include openidea:plugin/plugin-syntax@1.10.0; + export openidea:plugin/providers@1.10.0; + export openidea:plugin/file-actions@1.10.0; } ", path: "../../../../../wit", diff --git a/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm index fb6d2baa7..05266768f 100644 Binary files a/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm.sources index c73369ae0..4e3ae123d 100644 --- a/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm.sources @@ -1 +1 @@ -a11bc7b7151a62e98d665a6459b3c84e4cb836b734fd23e7bad3adc533655f81 +f9c4279e7972e89fdc0bc1849ed84b72b983b2230526b492110c4de87a843ed0 diff --git a/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm index a490523cb..ef8d54c70 100644 Binary files a/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm.sources index ecc946706..d9acd5546 100644 --- a/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm.sources @@ -1 +1 @@ -aad4871073c7c7f22ab84f1e7965d1a861b7e5ddd9f86408e95eba4c3c021411 +ae0aa9ed34eb508f388fc43b92544ebdd91c3dfcace3c281d0c32b4947ab09ce diff --git a/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm index ad5c3b83c..dcc13a629 100644 Binary files a/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm.sources index 9a4b69324..4b5295384 100644 --- a/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm.sources @@ -1 +1 @@ -f2e0df07f6d7a501e96caf43efcfdaa0596aa2b9dad5c46ef71f5ad2eddc505b +d75dcfcdb4c2f49e391e21bba9f58567937c8fbc739a853bfed8fce58cd6c753 diff --git a/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm index 1fd4796bb..c05253829 100644 Binary files a/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm.sources index 9c15450ee..d06b83594 100644 --- a/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm.sources @@ -1 +1 @@ -253f93d1254310669150f6fd629ae88223d7d6f1cd642803ec57382e5acd4451 +a25338eaf06fcd417cbd851e8447666ba25214e424c4ba7ee06919d563ff2e88 diff --git a/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm index 4c26ff1ba..647000e0c 100644 Binary files a/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm.sources index 1320926cf..fecd0794e 100644 --- a/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm.sources @@ -1 +1 @@ -9351d3248252ca35a40ce557ada29e8aa4f3135273e988235bc22ebcfd0505ec +aa9072503d07f0963b115a7ac3b5cdee008d9369263375c9621ba19259647db6 diff --git a/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm index 1afddaad3..9296441bb 100644 Binary files a/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm.sources index e1c7af5a3..53b26cb2f 100644 --- a/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm.sources @@ -1 +1 @@ -7f4ad5bc15d70de0ae7a0e96c584edcd6caef1cb18b5450685a83d8a8de16d24 +ea3b652f16052305b8cfd45216651da96af6603a1c9018bdcb61897e287a6be6 diff --git a/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm index e5246574e..81f954912 100644 Binary files a/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm.sources index 2424d0a45..74f39e37e 100644 --- a/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm.sources @@ -1 +1 @@ -7d18591aa915fd6dd71fd8f8a4a0c7d8abb2cc5ff9252a56fb0d6b7458562466 +b62841f3469339fcdd3d718963ca3a4a0971a98d770c625334ebb558613f0eb4 diff --git a/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm index 741ff7517..9fb231bfa 100644 Binary files a/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm.sources index ac2c0e17f..c5bb078ad 100644 --- a/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm.sources @@ -1 +1 @@ -55e59a27457e8f25e9bd0e727ebbc6276b0f45d210732a88ede4954ec2dc777f +535501e8df328c2d340b967de4cf0e9099d2d7ac1186a67b6cc45a88c033b2eb diff --git a/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm index a308f50ed..dc97b0317 100644 Binary files a/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm.sources index 52c8686b1..4d47b122e 100644 --- a/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm.sources @@ -1 +1 @@ -8ce7d4a12f8bd393b8b32e695d3dd2994c30ba27fb8419b8af900a550cb2da7c +29f72aaff35386bb1d340638234f7c63535b5fb2b447d19da53ed703cfa4ab8e diff --git a/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm index aafa51521..25fcd74d3 100644 Binary files a/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm.sources index 74bf1acf4..916bd565c 100644 --- a/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm.sources @@ -1 +1 @@ -f654b73781d88c25dddddcdb25e8c02195b36dc9e008dd9eafafd632a11c48c5 +e28ef416c0034a8006692fab43df24eb14fd43ac6f783e4a36ba223eac1dbff5 diff --git a/docs/en/plugins/guides/views.mdx b/docs/en/plugins/guides/views.mdx index 37a95d58d..e2f3f24f5 100644 --- a/docs/en/plugins/guides/views.mdx +++ b/docs/en/plugins/guides/views.mdx @@ -287,6 +287,7 @@ With `engines.openidea = "^1.3"`, a page can send JSON messages through | `open-log-tab` | A read-only editor tab following a program's output, with argument toggles. | | `open-content-tab` | An editor tab on content the plugin supplies, with toolbar actions answered by `content-tab-reply`. | | `open-diff` | API 1.7: the diff viewer on two texts (`left`, `right`, optional labels, `title` and `fileName` for highlighting). | +| `open-diff` with a `null` side | API 1.10: the file doesn't exist on that side (added or deleted); the diff viewer shows the other side alone. | The message fields and limits are in the [plugin guide](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#web-frame-ptys-api-13); @@ -353,6 +354,7 @@ These are called from a command or event of a window: | `host::open_log_tab(key, title, &log)` | API 1.3: the read-only log tab, from a `ProcessLog`. At most 32 per window; not yet in remote projects. | | `host::open_content_tab(&ContentTab { .. })` | API 1.4: a content editor tab without a web view; actions arrive as `content-tab-action` events, answered with `host::reply_content_tab`. | | `host::open_diff(&ContentDiff { .. }, file_name)` | API 1.7: the diff viewer on two texts, such as a review's file before and after; `file_name` picks the syntax highlighting. | +| `host::open_file_diff(&diff, file_name)` | API 1.10: the same with a `FileDiff`, whose `None` side is a file that doesn't exist there; an added or deleted file shows alone. | | `host::output_append(channel, text)` | API 1.4: a read-only **Output** tab per channel (32 channels, 1 MiB each); `output_clear`, `output_reveal`. | ```rust diff --git a/docs/zh/plugins/guides/views.mdx b/docs/zh/plugins/guides/views.mdx index 2045bb050..e5de547f4 100644 --- a/docs/zh/plugins/guides/views.mdx +++ b/docs/zh/plugins/guides/views.mdx @@ -256,6 +256,7 @@ Vite + React 页面由 `plugins/build.sh official/graphviz` 构建到 `web/`, | `open-log-tab` | 只读编辑器标签页,持续显示程序输出,可带参数开关。 | | `open-content-tab` | 内容由插件提供的编辑器标签页,带工具栏操作,用 `content-tab-reply` 回复。 | | `open-diff` | API 1.7:在差异查看器中对比两段文本(`left`、`right`,可选标签、`title`,以及用于高亮的 `fileName`)。 | +| `open-diff` 某一侧为 `null` | API 1.10:该侧文件不存在(新增或删除),差异查看器只显示另一侧。 | 消息字段和限制见 [插件指南](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#web-frame-ptys-api-13); `crates/ide-plugin/tests/fixtures/` 下已构建的 `web-pty`、`web-log`、`web-content` 测试插件演示了这些协议。 @@ -315,6 +316,7 @@ impl Details for MyPlugin { | `host::open_log_tab(key, title, &log)` | API 1.3:基于 `ProcessLog` 的只读日志标签页。每个窗口最多 32 个;暂不支持远程项目。 | | `host::open_content_tab(&ContentTab { .. })` | API 1.4:不依赖网页视图的内容编辑器标签页;操作以 `content-tab-action` 事件送达,用 `host::reply_content_tab` 回复。 | | `host::open_diff(&ContentDiff { .. }, file_name)` | API 1.7:在差异查看器中对比两段文本,例如评审中某个文件的修改前后;`file_name` 决定语法高亮。 | +| `host::open_file_diff(&diff, file_name)` | API 1.10:同上,参数为 `FileDiff`,某一侧为 `None` 表示该侧文件不存在;新增或删除的文件只显示存在的一侧。 | | `host::output_append(channel, text)` | API 1.4:每个通道一个只读 **输出** 标签页(32 个通道,各 1 MiB);另有 `output_clear`、`output_reveal`。 | ```rust diff --git a/plugins/README.md b/plugins/README.md index a997a0430..27a8c8e40 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -36,7 +36,7 @@ sdk/rust/openidea-plugin/ # the Rust SDK (host API, Plugin trait, mock host) crates/ide-plugin/tests/fixtures/ # test plugins: hello, jobs, language-toy, misbehave, semantic-tokens, hover, commit, inlay-hints ``` -The plugin API is defined in [`wit/`](../wit/) (`openidea:plugin@1.8.0`, world +The plugin API is defined in [`wit/`](../wit/) (`openidea:plugin@1.10.0`, world `plugin`). ## 1. Quick start @@ -421,9 +421,21 @@ are always available. Calling a gated function without its capability returns ## 3. Writing code (Rust SDK) +### API 1.10 + +API 1.10.0 is in development on `main`. Use `engines.openidea = "^1.10"` and the +matching SDK. Released 1.9 plugins keep working. New in 1.10: + +- `host::open_file_diff(&FileDiff { .. }, file_name)` (`views.open-file-diff`) is + `open_diff` for a file that doesn't exist on one side: a `None` side (`left` of + an added file, `right` of a deleted one) makes the diff viewer show the other + side alone, as for the IDE's own added and deleted files, instead of next to an + empty text. Both `None` is `Invalid`. Web views send `null` for that side in + `{ op: "open-diff", ... }`. + ### API 1.9 -API 1.9.0 is in development on `main`. Use `engines.openidea = "^1.9"` and the +API 1.9.0 shipped with OpenIDEA 0.1.46. Use `engines.openidea = "^1.9"` and the matching SDK. Released 1.8 plugins keep working. New in 1.9: - The `launch-configurations` export (`LaunchConfigurations`, registration @@ -695,6 +707,7 @@ then run `openidea-plugin check`. | `host::open_content_tab(tab)` | `views.open-content-tab` | API 1.4: the shared content editor protocol, without a web view; actions arrive as `content-tab-action`. | | `host::reply_content_tab(request_id, reply)` | `views.reply-content-tab` | API 1.4: reply to an owned action in the originating window. No capability; commands/events only. | | `host::open_diff(diff, file_name)` | `views.open-diff` | API 1.7: two texts in the invoking window's diff viewer; `file_name` (at most 256 characters) picks the highlighting. Commands/events only; each side at most 8 MiB (earlier hosts: 1 MiB), a larger side fails with `Invalid("diff too large: …")`. | +| `host::open_file_diff(diff, file_name)` | `views.open-file-diff` | API 1.10: `open_diff` where a side may be `None` (the file doesn't exist there: added or deleted); the viewer shows the other side alone. Both `None` fails with `Invalid`. | | `RunConfigurations::configurations(root)` | export `run-configurations.configurations` | API 1.4: optional `plugin-run-configurations` world; SDK registration `run_configurations`. Full project list, refreshed on configuration listing. | | `LaunchConfigurations::launch_configurations(root)` | export `launch-configurations` | API 1.9: optional `plugin-launch-configurations` world; SDK registration `launch_configurations`. The same list with `env` and `debugger`; preferred over `run-configurations`. | | `TestResults::parse(config, chunk)` | export `test-results.parse` | API 1.4: optional `plugin-test-results` world; SDK registration `test_results`. Bounded output batches for `framework = "plugin"`; failures use built-in parsers. | @@ -2642,7 +2655,7 @@ the API itself follows _Evolving the plugin API_ below. Released versions are frozen: 1.0.0 shipped with OpenIDEA 0.1.36, 1.1.0 with 0.1.37, 1.2.0 with 0.1.38, 1.3.0 with 0.1.39 and 1.4.0 with 0.1.40. -API 1.5.0 shipped with 0.1.41, 1.6.0 with 0.1.43, 1.7.0 with 0.1.44 and 1.8.0 with 0.1.45; API 1.9.0 is in development on `main`. wasmtime decides what stays compatible: it resolves interface names +API 1.5.0 shipped with 0.1.41, 1.6.0 with 0.1.43, 1.7.0 with 0.1.44 and 1.8.0 with 0.1.45 and 1.9.0 with 0.1.46; API 1.10.0 is in development on `main`. wasmtime decides what stays compatible: it resolves interface names by semver (a component importing `openidea:plugin/x@1.0.0` links against a host defining `@1.1.0`, and the host finds its exports the same way), but function types must match exactly — a record with another field count, or a diff --git a/plugins/official/ai-completion/dist/plugin.wasm b/plugins/official/ai-completion/dist/plugin.wasm index 833181914..cd42ee794 100644 Binary files a/plugins/official/ai-completion/dist/plugin.wasm and b/plugins/official/ai-completion/dist/plugin.wasm differ diff --git a/plugins/official/ai-completion/dist/plugin.wasm.sources b/plugins/official/ai-completion/dist/plugin.wasm.sources index a700b4fc3..22376d59b 100644 --- a/plugins/official/ai-completion/dist/plugin.wasm.sources +++ b/plugins/official/ai-completion/dist/plugin.wasm.sources @@ -1 +1 @@ -4ed77982187f1c454e8567fa3a1a74ba17c5fa24bdc3a14f163df091cad547b1 +8e875bb7ed12f235be46b32ec1377f251474b0c6b663a066c36fbadc6a7fefb3 diff --git a/plugins/official/blame-annotations/dist/plugin.wasm b/plugins/official/blame-annotations/dist/plugin.wasm index 863e7e7b9..fb39a9716 100644 Binary files a/plugins/official/blame-annotations/dist/plugin.wasm and b/plugins/official/blame-annotations/dist/plugin.wasm differ diff --git a/plugins/official/blame-annotations/dist/plugin.wasm.sources b/plugins/official/blame-annotations/dist/plugin.wasm.sources index 6fc630156..6f676efea 100644 --- a/plugins/official/blame-annotations/dist/plugin.wasm.sources +++ b/plugins/official/blame-annotations/dist/plugin.wasm.sources @@ -1 +1 @@ -5083b261592e2969f1eea008420e6397d5dca09f7f51c2a91f65a7762ca63275 +75b4e1267fbf4a93d62963481021970e3eace3442023182e84cd9357744242c9 diff --git a/plugins/official/checkstyle/dist/plugin.wasm b/plugins/official/checkstyle/dist/plugin.wasm index 031c915c3..f473ed8a3 100644 Binary files a/plugins/official/checkstyle/dist/plugin.wasm and b/plugins/official/checkstyle/dist/plugin.wasm differ diff --git a/plugins/official/checkstyle/dist/plugin.wasm.sources b/plugins/official/checkstyle/dist/plugin.wasm.sources index e77439fd5..3ee07a4f8 100644 --- a/plugins/official/checkstyle/dist/plugin.wasm.sources +++ b/plugins/official/checkstyle/dist/plugin.wasm.sources @@ -1 +1 @@ -bdd55768110eae5de8ff26b34af194edb4a32a06dfcffe9c222ff579851bf2ad +63ad90e231b3cf22ed47710822022f4f80fbdb621b1116998e2599dab7a9b87b diff --git a/plugins/official/container-runner/dist/plugin.wasm b/plugins/official/container-runner/dist/plugin.wasm index def9936e6..62c45bb0c 100644 Binary files a/plugins/official/container-runner/dist/plugin.wasm and b/plugins/official/container-runner/dist/plugin.wasm differ diff --git a/plugins/official/container-runner/dist/plugin.wasm.sources b/plugins/official/container-runner/dist/plugin.wasm.sources index 99dcb6f86..eb396ac18 100644 --- a/plugins/official/container-runner/dist/plugin.wasm.sources +++ b/plugins/official/container-runner/dist/plugin.wasm.sources @@ -1 +1 @@ -ce8a51723724726fbe5b4eb832a152e9519ffb52cbc8ad957d6f2bad23fb58ea +bfd7039bb90e1a4352b7961bbbf83e3af276ba86945fbc23bc34cbf1e3b8c272 diff --git a/plugins/official/csv-editor/dist/plugin.wasm b/plugins/official/csv-editor/dist/plugin.wasm index 99421d9ff..a2f4dd072 100644 Binary files a/plugins/official/csv-editor/dist/plugin.wasm and b/plugins/official/csv-editor/dist/plugin.wasm differ diff --git a/plugins/official/csv-editor/dist/plugin.wasm.sources b/plugins/official/csv-editor/dist/plugin.wasm.sources index 631c4db99..7f384c34d 100644 --- a/plugins/official/csv-editor/dist/plugin.wasm.sources +++ b/plugins/official/csv-editor/dist/plugin.wasm.sources @@ -1 +1 @@ -8a09e07fa34ca56bcb4b27a883ea58ea6b1a7a5465ac9d57231f9205c5b80be4 +0ff9eddb3f6fa47c4afd8375471b882cd323631a383a5da97b25271cdd2850a7 diff --git a/plugins/official/git-toolbox/dist/plugin.wasm b/plugins/official/git-toolbox/dist/plugin.wasm index 2f8053916..42d4ccdd3 100644 Binary files a/plugins/official/git-toolbox/dist/plugin.wasm and b/plugins/official/git-toolbox/dist/plugin.wasm differ diff --git a/plugins/official/git-toolbox/dist/plugin.wasm.sources b/plugins/official/git-toolbox/dist/plugin.wasm.sources index d1863a605..39ad2fa0c 100644 --- a/plugins/official/git-toolbox/dist/plugin.wasm.sources +++ b/plugins/official/git-toolbox/dist/plugin.wasm.sources @@ -1 +1 @@ -d402a7d7c57362ded611270ae804e2af4480663536feaa33475049d84e563dda +471ddce51119b0fd9caa46c24248f368d48beb8953b5ad6253ba0cfc2c5aa141 diff --git a/plugins/official/graphviz/dist/plugin.wasm b/plugins/official/graphviz/dist/plugin.wasm index 0c14a1eb5..0536f4f47 100644 Binary files a/plugins/official/graphviz/dist/plugin.wasm and b/plugins/official/graphviz/dist/plugin.wasm differ diff --git a/plugins/official/graphviz/dist/plugin.wasm.sources b/plugins/official/graphviz/dist/plugin.wasm.sources index ec5b39ee2..c32aebade 100644 --- a/plugins/official/graphviz/dist/plugin.wasm.sources +++ b/plugins/official/graphviz/dist/plugin.wasm.sources @@ -1 +1 @@ -51c22339fc7d2f17abc9e019f93f4e19fffd9f6bb91721404f49668ec7818bc1 +4fc818b0af1abfd9d9d0cdaf4c56cce02cc7e05be501de59b1cbea4672aa91b3 diff --git a/plugins/official/key-promoter/dist/plugin.wasm b/plugins/official/key-promoter/dist/plugin.wasm index a76da6fb1..7edeadd59 100644 Binary files a/plugins/official/key-promoter/dist/plugin.wasm and b/plugins/official/key-promoter/dist/plugin.wasm differ diff --git a/plugins/official/key-promoter/dist/plugin.wasm.sources b/plugins/official/key-promoter/dist/plugin.wasm.sources index f3b633175..09ee2cb32 100644 --- a/plugins/official/key-promoter/dist/plugin.wasm.sources +++ b/plugins/official/key-promoter/dist/plugin.wasm.sources @@ -1 +1 @@ -c8769d91ae5b81446e9f3a4fb7875d0082769c1496703dd60d67a55a1a07e2cd +d701b0d87cb4f0ff428bb663cb899c1ad85a3c2f10bc97b97ddbc67cdb88e07b diff --git a/plugins/official/license-header/dist/plugin.wasm b/plugins/official/license-header/dist/plugin.wasm index 92cb63aad..9b5664282 100644 Binary files a/plugins/official/license-header/dist/plugin.wasm and b/plugins/official/license-header/dist/plugin.wasm differ diff --git a/plugins/official/license-header/dist/plugin.wasm.sources b/plugins/official/license-header/dist/plugin.wasm.sources index aa7cafcf7..ec15997dd 100644 --- a/plugins/official/license-header/dist/plugin.wasm.sources +++ b/plugins/official/license-header/dist/plugin.wasm.sources @@ -1 +1 @@ -d8f9249fa4c805baa2a8599724651a80448a71d780c6c81ee51cd584adec6b28 +72e8802492777bf94f686ce6c09a4a24b16d06dfb0802c56e83a2170cf27393a diff --git a/plugins/official/mybatis/dist/plugin.wasm b/plugins/official/mybatis/dist/plugin.wasm index 673f74c61..3d1885573 100644 Binary files a/plugins/official/mybatis/dist/plugin.wasm and b/plugins/official/mybatis/dist/plugin.wasm differ diff --git a/plugins/official/mybatis/dist/plugin.wasm.sources b/plugins/official/mybatis/dist/plugin.wasm.sources index cebf48be4..6aa075aa8 100644 --- a/plugins/official/mybatis/dist/plugin.wasm.sources +++ b/plugins/official/mybatis/dist/plugin.wasm.sources @@ -1 +1 @@ -f18ba63197e8aa37df249fa05da679543b4978e9284ebae0f1786f16ffaeb02f +594995ca3941ed3ec89625e51b43bfa45d4b5b70248c22787ed7a3291ed07678 diff --git a/plugins/official/regex-tester/dist/plugin.wasm b/plugins/official/regex-tester/dist/plugin.wasm index f1ea16fe0..2d0ba57a4 100644 Binary files a/plugins/official/regex-tester/dist/plugin.wasm and b/plugins/official/regex-tester/dist/plugin.wasm differ diff --git a/plugins/official/regex-tester/dist/plugin.wasm.sources b/plugins/official/regex-tester/dist/plugin.wasm.sources index 96e535560..7f2d7d164 100644 --- a/plugins/official/regex-tester/dist/plugin.wasm.sources +++ b/plugins/official/regex-tester/dist/plugin.wasm.sources @@ -1 +1 @@ -33eb1da1fca89e4aa673dd330dd508b88e7994daab0cd3ab6ff9420cdc75c4a8 +2caaf82921e6b942ad043e91e02a8fa59c59ec497bb5d2c84b2f6c156b134e69 diff --git a/plugins/official/solidity/dist/plugin.wasm b/plugins/official/solidity/dist/plugin.wasm index 787c1d493..06a0256b0 100644 Binary files a/plugins/official/solidity/dist/plugin.wasm and b/plugins/official/solidity/dist/plugin.wasm differ diff --git a/plugins/official/solidity/dist/plugin.wasm.sources b/plugins/official/solidity/dist/plugin.wasm.sources index f866659d5..9693ce149 100644 --- a/plugins/official/solidity/dist/plugin.wasm.sources +++ b/plugins/official/solidity/dist/plugin.wasm.sources @@ -1 +1 @@ -fbc688bb595055bc4cc7aa2f9e70526a52f53083650c51e17d44090ea6f1594e +9d4fbc2a435f718863198609928018e0120abfbbd62937cfe8da4c861839ce0d diff --git a/plugins/official/string-tools/dist/plugin.wasm b/plugins/official/string-tools/dist/plugin.wasm index c3de2e5b0..51cce12c9 100644 Binary files a/plugins/official/string-tools/dist/plugin.wasm and b/plugins/official/string-tools/dist/plugin.wasm differ diff --git a/plugins/official/string-tools/dist/plugin.wasm.sources b/plugins/official/string-tools/dist/plugin.wasm.sources index 10d8b4051..516331fa6 100644 --- a/plugins/official/string-tools/dist/plugin.wasm.sources +++ b/plugins/official/string-tools/dist/plugin.wasm.sources @@ -1 +1 @@ -4da47cebf0815b7ca417e4d63da0413c4eb4bf4eab012f8cac05649619c2c4fe +71b7187c3187e932d5416dd7acff60d60470015ee74b3be9f8d5d5e1469e01d8 diff --git a/plugins/official/test-runner/dist/plugin.wasm b/plugins/official/test-runner/dist/plugin.wasm index 0053030ed..0a76ad924 100644 Binary files a/plugins/official/test-runner/dist/plugin.wasm and b/plugins/official/test-runner/dist/plugin.wasm differ diff --git a/plugins/official/test-runner/dist/plugin.wasm.sources b/plugins/official/test-runner/dist/plugin.wasm.sources index b7b309a41..570288ef4 100644 --- a/plugins/official/test-runner/dist/plugin.wasm.sources +++ b/plugins/official/test-runner/dist/plugin.wasm.sources @@ -1 +1 @@ -ae0baafe6f1f96fe2895c16856e524daff6e99f660ed02c84d01d3de404be06c +de457dec1dca333f217ea499c92eba4d23c0a72729b22de4106cec513396bd96 diff --git a/plugins/official/todo-finder/dist/plugin.wasm b/plugins/official/todo-finder/dist/plugin.wasm index f5600a164..eb2f3c988 100644 Binary files a/plugins/official/todo-finder/dist/plugin.wasm and b/plugins/official/todo-finder/dist/plugin.wasm differ diff --git a/plugins/official/todo-finder/dist/plugin.wasm.sources b/plugins/official/todo-finder/dist/plugin.wasm.sources index efcead262..d704a1fb0 100644 --- a/plugins/official/todo-finder/dist/plugin.wasm.sources +++ b/plugins/official/todo-finder/dist/plugin.wasm.sources @@ -1 +1 @@ -80c4585d53b29e83f45533f9b2ec0a2db0a0322639049c9be590debbc1defcda +575c9f2087bbc6233258875530a720c5e72de3f60ab580aa05778703f5fcafcc diff --git a/sdk/rust/openidea-plugin/src/execution.rs b/sdk/rust/openidea-plugin/src/execution.rs index 5843d5ed9..281dac789 100644 --- a/sdk/rust/openidea-plugin/src/execution.rs +++ b/sdk/rust/openidea-plugin/src/execution.rs @@ -37,6 +37,30 @@ pub struct ContentDiff { pub title: Option, } +/// A file's before and after for `host::open_file_diff` (API 1.10): `None` is a side where the +/// file doesn't exist (an added file has no left side, a deleted one no right side). +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct FileDiff { + pub left: Option, + pub right: Option, + pub left_label: Option, + pub right_label: Option, + pub title: Option, +} + +impl From for FileDiff { + fn from(v: ContentDiff) -> Self { + Self { + left: Some(v.left), + right: Some(v.right), + left_label: v.left_label, + right_label: v.right_label, + title: v.title, + } + } +} + /// ContentTabReply data exchanged with the IDE. #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -155,7 +179,7 @@ pub enum PluginTestEvent { pub trait RunConfigurations { fn configurations(&mut self, project_root: &str) -> Vec; } -/// How Debug starts a launch configuration (API 1.9). +/// How Debug starts a launch configuration (API 1.10). #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase", tag = "type")] pub enum Debugger { @@ -169,7 +193,7 @@ pub enum Debugger { AttachChild { kind: String, command_contains: Option }, } -/// A run configuration with an environment and a debugger (API 1.9). +/// A run configuration with an environment and a debugger (API 1.10). #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct PluginLaunchConfiguration { @@ -180,7 +204,7 @@ pub struct PluginLaunchConfiguration { pub debugger: Option, } -/// Supplies complete project configurations with environments and debuggers (API 1.9); +/// Supplies complete project configurations with environments and debuggers (API 1.10); /// register with launch_configurations instead of run_configurations. pub trait LaunchConfigurations { fn launch_configurations(&mut self, project_root: &str) -> Vec; diff --git a/sdk/rust/openidea-plugin/src/host.rs b/sdk/rust/openidea-plugin/src/host.rs index 3a3694713..d07a98e73 100644 --- a/sdk/rust/openidea-plugin/src/host.rs +++ b/sdk/rust/openidea-plugin/src/host.rs @@ -767,6 +767,16 @@ mod imp { } } + fn file_diff_to(v: &crate::FileDiff) -> wit::views::FileDiff { + wit::views::FileDiff { + left: v.left.clone(), + right: v.right.clone(), + left_label: v.left_label.clone(), + right_label: v.right_label.clone(), + title: v.title.clone(), + } + } + fn content_tab_reply_to(v: &crate::ContentTabReply) -> wit::views::ContentTabReply { wit::views::ContentTabReply { content: v.content.clone(), @@ -889,6 +899,9 @@ mod imp { pub fn open_diff(diff: &crate::ContentDiff, file_name: Option<&str>) -> Result<(), Error> { wit::views::open_diff(&content_diff_to(diff), file_name).map_err(error) } + pub fn open_file_diff(diff: &crate::FileDiff, file_name: Option<&str>) -> Result<(), Error> { + wit::views::open_file_diff(&file_diff_to(diff), file_name).map_err(error) + } pub fn open_terminal(title: &str, program: &str, args: &[String]) -> Result<(), Error> { wit::views::open_terminal(title, program, args).map_err(error) @@ -1918,6 +1931,11 @@ pub fn reply_content_tab(request: &str, reply: &crate::ContentTabReply) -> Resul pub fn open_diff(diff: &crate::ContentDiff, file_name: Option<&str>) -> Result<(), Error> { imp::open_diff(diff, file_name) } +/// API 1.10: like [`open_diff`] for a file missing on one side (`None`: added or deleted); the +/// diff viewer shows the other side alone. Both sides `None` is `Error::Invalid`. +pub fn open_file_diff(diff: &crate::FileDiff, file_name: Option<&str>) -> Result<(), Error> { + imp::open_file_diff(diff, file_name) +} /// Registers/replaces a read-only project target. Requires the program's process grant. pub fn register_run_target(project: &Project, target: &crate::PluginRunTarget) -> Result<(), Error> { diff --git a/sdk/rust/openidea-plugin/src/lib.rs b/sdk/rust/openidea-plugin/src/lib.rs index d4840dd42..0594b06a9 100644 --- a/sdk/rust/openidea-plugin/src/lib.rs +++ b/sdk/rust/openidea-plugin/src/lib.rs @@ -98,7 +98,7 @@ pub mod providers_bindings { export_macro_name: "__export_editor_providers_world", default_bindings_module: "openidea_plugin::providers_bindings", with: { - "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types, }, }); } @@ -115,10 +115,10 @@ pub mod views_bindings { export_macro_name: "__export_views_world", default_bindings_module: "openidea_plugin::views_bindings", with: { - "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types, - "openidea:plugin/workspace@1.9.0": crate::bindings::openidea::plugin::workspace, - "openidea:plugin/editor@1.9.0": crate::bindings::openidea::plugin::editor, - "openidea:plugin/invocation@1.9.0": crate::bindings::openidea::plugin::invocation, + "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/workspace@1.10.0": crate::bindings::openidea::plugin::workspace, + "openidea:plugin/editor@1.10.0": crate::bindings::openidea::plugin::editor, + "openidea:plugin/invocation@1.10.0": crate::bindings::openidea::plugin::invocation, }, }); } @@ -130,7 +130,7 @@ pub mod indexing_bindings { world: "indexing", path: "wit", pub_export_macro: true, export_macro_name: "__export_indexing_world", default_bindings_module: "openidea_plugin::indexing_bindings", - with: { "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types }, }); } @@ -142,10 +142,10 @@ pub mod details_bindings { export_macro_name: "__export_details_world", default_bindings_module: "openidea_plugin::details_bindings", with: { - "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types, - "openidea:plugin/workspace@1.9.0": crate::bindings::openidea::plugin::workspace, - "openidea:plugin/editor@1.9.0": crate::bindings::openidea::plugin::editor, - "openidea:plugin/invocation@1.9.0": crate::bindings::openidea::plugin::invocation, + "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/workspace@1.10.0": crate::bindings::openidea::plugin::workspace, + "openidea:plugin/editor@1.10.0": crate::bindings::openidea::plugin::editor, + "openidea:plugin/invocation@1.10.0": crate::bindings::openidea::plugin::invocation, }, }); } @@ -157,7 +157,7 @@ pub mod semantic_bindings { world: "semantic-tokens", path: "wit", pub_export_macro: true, export_macro_name: "__export_semantic_tokens_world", default_bindings_module: "openidea_plugin::semantic_bindings", - with: { "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types }, }); } @@ -169,8 +169,8 @@ pub mod diagnostics_bindings { export_macro_name: "__export_diagnostics_world", default_bindings_module: "openidea_plugin::diagnostics_bindings", with: { - "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types, - "openidea:plugin/diagnostics@1.9.0": crate::bindings::openidea::plugin::diagnostics, + "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/diagnostics@1.10.0": crate::bindings::openidea::plugin::diagnostics, }, }); } @@ -182,7 +182,7 @@ pub mod hover_bindings { world: "hover", path: "wit", pub_export_macro: true, export_macro_name: "__export_hover_world", default_bindings_module: "openidea_plugin::hover_bindings", - with: { "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types }, }); } @@ -194,11 +194,11 @@ pub mod commit_checks_bindings { export_macro_name: "__export_commit_checks_world", default_bindings_module: "openidea_plugin::commit_checks_bindings", with: { - "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types, - "openidea:plugin/workspace@1.9.0": crate::bindings::openidea::plugin::workspace, - "openidea:plugin/editor@1.9.0": crate::bindings::openidea::plugin::editor, - "openidea:plugin/invocation@1.9.0": crate::bindings::openidea::plugin::invocation, - "openidea:plugin/commit@1.9.0": crate::bindings::openidea::plugin::commit, + "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/workspace@1.10.0": crate::bindings::openidea::plugin::workspace, + "openidea:plugin/editor@1.10.0": crate::bindings::openidea::plugin::editor, + "openidea:plugin/invocation@1.10.0": crate::bindings::openidea::plugin::invocation, + "openidea:plugin/commit@1.10.0": crate::bindings::openidea::plugin::commit, }, }); } @@ -210,7 +210,7 @@ pub mod inlay_bindings { world: "inlay-hints", path: "wit", pub_export_macro: true, export_macro_name: "__export_inlay_hints_world", default_bindings_module: "openidea_plugin::inlay_bindings", - with: { "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types }, }); } @@ -221,7 +221,7 @@ pub mod file_actions_bindings { world: "file-actions-provider", path: "wit", pub_export_macro: true, export_macro_name: "__export_file_actions_world", default_bindings_module: "openidea_plugin::file_actions_bindings", - with: { "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types }, }); } @@ -233,10 +233,10 @@ pub mod endpoints_bindings { export_macro_name: "__export_endpoints_world", default_bindings_module: "openidea_plugin::endpoints_bindings", with: { - "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types, - "openidea:plugin/workspace@1.9.0": crate::bindings::openidea::plugin::workspace, - "openidea:plugin/editor@1.9.0": crate::bindings::openidea::plugin::editor, - "openidea:plugin/invocation@1.9.0": crate::bindings::openidea::plugin::invocation, + "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/workspace@1.10.0": crate::bindings::openidea::plugin::workspace, + "openidea:plugin/editor@1.10.0": crate::bindings::openidea::plugin::editor, + "openidea:plugin/invocation@1.10.0": crate::bindings::openidea::plugin::invocation, }, }); } @@ -1348,7 +1348,7 @@ pub mod run_configurations_bindings { pub mod launch_configurations_bindings { wit_bindgen::generate!({ world: "launch-configurations-provider", path: "wit", pub_export_macro: true, export_macro_name: "__export_launch_configurations_world", default_bindings_module: "openidea_plugin::launch_configurations_bindings", - with: { "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types }, }); } #[cfg(target_arch = "wasm32")] @@ -1356,7 +1356,7 @@ pub mod launch_configurations_bindings { pub mod test_results_bindings { wit_bindgen::generate!({ world: "test-results-provider", path: "wit", pub_export_macro: true, export_macro_name: "__export_tests_world", default_bindings_module: "openidea_plugin::test_results_bindings", - with: { "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types }, }); } #[doc(hidden)] @@ -1406,7 +1406,7 @@ pub mod language_features; pub mod language_features_bindings { wit_bindgen::generate!({world: "editor-language-features", path: "wit", pub_export_macro: true, export_macro_name: "__export_language_features_world", default_bindings_module: "openidea_plugin::language_features_bindings", - with: { "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types }, }); } @@ -1438,7 +1438,7 @@ fn gutter_actions(doc: $crate::language_features_bindings::exports::openidea::pl pub mod injections_bindings { wit_bindgen::generate!({world: "language-injections", path: "wit", pub_export_macro: true, export_macro_name: "__export_injections_world", default_bindings_module: "openidea_plugin::injections_bindings", - with: { "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types }, }); } @@ -1468,8 +1468,8 @@ pub mod mcp_bindings { wit_bindgen::generate!({ world: "mcp-tools", path: "wit", pub_export_macro: true, export_macro_name: "__export_mcp_world", default_bindings_module: "openidea_plugin::mcp_bindings", with: { - "openidea:plugin/types@1.9.0": crate::bindings::openidea::plugin::types, - "openidea:plugin/invocation@1.9.0": crate::bindings::openidea::plugin::invocation, + "openidea:plugin/types@1.10.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/invocation@1.10.0": crate::bindings::openidea::plugin::invocation, }, }); } diff --git a/sdk/rust/openidea-plugin/src/mock.rs b/sdk/rust/openidea-plugin/src/mock.rs index c5f0e020b..532a1612e 100644 --- a/sdk/rust/openidea-plugin/src/mock.rs +++ b/sdk/rust/openidea-plugin/src/mock.rs @@ -176,7 +176,7 @@ struct State { terminal_writes: Vec<(String, String)>, content_tabs: BTreeMap, content_replies: Vec<(String, crate::ContentTabReply)>, - diffs: Vec<(crate::ContentDiff, Option)>, + diffs: Vec<(crate::FileDiff, Option)>, database_sources: BTreeMap<(String, String), PluginDataSource>, database_credentials: BTreeSet<(String, String)>, database_connections: Vec<(String, String)>, @@ -672,6 +672,11 @@ impl MockHost { .unwrap(), }) } + /// Diffs the plugin opened (`open_diff` sides are always `Some`), with their file names. + pub fn opened_diffs(&self) -> Vec<(crate::FileDiff, Option)> { + self.state.borrow().diffs.clone() + } + /// Terminals the plugin opened. pub fn terminals(&self) -> Vec { self.state.borrow().terminals.clone() @@ -2441,7 +2446,11 @@ pub mod current { Ok(()) } pub fn open_diff(diff: &crate::ContentDiff, file_name: Option<&str>) -> Result<(), Error> { - if diff.left.contains('\0') || diff.right.contains('\0') { + open_file_diff(&diff.clone().into(), file_name) + } + pub fn open_file_diff(diff: &crate::FileDiff, file_name: Option<&str>) -> Result<(), Error> { + let sides = [&diff.left, &diff.right]; + if sides.iter().all(|s| s.is_none()) || sides.into_iter().flatten().any(|s| s.contains('\0')) { return Err(Error::Invalid("invalid diff".into())); } with(|s| s.diffs.push((diff.clone(), file_name.map(Into::into)))); @@ -3109,6 +3118,20 @@ mod tests { assert!(matches!(host::open_log_tab("", "api logs", &log), Err(Error::Invalid(_)))); } + #[test] + fn a_file_diff_may_miss_one_side() { + let mock = MockHost::install(); + let added = crate::FileDiff { right: Some("new\n".into()), ..Default::default() }; + host::open_file_diff(&added, Some("src/new.rs")).unwrap(); + host::open_diff(&crate::ContentDiff { left: "a".into(), right: "b".into(), ..Default::default() }, None) + .unwrap(); + assert!(matches!(host::open_file_diff(&crate::FileDiff::default(), None), Err(Error::Invalid(_)))); + let diffs = mock.opened_diffs(); + assert_eq!(diffs[0], (added, Some("src/new.rs".into()))); + assert_eq!((diffs[1].0.left.as_deref(), diffs[1].0.right.as_deref()), (Some("a"), Some("b"))); + assert_eq!(diffs.len(), 2); + } + #[test] fn fs_write_needs_a_grant_of_its_own() { // `fs.read` does not let a plugin write. diff --git a/sdk/rust/openidea-plugin/wit/commit.wit b/sdk/rust/openidea-plugin/wit/commit.wit index 0caac6fe0..34a6e04a8 100644 --- a/sdk/rust/openidea-plugin/wit/commit.wit +++ b/sdk/rust/openidea-plugin/wit/commit.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// The commit being prepared in the window the current command or event came /// from (the Commit tool window, or the Commit dialog while it is open): the diff --git a/sdk/rust/openidea-plugin/wit/database.wit b/sdk/rust/openidea-plugin/wit/database.wit index 9ab95663c..a2165967a 100644 --- a/sdk/rust/openidea-plugin/wit/database.wit +++ b/sdk/rust/openidea-plugin/wit/database.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Plugin-owned project data sources. Requires database.sources and project trust. /// Runs on the Database subsystem's host, including on remote project servers. diff --git a/sdk/rust/openidea-plugin/wit/decorations.wit b/sdk/rust/openidea-plugin/wit/decorations.wit index db0b04967..a86e12119 100644 --- a/sdk/rust/openidea-plugin/wit/decorations.wit +++ b/sdk/rust/openidea-plugin/wit/decorations.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Editor and project-tree decorations (API 1.4). Requires project.read. An editor set /// follows its file: the file's own project, or the nearest one when it is outside them all. diff --git a/sdk/rust/openidea-plugin/wit/details.wit b/sdk/rust/openidea-plugin/wit/details.wit index 656aed9cd..ce8a48c37 100644 --- a/sdk/rust/openidea-plugin/wit/details.wit +++ b/sdk/rust/openidea-plugin/wit/details.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// What the pane beside the Services tree shows for a plugin's node. interface detail-types { diff --git a/sdk/rust/openidea-plugin/wit/diagnostics.wit b/sdk/rust/openidea-plugin/wit/diagnostics.wit index 8c88fca6c..51c72f240 100644 --- a/sdk/rust/openidea-plugin/wit/diagnostics.wit +++ b/sdk/rust/openidea-plugin/wit/diagnostics.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Optional export (world `plugin-diagnostics`): problems in the current, /// possibly unsaved document, for the languages declared with the diff --git a/sdk/rust/openidea-plugin/wit/endpoints.wit b/sdk/rust/openidea-plugin/wit/endpoints.wit index df7ea70f3..bb283c010 100644 --- a/sdk/rust/openidea-plugin/wit/endpoints.wit +++ b/sdk/rust/openidea-plugin/wit/endpoints.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// HTTP endpoints found in a project (`[[contributes.endpoints]]`). interface endpoints-provider { diff --git a/sdk/rust/openidea-plugin/wit/events.wit b/sdk/rust/openidea-plugin/wit/events.wit index 190a39142..559f96ac4 100644 --- a/sdk/rust/openidea-plugin/wit/events.wit +++ b/sdk/rust/openidea-plugin/wit/events.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Workbench events, delivered in batches to `event-handler.handle`. interface events { diff --git a/sdk/rust/openidea-plugin/wit/exports.wit b/sdk/rust/openidea-plugin/wit/exports.wit index 7e90d003e..944c869db 100644 --- a/sdk/rust/openidea-plugin/wit/exports.wit +++ b/sdk/rust/openidea-plugin/wit/exports.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; interface lifecycle { use types.{context, error}; diff --git a/sdk/rust/openidea-plugin/wit/extensions.wit b/sdk/rust/openidea-plugin/wit/extensions.wit index 51a086e7b..3f7890c4d 100644 --- a/sdk/rust/openidea-plugin/wit/extensions.wit +++ b/sdk/rust/openidea-plugin/wit/extensions.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// What other plugins contributed to the extension points this plugin declares /// (`[[extension-points]]` in `plugin.toml`; the contributors list this plugin diff --git a/sdk/rust/openidea-plugin/wit/file-actions.wit b/sdk/rust/openidea-plugin/wit/file-actions.wit index 9641f3604..2b60cafd0 100644 --- a/sdk/rust/openidea-plugin/wit/file-actions.wit +++ b/sdk/rust/openidea-plugin/wit/file-actions.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Optional export (world `plugin-file-actions`): quick fixes and /// refactorings that create, rename or delete files, next to the text edits diff --git a/sdk/rust/openidea-plugin/wit/fs.wit b/sdk/rust/openidea-plugin/wit/fs.wit index 76ca5f53c..ca0709f57 100644 --- a/sdk/rust/openidea-plugin/wit/fs.wit +++ b/sdk/rust/openidea-plugin/wit/fs.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Files outside the open projects: the configuration of the program a /// plugin integrates with, a tool installed elsewhere, a licence file. diff --git a/sdk/rust/openidea-plugin/wit/host.wit b/sdk/rust/openidea-plugin/wit/host.wit index ff67f0670..d266b84ae 100644 --- a/sdk/rust/openidea-plugin/wit/host.wit +++ b/sdk/rust/openidea-plugin/wit/host.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Writes to the IDE log, tagged with the plugin id. interface log { diff --git a/sdk/rust/openidea-plugin/wit/hover.wit b/sdk/rust/openidea-plugin/wit/hover.wit index e4eed76e0..d339618fa 100644 --- a/sdk/rust/openidea-plugin/wit/hover.wit +++ b/sdk/rust/openidea-plugin/wit/hover.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Optional export (world `plugin-hover`): Markdown added to the hover of /// documents of the languages declared with the `hover` provider kind, diff --git a/sdk/rust/openidea-plugin/wit/indexing.wit b/sdk/rust/openidea-plugin/wit/indexing.wit index fd74e3c27..5b20748df 100644 --- a/sdk/rust/openidea-plugin/wit/indexing.wit +++ b/sdk/rust/openidea-plugin/wit/indexing.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Cross-file associations a plugin publishes for the files it declares under /// `[[contributes.documentIndexers]]`. The host calls `index` in cancellable diff --git a/sdk/rust/openidea-plugin/wit/injections.wit b/sdk/rust/openidea-plugin/wit/injections.wit index 7f5edacc1..22e5da5fa 100644 --- a/sdk/rust/openidea-plugin/wit/injections.wit +++ b/sdk/rust/openidea-plugin/wit/injections.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Embedded languages. The host routes plugin providers and configured language /// servers inside these ranges, preserving host-document UTF-16 coordinates. diff --git a/sdk/rust/openidea-plugin/wit/inlay.wit b/sdk/rust/openidea-plugin/wit/inlay.wit index 90f8ab04d..205154174 100644 --- a/sdk/rust/openidea-plugin/wit/inlay.wit +++ b/sdk/rust/openidea-plugin/wit/inlay.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Optional export (world `plugin-inlay-hints`): inline hints in documents of /// the languages declared with the `inlay-hints` provider kind, including diff --git a/sdk/rust/openidea-plugin/wit/io.wit b/sdk/rust/openidea-plugin/wit/io.wit index cb921509c..771cd33dc 100644 --- a/sdk/rust/openidea-plugin/wit/io.wit +++ b/sdk/rust/openidea-plugin/wit/io.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Problems in files, shown in the editor and the Problems view. interface diagnostics { diff --git a/sdk/rust/openidea-plugin/wit/language-features.wit b/sdk/rust/openidea-plugin/wit/language-features.wit index 1ebd0366e..9f2e989c2 100644 --- a/sdk/rust/openidea-plugin/wit/language-features.wit +++ b/sdk/rust/openidea-plugin/wit/language-features.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Additional language features, called only for declared API 1.4 provider kinds. /// Editor calls have a 50 ms soft / 500 ms hard budget; formatting has 5 seconds. diff --git a/sdk/rust/openidea-plugin/wit/mcp.wit b/sdk/rust/openidea-plugin/wit/mcp.wit index 244dec640..ca3d52341 100644 --- a/sdk/rust/openidea-plugin/wit/mcp.wit +++ b/sdk/rust/openidea-plugin/wit/mcp.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Discovery of the IDE's built-in MCP server; never exposes its URL or token. interface mcp { diff --git a/sdk/rust/openidea-plugin/wit/plugin.wit b/sdk/rust/openidea-plugin/wit/plugin.wit index e414759ef..077eab417 100644 --- a/sdk/rust/openidea-plugin/wit/plugin.wit +++ b/sdk/rust/openidea-plugin/wit/plugin.wit @@ -8,7 +8,7 @@ /// `fs` and `workspace`, and everything else goes through the imports below, /// gated by the capabilities granted in `plugin.toml` (a missing one returns /// `error::denied`). -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; world plugin { import log; diff --git a/sdk/rust/openidea-plugin/wit/providers.wit b/sdk/rust/openidea-plugin/wit/providers.wit index e6f383551..928716ec2 100644 --- a/sdk/rust/openidea-plugin/wit/providers.wit +++ b/sdk/rust/openidea-plugin/wit/providers.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Editor features a plugin provides for the languages it declares under /// `[[contributes.providers]]` (the host calls only declared kinds). They run diff --git a/sdk/rust/openidea-plugin/wit/run-targets.wit b/sdk/rust/openidea-plugin/wit/run-targets.wit index 30d386957..7892e0095 100644 --- a/sdk/rust/openidea-plugin/wit/run-targets.wit +++ b/sdk/rust/openidea-plugin/wit/run-targets.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Project-scoped targets owned by the registering plugin (API 1.4). interface run-targets { diff --git a/sdk/rust/openidea-plugin/wit/run.wit b/sdk/rust/openidea-plugin/wit/run.wit index 2ff8645ce..8bbf4856d 100644 --- a/sdk/rust/openidea-plugin/wit/run.wit +++ b/sdk/rust/openidea-plugin/wit/run.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Launches this plugin's configurations in the invoking window's Run tool window. interface run { diff --git a/sdk/rust/openidea-plugin/wit/semantic.wit b/sdk/rust/openidea-plugin/wit/semantic.wit index 7f67089b5..e53bf51f7 100644 --- a/sdk/rust/openidea-plugin/wit/semantic.wit +++ b/sdk/rust/openidea-plugin/wit/semantic.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Optional export (world `plugin-semantic-tokens`): semantic colouring of /// documents of the languages declared with the `semantic-tokens` provider diff --git a/sdk/rust/openidea-plugin/wit/types.wit b/sdk/rust/openidea-plugin/wit/types.wit index e51c4579a..35987f87a 100644 --- a/sdk/rust/openidea-plugin/wit/types.wit +++ b/sdk/rust/openidea-plugin/wit/types.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Shared types. Positions are 0-based lines and UTF-16 code unit columns, /// as in the editor and LSP. diff --git a/sdk/rust/openidea-plugin/wit/views.wit b/sdk/rust/openidea-plugin/wit/views.wit index cb0e621e8..12208980d 100644 --- a/sdk/rust/openidea-plugin/wit/views.wit +++ b/sdk/rust/openidea-plugin/wit/views.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Declarative views: tool windows declared /// under `[[contributes.views]]` and custom editors under @@ -135,6 +135,10 @@ interface views { } /// A comparison opened by a content action reply. record content-diff { left: string, right: string, left-label: option, right-label: option, title: option } + /// A file's before and after for `open-file-diff` (API 1.10): none is a side + /// where the file doesn't exist (an added file has no left side, a deleted + /// one no right side). + record file-diff { left: option, right: option, left-label: option, right-label: option, title: option } /// Optional updates to an outstanding action or Save request. record content-tab-reply { content: option, saved: option, read-only: option, @@ -156,6 +160,11 @@ interface views { /// of a window. Each side at most 8 MiB (earlier hosts: 1 MiB); a larger /// side fails with `invalid("diff too large: …")`. open-diff: func(diff: content-diff, file-name: option) -> result<_, error>; + /// `open-diff` for a file that may not exist on one side (API 1.10): the + /// diff viewer shows the existing side alone, as for the IDE's own added + /// and deleted files, instead of next to an empty text. Both sides none is + /// `invalid`. + open-file-diff: func(diff: file-diff, file-name: option) -> result<_, error>; /// The view (or every custom editor of that id) shows outdated content: /// the IDE renders it again. diff --git a/sdk/rust/openidea-plugin/wit/workspace.wit b/sdk/rust/openidea-plugin/wit/workspace.wit index e4d3b3da3..fd0799e2c 100644 --- a/sdk/rust/openidea-plugin/wit/workspace.wit +++ b/sdk/rust/openidea-plugin/wit/workspace.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; interface workspace { use types.{error, location}; diff --git a/src/bindings.ts b/src/bindings.ts index a05eed159..6c45f205b 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -5612,6 +5612,15 @@ export type FileDecoration = { icon?: string | null, }; +/** A diff opened by a plugin (API 1.10): `None` is a side where the file doesn't exist. */ +export type FileDiff = { + left: string | null, + right: string | null, + leftLabel: string | null, + rightLabel: string | null, + title: string | null, +}; + export type FileEdit = { kind: "edit"; path: IpcPath; edits: TextEdit[]; /** LSP TextDocumentEdit version; null/unversioned edits use content preconditions. */ version?: number | null } | { kind: "create"; path: IpcPath; overwrite: boolean } | { kind: "rename"; from: IpcPath; to: IpcPath } | { kind: "delete"; path: IpcPath; recursive: boolean }; @@ -8614,7 +8623,7 @@ export type PluginEvent_Deserialize = /** Reply to a content action in this window. */ ({ type: "contentTabReply"; pluginId: string; requestId: string; reply: ContentTabReply }) & { actions?: never; arg?: never; args?: never; body?: never; cancellable?: never; capabilities?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; path?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; request?: never; reveal?: never; root?: never; selection?: never; sets?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | /** Open two texts in this window's diff viewer. */ -({ type: "openDiff"; pluginId: string; diff: ContentDiff; fileName: string | null }) & { actions?: never; arg?: never; args?: never; body?: never; cancellable?: never; capabilities?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; done?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; path?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; selection?: never; sets?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openDiff"; pluginId: string; diff: FileDiff; fileName: string | null }) & { actions?: never; arg?: never; args?: never; body?: never; cancellable?: never; capabilities?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; done?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; path?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; selection?: never; sets?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | /** Plugins, their status or their contributions changed: re-fetch `plugin_list`. */ ({ type: "commandsChanged" }) & { actions?: never; arg?: never; args?: never; body?: never; cancellable?: never; capabilities?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; path?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; selection?: never; sets?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | /** Complete replacement of one plugin's project-scoped decorations. */ @@ -8717,7 +8726,7 @@ export type PluginEvent_Serialize = /** Reply to a content action in this window. */ ({ type: "contentTabReply"; pluginId: string; requestId: string; reply: ContentTabReply }) & { actions?: never; arg?: never; args?: never; body?: never; cancellable?: never; capabilities?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; path?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; request?: never; reveal?: never; root?: never; selection?: never; sets?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | /** Open two texts in this window's diff viewer. */ -({ type: "openDiff"; pluginId: string; diff: ContentDiff; fileName: string | null }) & { actions?: never; arg?: never; args?: never; body?: never; cancellable?: never; capabilities?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; done?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; path?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; selection?: never; sets?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openDiff"; pluginId: string; diff: FileDiff; fileName: string | null }) & { actions?: never; arg?: never; args?: never; body?: never; cancellable?: never; capabilities?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; done?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; path?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; selection?: never; sets?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | /** Plugins, their status or their contributions changed: re-fetch `plugin_list`. */ ({ type: "commandsChanged" }) & { actions?: never; arg?: never; args?: never; body?: never; cancellable?: never; capabilities?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; path?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; selection?: never; sets?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | /** Complete replacement of one plugin's project-scoped decorations. */ diff --git a/src/features/plugins/__tests__/contentEditor.test.tsx b/src/features/plugins/__tests__/contentEditor.test.tsx index a95bfc9f2..d097ada79 100644 --- a/src/features/plugins/__tests__/contentEditor.test.tsx +++ b/src/features/plugins/__tests__/contentEditor.test.tsx @@ -274,6 +274,36 @@ describe("plugin-backed content editor tabs", () => { } }); + it("opens a plugin diff with a missing side as the IDE's one-sided added or deleted file", () => { + const diffs: unknown[] = []; + const unregisterDiff = registerActions([ + { id: "vcs.openDiff", title: "Open Diff", run: ({ arg }) => void diffs.push(arg) }, + ]); + try { + openPluginDiffRequest({ left: null, right: "added\n", fileName: "src/new.ts" }, 10); + openPluginDiffRequest({ left: "deleted\n", right: null, rightLabel: "MR !12", fileName: "old.ts" }, 10); + // `absent` is what the diff viewer shows alone (oneSided), as for the IDE's own added / deleted files. + expect(diffs).toEqual([ + { + path: "plugin-diff:/new.ts", + title: "src/new.ts", + left: { type: "text", text: "", label: "Before", absent: true }, + right: { type: "text", text: "added\n", label: "After" }, + }, + { + path: "plugin-diff:/old.ts", + title: "old.ts", + left: { type: "text", text: "deleted\n", label: "Before" }, + right: { type: "text", text: "", label: "MR !12", absent: true }, + }, + ]); + expect(() => openPluginDiffRequest({ left: null, right: null }, 10)).toThrow(); + expect(diffs).toHaveLength(2); + } finally { + unregisterDiff(); + } + }); + it.each([undefined, "normalized = true\n"])("keeps later edits dirty when a save returns %j", async (replacement) => { const f = setup(); try { diff --git a/src/features/plugins/runtimeUi.tsx b/src/features/plugins/runtimeUi.tsx index 26cfc0723..6df03023f 100644 --- a/src/features/plugins/runtimeUi.tsx +++ b/src/features/plugins/runtimeUi.tsx @@ -581,7 +581,7 @@ export function handleRuntimeEvent(e: PluginEvent): boolean { title: diff.title ?? undefined, fileName: fileName ?? undefined, }, - diff.left.length + diff.right.length, + (diff.left?.length ?? 0) + (diff.right?.length ?? 0), ); } catch (err) { console.warn(`plugin ${e.pluginId} diff:`, err); diff --git a/src/features/plugins/views/contentTab.ts b/src/features/plugins/views/contentTab.ts index fc3cc3119..f8b054fe9 100644 --- a/src/features/plugins/views/contentTab.ts +++ b/src/features/plugins/views/contentTab.ts @@ -32,8 +32,9 @@ export interface PluginContentEditorData { } export interface ContentTabDiff { - left: string; - right: string; + /** `null`: the file doesn't exist on this side (added or deleted). */ + left: string | null; + right: string | null; leftLabel?: string; rightLabel?: string; title?: string; @@ -165,9 +166,11 @@ function validDiff(v: unknown): ContentTabDiff | undefined { throw new Error(tx`Diff too large: a side is over ${MAX_DIFF_SIDE >> 20} MiB`); } } + const validSide = (v: unknown): v is string | null => v === null || bodyText(v, MAX_DIFF_SIDE); if ( - !bodyText(d.left, MAX_DIFF_SIDE) || - !bodyText(d.right, MAX_DIFF_SIDE) || + !validSide(d.left) || + !validSide(d.right) || + (d.left === null && d.right === null) || (d.leftLabel !== undefined && !text(d.leftLabel, 128)) || (d.rightLabel !== undefined && !text(d.rightLabel, 128)) || (d.title !== undefined && !text(d.title, 256)) @@ -198,11 +201,14 @@ export function pluginDiffPath(name: string): string { } export function openPluginDiff(diff: ContentTabDiff, name: string, title: string) { + // A missing side is the IDE's own added / deleted file side: the diff viewer shows the other one alone. + const side = (text: string | null, label: string) => + text === null ? { type: "text", text: "", label, absent: true } : { type: "text", text, label }; void executeAction("vcs.openDiff", { path: pluginDiffPath(name), title: diff.title ?? title, - left: { type: "text", text: diff.left, label: diff.leftLabel ?? tx("Before") }, - right: { type: "text", text: diff.right, label: diff.rightLabel ?? tx("After") }, + left: side(diff.left, diff.leftLabel ?? tx("Before")), + right: side(diff.right, diff.rightLabel ?? tx("After")), }); } diff --git a/wit/commit.wit b/wit/commit.wit index 0caac6fe0..34a6e04a8 100644 --- a/wit/commit.wit +++ b/wit/commit.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// The commit being prepared in the window the current command or event came /// from (the Commit tool window, or the Commit dialog while it is open): the diff --git a/wit/database.wit b/wit/database.wit index 9ab95663c..a2165967a 100644 --- a/wit/database.wit +++ b/wit/database.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Plugin-owned project data sources. Requires database.sources and project trust. /// Runs on the Database subsystem's host, including on remote project servers. diff --git a/wit/decorations.wit b/wit/decorations.wit index db0b04967..a86e12119 100644 --- a/wit/decorations.wit +++ b/wit/decorations.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Editor and project-tree decorations (API 1.4). Requires project.read. An editor set /// follows its file: the file's own project, or the nearest one when it is outside them all. diff --git a/wit/details.wit b/wit/details.wit index 656aed9cd..ce8a48c37 100644 --- a/wit/details.wit +++ b/wit/details.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// What the pane beside the Services tree shows for a plugin's node. interface detail-types { diff --git a/wit/diagnostics.wit b/wit/diagnostics.wit index 8c88fca6c..51c72f240 100644 --- a/wit/diagnostics.wit +++ b/wit/diagnostics.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Optional export (world `plugin-diagnostics`): problems in the current, /// possibly unsaved document, for the languages declared with the diff --git a/wit/endpoints.wit b/wit/endpoints.wit index df7ea70f3..bb283c010 100644 --- a/wit/endpoints.wit +++ b/wit/endpoints.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// HTTP endpoints found in a project (`[[contributes.endpoints]]`). interface endpoints-provider { diff --git a/wit/events.wit b/wit/events.wit index 190a39142..559f96ac4 100644 --- a/wit/events.wit +++ b/wit/events.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Workbench events, delivered in batches to `event-handler.handle`. interface events { diff --git a/wit/exports.wit b/wit/exports.wit index 7e90d003e..944c869db 100644 --- a/wit/exports.wit +++ b/wit/exports.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; interface lifecycle { use types.{context, error}; diff --git a/wit/extensions.wit b/wit/extensions.wit index 51a086e7b..3f7890c4d 100644 --- a/wit/extensions.wit +++ b/wit/extensions.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// What other plugins contributed to the extension points this plugin declares /// (`[[extension-points]]` in `plugin.toml`; the contributors list this plugin diff --git a/wit/file-actions.wit b/wit/file-actions.wit index 9641f3604..2b60cafd0 100644 --- a/wit/file-actions.wit +++ b/wit/file-actions.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Optional export (world `plugin-file-actions`): quick fixes and /// refactorings that create, rename or delete files, next to the text edits diff --git a/wit/fs.wit b/wit/fs.wit index 76ca5f53c..ca0709f57 100644 --- a/wit/fs.wit +++ b/wit/fs.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Files outside the open projects: the configuration of the program a /// plugin integrates with, a tool installed elsewhere, a licence file. diff --git a/wit/host.wit b/wit/host.wit index ff67f0670..d266b84ae 100644 --- a/wit/host.wit +++ b/wit/host.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Writes to the IDE log, tagged with the plugin id. interface log { diff --git a/wit/hover.wit b/wit/hover.wit index e4eed76e0..d339618fa 100644 --- a/wit/hover.wit +++ b/wit/hover.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Optional export (world `plugin-hover`): Markdown added to the hover of /// documents of the languages declared with the `hover` provider kind, diff --git a/wit/indexing.wit b/wit/indexing.wit index fd74e3c27..5b20748df 100644 --- a/wit/indexing.wit +++ b/wit/indexing.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Cross-file associations a plugin publishes for the files it declares under /// `[[contributes.documentIndexers]]`. The host calls `index` in cancellable diff --git a/wit/injections.wit b/wit/injections.wit index 7f5edacc1..22e5da5fa 100644 --- a/wit/injections.wit +++ b/wit/injections.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Embedded languages. The host routes plugin providers and configured language /// servers inside these ranges, preserving host-document UTF-16 coordinates. diff --git a/wit/inlay.wit b/wit/inlay.wit index 90f8ab04d..205154174 100644 --- a/wit/inlay.wit +++ b/wit/inlay.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Optional export (world `plugin-inlay-hints`): inline hints in documents of /// the languages declared with the `inlay-hints` provider kind, including diff --git a/wit/io.wit b/wit/io.wit index cb921509c..771cd33dc 100644 --- a/wit/io.wit +++ b/wit/io.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Problems in files, shown in the editor and the Problems view. interface diagnostics { diff --git a/wit/language-features.wit b/wit/language-features.wit index 1ebd0366e..9f2e989c2 100644 --- a/wit/language-features.wit +++ b/wit/language-features.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Additional language features, called only for declared API 1.4 provider kinds. /// Editor calls have a 50 ms soft / 500 ms hard budget; formatting has 5 seconds. diff --git a/wit/mcp.wit b/wit/mcp.wit index 244dec640..ca3d52341 100644 --- a/wit/mcp.wit +++ b/wit/mcp.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Discovery of the IDE's built-in MCP server; never exposes its URL or token. interface mcp { diff --git a/wit/plugin.wit b/wit/plugin.wit index e414759ef..077eab417 100644 --- a/wit/plugin.wit +++ b/wit/plugin.wit @@ -8,7 +8,7 @@ /// `fs` and `workspace`, and everything else goes through the imports below, /// gated by the capabilities granted in `plugin.toml` (a missing one returns /// `error::denied`). -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; world plugin { import log; diff --git a/wit/providers.wit b/wit/providers.wit index e6f383551..928716ec2 100644 --- a/wit/providers.wit +++ b/wit/providers.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Editor features a plugin provides for the languages it declares under /// `[[contributes.providers]]` (the host calls only declared kinds). They run diff --git a/wit/run-targets.wit b/wit/run-targets.wit index 30d386957..7892e0095 100644 --- a/wit/run-targets.wit +++ b/wit/run-targets.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Project-scoped targets owned by the registering plugin (API 1.4). interface run-targets { diff --git a/wit/run.wit b/wit/run.wit index 2ff8645ce..8bbf4856d 100644 --- a/wit/run.wit +++ b/wit/run.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Launches this plugin's configurations in the invoking window's Run tool window. interface run { diff --git a/wit/semantic.wit b/wit/semantic.wit index 7f67089b5..e53bf51f7 100644 --- a/wit/semantic.wit +++ b/wit/semantic.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Optional export (world `plugin-semantic-tokens`): semantic colouring of /// documents of the languages declared with the `semantic-tokens` provider diff --git a/wit/types.wit b/wit/types.wit index e51c4579a..35987f87a 100644 --- a/wit/types.wit +++ b/wit/types.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Shared types. Positions are 0-based lines and UTF-16 code unit columns, /// as in the editor and LSP. diff --git a/wit/views.wit b/wit/views.wit index cb0e621e8..12208980d 100644 --- a/wit/views.wit +++ b/wit/views.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; /// Declarative views: tool windows declared /// under `[[contributes.views]]` and custom editors under @@ -135,6 +135,10 @@ interface views { } /// A comparison opened by a content action reply. record content-diff { left: string, right: string, left-label: option, right-label: option, title: option } + /// A file's before and after for `open-file-diff` (API 1.10): none is a side + /// where the file doesn't exist (an added file has no left side, a deleted + /// one no right side). + record file-diff { left: option, right: option, left-label: option, right-label: option, title: option } /// Optional updates to an outstanding action or Save request. record content-tab-reply { content: option, saved: option, read-only: option, @@ -156,6 +160,11 @@ interface views { /// of a window. Each side at most 8 MiB (earlier hosts: 1 MiB); a larger /// side fails with `invalid("diff too large: …")`. open-diff: func(diff: content-diff, file-name: option) -> result<_, error>; + /// `open-diff` for a file that may not exist on one side (API 1.10): the + /// diff viewer shows the existing side alone, as for the IDE's own added + /// and deleted files, instead of next to an empty text. Both sides none is + /// `invalid`. + open-file-diff: func(diff: file-diff, file-name: option) -> result<_, error>; /// The view (or every custom editor of that id) shows outdated content: /// the IDE renders it again. diff --git a/wit/workspace.wit b/wit/workspace.wit index e4d3b3da3..fd0799e2c 100644 --- a/wit/workspace.wit +++ b/wit/workspace.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.9.0; +package openidea:plugin@1.10.0; interface workspace { use types.{error, location};