forked from 1b-agent/opencadstudio-upstream
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:
1 parent
1c52a2afcf
commit
0d766be3df
6 files changed
+13
-11
No files matched your search
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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()),
|
||||
),
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user