fix(plugins): preserve document path encoding

Keep OS-native path data intact across IPC instead of replacing non-UTF-8 bytes.

Refs #901
This commit is contained in:
Hakan Seven committed 2026-08-29 16:00:18 +03:00
1 parent 1c52a2afcf
commit 0d766be3df
6 files changed
+13 -11

No files matched your search

+2 -3
View File
@@ -542,9 +542,8 @@ pub trait HostApi {
}
/// Return the filesystem path of the document in tab `tab_id`, if any.
/// Added after API v4; appended at the very end so older plugins compiled
/// without it keep stable vtable indices. The default returns `None`;
/// in-process hosts should override it to expose the real path.
/// Added in API v5. The default returns `None`; in-process hosts should
/// override it to expose the real path.
fn document_path(&self, tab_id: u64) -> Option<PathBuf> {
let _ = tab_id;
None
+3 -3
View File
@@ -136,7 +136,7 @@ pub enum PluginRequest {
CloseDocumentViewV4 { tab_id: u64 },
/// V4: ask the host for the stable tab identifier of the active tab.
GetTabId,
/// V4: ask the host for the filesystem path of the document in `tab_id`.
/// V5: ask the host for the filesystem path of the document in `tab_id`.
DocumentPath { tab_id: u64 },
}
@@ -162,8 +162,8 @@ pub enum PluginResponse {
},
/// V4: stable tab identifier of the active tab.
TabId(u64),
/// V4: filesystem path of the document in the requested tab, if any.
DocumentPath(Option<String>),
/// V5: filesystem path of the document in the requested tab, if any.
DocumentPath(Option<std::ffi::OsString>),
}
/// Messages sent from the host to the plugin runner.
+3 -3
View File
@@ -74,8 +74,8 @@ pub fn handle_plugin_request(
PluginResponse::Ok
}
GetTabId => PluginResponse::TabId(host.tab_id()),
DocumentPath { tab_id } => {
PluginResponse::DocumentPath(host.document_path(tab_id).map(|p| p.to_string_lossy().to_string()))
}
DocumentPath { tab_id } => PluginResponse::DocumentPath(
host.document_path(tab_id).map(|path| path.into_os_string()),
),
}
}