Skip to main content

DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceHandlers/Model/
ModelClose.rs

1//! Close a text model. Drops the entry from
2//! `ApplicationState.Feature.Documents`. Idempotent - closing
3//! an already-closed URI is a no-op.
4
5use std::sync::Arc;
6
7use serde_json::Value;
8
9use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
10
11pub async fn Fn(RunTime:Arc<ApplicationRunTime>, Arguments:Vec<Value>) -> Result<Value, String> {
12	let Uri = Arguments
13		.first()
14		.and_then(|V| V.as_str())
15		.ok_or("model:close requires uri".to_string())?;
16
17	RunTime.Environment.ApplicationState.Feature.Documents.Remove(Uri);
18
19	Ok(Value::Null)
20}