Skip to main content

DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/Command/TreeView/
RevealTreeViewItem.rs

1//! Tauri command - focus / scroll-into-view a specific tree item.
2//! `Options` carries the LSP-shaped `select`, `focus`, `expand`
3//! booleans (matches `vscode.TreeView.reveal`).
4
5use std::sync::Arc;
6
7use CommonLibrary::TreeView::TreeViewProvider::TreeViewProvider;
8use serde_json::{Value, json};
9use tauri::{AppHandle, Manager, State, Wry, command};
10
11use crate::{
12	ApplicationState::State::ApplicationState::ApplicationState,
13	Environment::MountainEnvironment::MountainEnvironment,
14	RunTime::ApplicationRunTime::ApplicationRunTime,
15	dev_log,
16};
17
18#[command]
19pub async fn RevealTreeViewItem(
20	ApplicationHandle:AppHandle<Wry>,
21
22	_State:State<'_, Arc<ApplicationState>>,
23
24	ViewId:String,
25
26	ItemHandle:String,
27
28	Options:Option<Value>,
29) -> Result<Value, String> {
30	dev_log!("commands", "revealing item '{}' in view '{}'", ItemHandle, ViewId);
31
32	let RunTime = ApplicationHandle.state::<Arc<ApplicationRunTime>>().inner().clone();
33
34	let Environment:Arc<MountainEnvironment> = RunTime.Environment.clone();
35
36	let OptionsValue = Options.unwrap_or(json!({}));
37
38	match Environment.RevealTreeItem(ViewId.clone(), ItemHandle, OptionsValue).await {
39		Ok(_) => Ok(json!({ "success": true })),
40
41		Err(Error) => {
42			let ErrorMessage = format!("Failed to reveal tree item in view '{}': {}", ViewId, Error);
43
44			dev_log!("commands", "error: {}", ErrorMessage);
45
46			Err(ErrorMessage)
47		},
48	}
49}