Further work should add more incrementality to support recording and amending, along with tracking when to fire onDidChangeFileDecorations.
IDY5SNLOFZ663OCJ2L5NZMFNJXZSGL5O22QQXR5BIV3SJ2VUQIMQC 3YGYMEXVHOHRQVPC53MVPSLI2ZJM77MBPWNPDDCL56DNCPUC6XTAC NB2MF3MYAJ25KNZP3GMHX42LUSBYOX6FTNLIBK3CQ7CMANFZFEGQC XDFSAPI75FQXHD3ZMYBEGROQ35VQC3WQFQ5EJQAWUXTCKR2N62LAC MGJ23FHFUNT4RSJP3AW5ZALGEDTNZPR4PLHLPOCFNEBIX2WHV2JAC OUADGWKR6A7G3UHCLSC7AWLJIMS45Y56NPVTQ7FENJPYNTAMXXMAC 2ZAM5V35CAQD5MOFPZEGU4ERQ2FM5CL5MB2DOJDW2ZQ74IQFBISQC SLTXBK5GTNH3PUZNA5VG7IDICV3NZPWSCTJSE4YPOQEDMWO67PIQC TWEUQ64DU5ZXAEG67GQSS7GDEZ2O2JR5352WRVIIUK5J7ZOMO5QAC QY4Z5ZXZ7G6DZFCTRPX7D6TIDZ5DHSDTLOWFDANIPUHOEKQRAIXAC IBVCQSSGPKLQTD4T4TAJZRC4LY3G6FP4QWFEBHN5KEFI44ZGGAXQC unrecorded_changes: vscode_sys::reference::SourceControlResourceGroupRef,untracked_paths: vscode_sys::reference::SourceControlResourceGroupRef,
unrecorded_changes: Rc<vscode_sys::reference::SourceControlResourceGroupRef>,untracked_paths: Rc<vscode_sys::reference::SourceControlResourceGroupRef>,
use std::rc::Rc;use camino::Utf8PathBuf;use napi::bindgen_prelude::{External, FunctionCallContext};use pijul_extension::path_state::PathState;use crate::vscode_sys::reference::SourceControlResourceGroupRef;use crate::vscode_sys::{SourceControlResourceState, Uri};pub struct Arguments {pub repository_path: Utf8PathBuf,pub repository_states: Vec<(Utf8PathBuf, PathState)>,pub unrecorded_changes: Rc<SourceControlResourceGroupRef>,pub untracked_paths: Rc<SourceControlResourceGroupRef>,}pub type Prototype = napi::threadsafe_function::ThreadsafeFunction<External<Arguments>,(),External<Arguments>,napi::Status,false,false,0,>;pub fn build(env: &napi::Env) -> Result<Prototype, napi::Error> {env.create_function_from_closure("update_resource_states", callback)?.build_threadsafe_function().build()}fn callback(function_call_context: FunctionCallContext) -> Result<(), napi::Error> {let (external,): (&External<Arguments>,) = function_call_context.args()?;let Arguments {repository_path,repository_states,unrecorded_changes,untracked_paths,} = &**external;let mut modified_resource_states = Vec::new();let mut untracked_resource_states = Vec::new();for (relative_path, path_state) in repository_states {let absolute_path = repository_path.join(relative_path);let resource_uri = Uri::file(function_call_context.env, absolute_path.as_str())?;let resource_state =SourceControlResourceState::new(function_call_context.env, &resource_uri)?;match path_state {PathState::Untracked => untracked_resource_states.push(resource_state),PathState::Tracked(_tracked_state) => modified_resource_states.push(resource_state),}}unrecorded_changes.get_inner(function_call_context.env)?.set_resource_states(modified_resource_states)?;untracked_paths.get_inner(function_call_context.env)?.set_resource_states(untracked_resource_states)?;Ok(())}
.call_async(External::new(arguments)).await}pub async fn update_resource_states(&self,repository_path: Utf8PathBuf,repository_states: Vec<(Utf8PathBuf, PathState)>,unrecorded_changes: &Rc<vscode_sys::reference::SourceControlResourceGroupRef>,untracked_paths: &Rc<vscode_sys::reference::SourceControlResourceGroupRef>,) -> Result<(), napi::Error> {let arguments = update_resource_states::Arguments {repository_path,repository_states,unrecorded_changes: Rc::clone(unrecorded_changes),untracked_paths: Rc::clone(untracked_paths),};self.update_resource_states
use std::collections::HashMap;use camino::Utf8PathBuf;use crate::event_loop::Repository;use crate::event_loop::js_function::Functions;#[tracing::instrument(skip(repositories, js_functions))]pub async fn handle(repository_path: Utf8PathBuf,repositories: &HashMap<Utf8PathBuf, Repository>,js_functions: &Functions,) {let Some(repository) = repositories.get(&repository_path) else {tracing::error!(message = "No repository found", ?repository_path);return;};if let Err(error) = js_functions.update_resource_states(repository_path,repository.repository.iter_path_states().collect(),&repository.unrecorded_changes,&repository.untracked_paths,).await{tracing::error!(message = "Failed to update resource states", ?error);}}