luaur_cli_lib/methods/
vfs_navigator_reset_to_std_in.rs1use crate::enums::navigation_status::NavigationStatus;
2use crate::functions::get_current_working_directory::get_current_working_directory;
3use crate::functions::get_module_path::get_module_path;
4use crate::functions::normalize_path::normalize_path;
5use crate::records::vfs_navigator::VfsNavigator;
6use luaur_common::macros::luau_assert::LUAU_ASSERT;
7
8pub fn vfs_navigator_reset_to_std_in(navigator: &mut VfsNavigator) -> NavigationStatus {
9 let cwd = get_current_working_directory();
10 if cwd.is_none() {
11 return NavigationStatus::NotFound;
12 }
13
14 navigator.real_path = "./stdin".to_string();
15 navigator.absolute_real_path = normalize_path(&(cwd.unwrap() + "/stdin"));
16 navigator.module_path = "./stdin".to_string();
17 navigator.absolute_module_path = get_module_path(&navigator.absolute_real_path);
18
19 let first_slash = navigator.absolute_real_path.find('/');
20 LUAU_ASSERT!(first_slash.is_some());
21
22 navigator.absolute_path_prefix = navigator
23 .absolute_real_path
24 .get(..first_slash.unwrap())
25 .unwrap_or("")
26 .to_string();
27
28 NavigationStatus::Success
29}