This is the final event needed to complete the event loop refactor! The next few changes will be focused on completing the migration and cleaning up the codebase.
OMUOCCBAGL4O7U6XO4CJNMU4CQYZVJG2BXAZD5UAZUNMSCBG3PSQC VKCHFDMCESSKL5AVZB3PNHAX2N2V4KOQ7OOZ6BHZE2AILFBJ2QMAC 57DXWD6GZPHURKSCV4Z6TN2FCY4VM4HLVQP7ZE75Y3EEDJ7IHJVAC 2ZAM5V35CAQD5MOFPZEGU4ERQ2FM5CL5MB2DOJDW2ZQ74IQFBISQC M5RW5PN4VFYZOKHUFMVWR2XAUAXHUYROVZFTS3RIE7AAUGTVHAEQC XRFRJHZM4TEIQCSEEESJG3SCPFRLJRHOWHVCGW5744YBKF6ONW2AC WFWTKCJNC4VSURSQWE5FXJGTEJJOCDMQ6LN2O6EW2DNOVT2ZUMRQC 3YGYMEXVHOHRQVPC53MVPSLI2ZJM77MBPWNPDDCL56DNCPUC6XTAC let old_uri = renamed_file.get_old_uri()?;let new_uri = renamed_file.get_new_uri()?;let old_absolute_path = Utf8PathBuf::from(old_uri.get_fs_path()?);let new_absolute_path = Utf8PathBuf::from(new_uri.get_fs_path()?);
let old_vscode_uri = renamed_file.get_old_uri()?;let new_vscode_uri = renamed_file.get_new_uri()?;
// TODO: handle renaming/moves across workspacesif let Some((workspace_path, open_repository)) = extension_state.repositories.get_open_repository_mut(env, &old_uri)?{let old_relative_path =old_absolute_path.strip_prefix(&workspace_path).map_err(|error| {napi::Error::from_reason(format!("Path {old_absolute_path} not in {workspace_path}: {error}"))})?;let new_relative_path =new_absolute_path.strip_prefix(&workspace_path).map_err(|error| {napi::Error::from_reason(format!("Path {new_absolute_path} not in {workspace_path}: {error}"))})?;
let old_uri = uri::from_vscode(&old_vscode_uri)?;let new_uri = uri::from_vscode(&new_vscode_uri)?;
open_repository.repository.move_path(old_relative_path, new_relative_path.to_path_buf()).map_err(|error| {napi::Error::from_reason(format!("Unable to move {old_absolute_path} to {new_absolute_path}: {error:#?}"))})?;open_repository.update_resource_states(env, &workspace_path)?;} else {tracing::info!(message = "Ignoring move outside of workspace",?old_absolute_path,?new_absolute_path);}
event_loop::send(Event::MovePath { old_uri, new_uri });
use camino::Utf8PathBuf;use iri_string::types::UriAbsoluteString;use crate::event_loop::ExtensionState;#[tracing::instrument(skip(extension_state))]pub async fn handle(old_uri: UriAbsoluteString,new_uri: UriAbsoluteString,extension_state: &mut ExtensionState,) {let Some((repository_path, old_path, repository)) =extension_state.get_repository_mut(&old_uri)else {tracing::info!(message = "Ignoring filesystem changes");return;};if new_uri.scheme_str() != "file" {tracing::info!(message = "Ignoring move to unsupported URI");return;}// TODO: handle moving between repositories, and in/out of themlet new_path = Utf8PathBuf::from(new_uri.path_str()).strip_prefix(repository_path).unwrap().to_path_buf();match repository.repository.move_path(old_path, new_path) {Ok(()) => {tracing::info!(message = "Moved paths");}Err(error) => {tracing::error!(message = "Failed to move paths", ?error);}}}