forked from 1b-agent/opencadstudio-upstream
feat(plugins): expose document path to plugins via HostApi
OpenCADStudio/plugins#901 (comment) - Add HostApi::document_path(tab_id) returning Option<PathBuf>. - Add PluginRequest::DocumentPath and PluginResponse::DocumentPath for out-of-process plugins. - Implement the request in the IPC server and in both V3/V4 plugin-side HostApi proxies. - Implement HostSession::document_path by looking up the tab by id and returning its current_path.
This commit is contained in:
1 parent
3024869de0
commit
09ba67bfd1
6 files changed
+58
No files matched your search
@@ -401,6 +401,21 @@ impl HostApi for PluginHostApi {
|
||||
None => Box::new(EmptyDocumentReader),
|
||||
}
|
||||
}
|
||||
|
||||
fn document_path(&self, tab_id: u64) -> Option<std::path::PathBuf> {
|
||||
match self.client.request(PluginRequest::DocumentPath { tab_id }) {
|
||||
Ok(PluginResponse::DocumentPath(Some(path))) => Some(std::path::PathBuf::from(path)),
|
||||
Ok(PluginResponse::DocumentPath(None)) => None,
|
||||
Ok(other) => {
|
||||
eprintln!("[plugin] unexpected DocumentPath response: {other:?}");
|
||||
None
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("[plugin] DocumentPath request failed: {e}");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Sentinel reader used when the shared-memory view could not be initialized.
|
||||
|
||||
Reference in new issue
Block a user