Add `MovePath` event

finchie
Jan 2, 2026, 12:27 PM
OMUOCCBAGL4O7U6XO4CJNMU4CQYZVJG2BXAZD5UAZUNMSCBG3PSQC

Dependencies

  • [2] VKCHFDMC Create simple `FileSystemWatcher`
  • [3] 57DXWD6G Handle file rename/move events in VS Code extension
  • [4] 2ZAM5V35 Move event handling into modules
  • [5] M5RW5PN4 Add `OpenTextEditor` event
  • [6] XRFRJHZM Add `ChangedFilesystemContents` event
  • [7] WFWTKCJN Create initial Visual Studio Code extension
  • [*] 3YGYMEXV Create `event_loop` module

Change contents

  • replacement in editors/vscode/src/lib.rs at line 263
    [3.654][3.654:675]()
    env: &napi::Env,
    [3.654]
    [3.675]
    _env: &napi::Env,
  • edit in editors/vscode/src/lib.rs at line 266
    [3.746][3.746:800](),[3.925][3.925:926]()
    let mut extension_state = ExtensionState::get()?;
  • replacement in editors/vscode/src/lib.rs at line 267
    [3.971][3.971:1223]()
    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()?);
    [3.971]
    [3.1223]
    let old_vscode_uri = renamed_file.get_old_uri()?;
    let new_vscode_uri = renamed_file.get_new_uri()?;
  • replacement in editors/vscode/src/lib.rs at line 270
    [3.1224][3.1224:2159]()
    // TODO: handle renaming/moves across workspaces
    if 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}"
    ))
    })?;
    [3.1224]
    [3.2159]
    let old_uri = uri::from_vscode(&old_vscode_uri)?;
    let new_uri = uri::from_vscode(&new_vscode_uri)?;
  • replacement in editors/vscode/src/lib.rs at line 273
    [3.2160][3.2160:2525](),[3.2591][3.2591:2871]()
    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
    );
    }
    [3.2160]
    [2.1679]
    event_loop::send(Event::MovePath { old_uri, new_uri });
  • edit in editors/vscode/src/event_loop/mod.rs at line 141
    [6.791]
    [6.791]
    Event::MovePath { old_uri, new_uri } => {
    event::move_path::handle(old_uri, new_uri, &mut extension_state).await
    }
  • file addition: move_path.rs (----------)
    [4.332]
    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 them
    let 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);
    }
    }
    }
  • edit in editors/vscode/src/event_loop/event/mod.rs at line 8
    [6.3457]
    [5.5913]
    pub mod move_path;
  • edit in editors/vscode/src/event_loop/event/mod.rs at line 35
    [6.3465]
    [6.3465]
    MovePath {
    old_uri: UriAbsoluteString,
    new_uri: UriAbsoluteString,
    },