Skip to main content

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};
8use ::Vine::Generated::{ShowTextDocumentRequest, ShowTextDocumentResponse};
9
10use crate::{RPC::CocoonService::CocoonServiceImpl, dev_log};
11
12pub async fn Fn(
13	Service:&CocoonServiceImpl,
14
15	Request:ShowTextDocumentRequest,
16) -> Result<Response<ShowTextDocumentResponse>, Status> {
17	let URI = Request.uri.as_ref().map(|U| U.value.clone()).unwrap_or_default();
18
19	dev_log!("cocoon", "[CocoonService] show_text_document: {}", URI);
20
21	let _ = Service.environment.ApplicationHandle.emit(
22		"sky://editor/openDocument",
23		json!({ "uri": URI, "viewColumn": Request.view_column }),
24	);
25
26	Ok(Response::new(ShowTextDocumentResponse { success:true }))
27}