From ffe14e22cd3251d4d60deba0c79b1a6a440e0daf Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Thu, 5 Nov 2026 16:00:21 +0800 Subject: [PATCH] fix(plugins): hand plugins paths in one form on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plugins got the project root, editor path, provider documents, code action edits, vcs-status roots and find-files results as D:\… while event paths from the UI use /, so Checkstyle could not find the project of a saved file. The host now converts every path it hands to plugins with ipc_path::to_ipc. --- crates/ide-host/src/plugins/api.rs | 5 +++-- crates/ide-plugin/src/runtime.rs | 10 +++------- crates/ide-plugin/src/wit_host.rs | 6 ++++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/crates/ide-host/src/plugins/api.rs b/crates/ide-host/src/plugins/api.rs index 375ab1829..350c4ddfc 100644 --- a/crates/ide-host/src/plugins/api.rs +++ b/crates/ide-host/src/plugins/api.rs @@ -2,6 +2,7 @@ //! Capabilities were checked by the runtime before any of this runs. use super::{PluginEvent, PluginEventSink}; +use ide_core::ipc_path::to_ipc; use ide_core::{CancellationToken, TextEdit}; use ide_extension::Package; use ide_language::ProgramPin; @@ -419,7 +420,7 @@ impl HostApi for PluginApi { let info = repo.branch_info().map_err(failed)?; let changed = repo.status().map_err(failed)?.len(); Ok(Some(RepositoryStatus { - root: repo.root().to_string_lossy().into_owned(), + root: to_ipc(repo.root()), branch: info.head, commit: info.head_commit, upstream: info.upstream, @@ -467,7 +468,7 @@ impl HostApi for PluginApi { } let Ok(rel) = entry.path().strip_prefix(root) else { continue }; if matcher.is_match(rel) { - out.push(entry.path().to_string_lossy().into_owned()); + out.push(to_ipc(entry.path())); } } out.sort(); diff --git a/crates/ide-plugin/src/runtime.rs b/crates/ide-plugin/src/runtime.rs index 19d97abb7..5dd6830f2 100644 --- a/crates/ide-plugin/src/runtime.rs +++ b/crates/ide-plugin/src/runtime.rs @@ -13,6 +13,7 @@ use crate::types::{ }; use crate::wit_host::{bindings, providers_bindings, syntax_bindings, views_bindings}; use ide_core::CancellationToken; +use ide_core::ipc_path::to_ipc; use ide_extension::Capability; use parking_lot::Mutex; use std::path::Path; @@ -935,12 +936,7 @@ fn location_from_wit(l: wit_types::Location) -> Location { } fn doc_to_wit(d: &ProviderDocument) -> wit_prov::Document { - wit_prov::Document { - path: d.path.to_string_lossy().into_owned(), - language: d.language.clone(), - version: d.version, - text: d.text.clone(), - } + wit_prov::Document { path: to_ipc(&d.path), language: d.language.clone(), version: d.version, text: d.text.clone() } } /// Resets the budgets for the next call: fuel, deadline, cancellation. @@ -1012,7 +1008,7 @@ fn code_action_to_wit(a: &CodeAction) -> wit_prov::CodeAction { .edits .iter() .map(|(path, edits)| wit_prov::FileEdit { - path: path.to_string_lossy().into_owned(), + path: to_ipc(path), edits: edits .iter() .map(|e| wit_types::TextEdit { range: range_to_wit(e.range), text: e.new_text.clone() }) diff --git a/crates/ide-plugin/src/wit_host.rs b/crates/ide-plugin/src/wit_host.rs index b274a088c..a1f7b7533 100644 --- a/crates/ide-plugin/src/wit_host.rs +++ b/crates/ide-plugin/src/wit_host.rs @@ -5,6 +5,7 @@ use crate::runtime::{StoreData, clip}; use crate::sandbox; use crate::types::{EditorContext, EventKind, HostError, HttpRequest, NotificationLevel, StatusItem, net_host}; +use ide_core::ipc_path::to_ipc; use ide_extension::Capability; use std::path::{Path, PathBuf}; use std::time::{Duration, Instant}; @@ -310,7 +311,8 @@ impl workspace::HostProject for StoreData { if let Err(e) = self.require(Capability::ProjectRead) { return Ok(Err(e)); } - Ok(Ok(self.table.get(&this)?.root.to_string_lossy().into_owned())) + // Paths reach plugins in IPC form (`/` on Windows), as the UI's event paths do, so they compare as text. + Ok(Ok(to_ipc(&self.table.get(&this)?.root))) } fn read_file(&mut self, this: Resource, path: String) -> Fallible { @@ -346,7 +348,7 @@ impl editor::Host for StoreData {} impl editor::HostTextEditor for StoreData { fn path(&mut self, this: Resource) -> wasmtime::Result { - Ok(self.table.get(&this)?.ctx.path.to_string_lossy().into_owned()) + Ok(to_ipc(&self.table.get(&this)?.ctx.path)) } fn language(&mut self, this: Resource) -> wasmtime::Result {