V55EAIWQXWER2HWKZHPJBV7DDJMSPSPWSO3FSSAYODJHVDBHUN6QC 6YZAVBWU6E5FYOI5JGEIPXGZLIKAW6LS2AOFIQWEE5DMOPPCD5PQC IQDCHWCP47LL46EXQLQGHQPGFYIHQLMQBHA57RWJCIOX5UEUIQAQC SWWE2R6MVBX5CNM6X3WLXZTSRTU53PBJL7WJSFVF77XBPXDX4COAC UB2ITZJSDADVINSQEZ3HA6PVGA7OA6JYFG5GMSO7Y7LOXJC4FI7AC S2NVIFXRFER4SRA37WCT5XTXHDHAL5WIGGKY4A4XOTPLTKTZSRGQC YBJRDOTCX3ZRDB5EVXJBR55FX3CADCSIGMYWNYVC2PD5W3GXR3DQC KM5PSZ4A2FJOPHJA6RC7LHZAUXLQDZDQC2DVSE5YUORLFIPZO74QC 2VUX5BTDKHX3TJ677NW34H5WLSWH35C3PU46C7MXCN5O7PAZVXNQC A5YBC77VWH2LXCZJOPZORQJI5ZYABSCHJWVX5HVNWPM5RABXESLQC D7A7MSIHJS3IAOLEPK52M4CZLDPLO7JB3Y62XACT2AM6UUCPQ6BAC 4WO3ZJM2RNYZCBPS7FGYAEBELYD57OSS7LEUYCWGZBCAY272SNQQC BJXUYQ2YQMVULJITT5FEA6NERJVLWFKEAWSBYZVIB7KAT27KOWBAC PTFDJ567XGGF26TE7KVQT7WPZIWV737DBO24VFIPEWPVAVKEKADQC AMPZ2BXK4IGUZO3OPBRSJ6Z4GI5K4PRFMLUGTR6AP4FKKRWQG7LQC let (untracked_file_load_tx, untracked_file_load_rx) =watch::channel("".to_string());let untracked_file_load_rx =WatchStream::from_changes(untracked_file_load_rx);
let (src_file_load_tx, src_file_load_rx) = watch::channel("".to_string());let untracked_file_load_rx = WatchStream::from_changes(src_file_load_rx);
.map(move |path| (repo_path_clone.clone(), path)).then(|(repo_path, path)| async {load_untracked_file(repo_path, path).await
.map(move |file_path| (repo_path_clone.clone(), file_path)).then(|(repo_path, file_path)| async {load_src_file(repo_path, file_path).await
enum SrcFile {Loading,Loaded(FileEditorContent),}#[derive(Debug)]struct SrcFileCacheWeight;impl WeightScale<String, SrcFile> for SrcFileCacheWeight {fn weight(&self, key: &String, value: &SrcFile) -> usize {let key_weight = key.as_bytes().len();let value_weight = match value {SrcFile::Loading => 0,SrcFile::Loaded(file_editor_content) => match file_editor_content {FileEditorContent::Decoded(content) => {content.text().as_bytes().len()}FileEditorContent::ShortBase64(string) => {string.as_bytes().len()}FileEditorContent::UnknownEncoding => 0,},};key_weight + value_weight}}#[derive(Debug)]
#[derive(Debug)]enum ChangedFileDiffWithContents {Add,Edit {line: usize,deleted: bool,content: FileEditorContent,},Replacement {line: usize,/// Deleted linechange_contents: FileEditorContent,/// Added linesreplacement_contents: FileEditorContent,},}#[derive(Debug)]pub enum ChangedFileDiffWithoutContents {Move,Del,Undel,SolveNameConflict,UnsolveNameConflict,SolveOrderConflict,UnsolveOrderConflict,ResurrectZombines,AddRoot,DelRoot,}
let untracked_file_selection =|repo: &repo::State,ix: usize,untracked_file_contents: &mut Option<UntrackedFileContents>,untracked_file_load_tx: &watch::Sender<String>|-> cursor::Selection {let path = repo.untracked_files.iter().nth(ix).unwrap().clone();
let untracked_file_selection = |repo: &repo::State,ix: usize,src_files_cache: &mut SrcFilesCache,src_file_load_tx: &watch::Sender<String,>|-> cursor::Selection {let path = repo.untracked_files.iter().nth(ix).unwrap().clone();
match &state.untracked_file_contents {Some(UntrackedFileContents::Loading { path: loading_path }) => {if &path == loading_path {state.untracked_file_contents =Some(UntrackedFileContents::Loaded {path,content,});}}// Reloaded fileSome(UntrackedFileContents::Loaded {path: loaded_path,content: _,}) => {if &path == loaded_path {state.untracked_file_contents =Some(UntrackedFileContents::Loaded {path,content,});}
match state.src_files_cache.get(&path) {Some(SrcFile::Loading | SrcFile::Loaded(_)) => {src_files_cache_put(&mut state.src_files_cache,path,SrcFile::Loaded(content),);
if let Some(UntrackedFileContents::Loaded {content: FileEditorContent::Decoded(content),..}) = &mut state.untracked_file_contents
if let Some(SrcFile::Loaded(FileEditorContent::Decoded(mut content),..,)) = state.src_files_cache.pop(&path)
fn load_src_file_if_not_cached(cache: &mut SrcFilesCache,load_tx: &watch::Sender<String>,path: &str,) {if !cache.contains(path) {src_files_cache_put(cache, path.to_string(), SrcFile::Loading);load_tx.send(path.to_string()).unwrap();}}fn src_files_cache_put(cache: &mut SrcFilesCache, key: String, value: SrcFile) {if let Err((key, value)) = cache.put_with_weight(key, value) {let kv_weight = SrcFileCacheWeight.weight(&key, &value);info!("Source file cache is too small to hold {key}. Resizing cache to to {kv_weight} fit it.");cache.resize(NonZero::new(kv_weight).unwrap());let res = cache.put_with_weight(key, value);assert!(res.is_ok());}}fn src_files_cache_clear(cache: &mut SrcFilesCache) {cache.clear();}
let diff = match &state.untracked_file_contents {Some(UntrackedFileContents::Loaded {path: loaded_path,content,}) if loaded_path == path => match content {
let diff = match &state.src_files_cache.peek(path) {Some(SrcFile::Loaded(content)) => match content {