Skip to main content

DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/RPC/CocoonService/Window/
ShowTextDocument.rs

1//! Open a document in the workbench. Maps to `sky://editor/openDocument`
2//! (same channel as `Workspace::OpenDocument::Fn`; this is the
3//! window-namespace alias).
4
5use serde_json::json;
6use tauri::Emitter;
7use tonic::{Response, Status};
8
9use crate::{
10	RPC::CocoonService::CocoonServiceImpl,
11	Vine::Generated::{ShowTextDocumentRequest, ShowTextDocumentResponse},
12	dev_log,
13};
14
15pub async fn Fn(
16	Service:&CocoonServiceImpl,
17
18	Request:ShowTextDocumentRequest,
19) -> Result<Response<ShowTextDocumentResponse>, Status> {
20	let URI = Request.uri.as_ref().map(|U| U.value.clone()).unwrap_or_default();
21
22	dev_log!("cocoon", "[CocoonService] show_text_document: {}", URI);
23
24	let _ = Service.environment.ApplicationHandle.emit(
25		"sky://editor/openDocument",
26		json!({ "uri": URI, "viewColumn": Request.view_column }),
27	);
28
29	Ok(Response::new(ShowTextDocumentResponse { success:true }))
30}