Skip to main content

Vine/Server/Notification/
ApplyTextEdits.rs

1//! Cocoon → `window.applyTextEdits` notification.
2//! Emitted when an extension calls `editor.edit(editBuilder => {...})`.
3//! Cocoon's TextEditor shim collects the edits and sends them here.
4//! Mountain relays `sky://editor/apply-text-edits` so Sky can apply them
5//! via `ICodeEditorService.listCodeEditors()` → `editor.executeEdits(...)`.
6
7use serde_json::Value;
8
9use crate::{Host::VineHost, dev_log};
10
11pub async fn ApplyTextEdits(Host:&dyn VineHost, Parameter:&Value) {
12	let Uri = Parameter.get("uri").and_then(Value::as_str).unwrap_or("").to_string();
13
14	let EditCount = Parameter.get("edits").and_then(Value::as_array).map(|A| A.len()).unwrap_or(0);
15
16	dev_log!("model", "[ApplyTextEdits] uri={} edits={}", Uri, EditCount);
17
18	if Uri.is_empty() || EditCount == 0 {
19		return;
20	}
21
22	Host.EmitToRenderer("sky://editor/apply-text-edits", Parameter.clone());
23}