EC3TVL4X6VZZVLOKUN63LC73ADPHBHMZO7QMDXGX2ZPURVI4B4XQC 6YZAVBWU6E5FYOI5JGEIPXGZLIKAW6LS2AOFIQWEE5DMOPPCD5PQC KLR5FRIBS6UOH3S3XAOE22TJACVSVOY7TOLW22DIWNGY27S6WZRAC IQDCHWCP47LL46EXQLQGHQPGFYIHQLMQBHA57RWJCIOX5UEUIQAQC SWWE2R6MVBX5CNM6X3WLXZTSRTU53PBJL7WJSFVF77XBPXDX4COAC WT3GA27PQ2AOAIGK65O3Q4DMX4AZDVNULBLRL6GF4QW6QCASUEAAC DVKSPF7R5QBWRHNADU7LK37OVZHOHNDSRETUVY6GNXWE74SHXSUAC UB2ITZJSDADVINSQEZ3HA6PVGA7OA6JYFG5GMSO7Y7LOXJC4FI7AC }).collect()}fn untracked_files(repo: &pijul::Repository) -> BTreeSet<String> {let repo_path = CanonicalPathBuf::canonicalize(&repo.path).unwrap();let txn = repo.pristine.arc_txn_begin().unwrap();let threads = std::thread::available_parallelism().unwrap().get();let txn_ = txn.clone();repo.working_copy.iterate_prefix_rec(repo_path.clone(),repo_path.clone(),false,threads,move |path, _| {use path_slash::PathExt;let path_str = path.to_slash_lossy();path_str.is_empty() || txn.read().is_tracked(&path_str).unwrap()},).unwrap().filter_map(move |path| {let (path, _) = path.unwrap();use path_slash::PathExt;let path_str = path.to_slash_lossy();if !txn_.read().is_tracked(&path_str).unwrap() {Some(path_str.into_owned())} else {None}
let changed_file_path =|ix| state.repo.changed_files.iter().nth(ix).unwrap().clone();
let untracked_file_selection = |ix: usize| -> cursor::Selection {let path = state.repo.untracked_files.iter().nth(ix).unwrap().clone();cursor::Selection::UntrackedFile { ix, path }};let changed_file_selection = |ix: usize| -> cursor::Selection {let path = state.repo.changed_files.iter().nth(ix).unwrap().clone();cursor::Selection::ChangedFile { ix, path }};
// Re-index cursor selectionif let Some(selection) = state.cursor.selection.as_ref() {// Try to find the file with the same name. If not found, remove// selectionstate.cursor.selection = match selection {cursor::Selection::UntrackedFile { ix: _, path } => state.repo.untracked_files.iter().enumerate().find(|(_ix, file_path)| *file_path == path).map(|(ix, path)| cursor::Selection::UntrackedFile {ix,path: path.clone(),}),cursor::Selection::ChangedFile { ix: _, path } => state.repo.changed_files.iter().enumerate().find(|(_ix, file_path)| *file_path == path).map(|(ix, path)| cursor::Selection::ChangedFile {ix,path: path.clone(),}),};}
state.cursor.selection =Some(match state.cursor.selection.as_ref() {Some(cursor::Selection::Channel) => {if state.repo.changed_files.is_empty() {cursor::Selection::Channel
state.cursor.selection = match state.cursor.selection.as_ref() {Some(cursor::Selection::UntrackedFile { ix, path: _ }) => {let new_selection =if state.repo.untracked_files.len().saturating_sub(1)== *ix{if state.repo.changed_files.is_empty() {let ix = 0;untracked_file_selection(ix)} else {let ix = 0;changed_file_selection(ix)}
let ix = 0;let path = changed_file_path(ix);cursor::Selection::File { ix, path }}}Some(cursor::Selection::File { ix, path: _ }) => {
let ix = ix + 1;untracked_file_selection(ix)};Some(new_selection)}Some(cursor::Selection::ChangedFile { ix, path: _ }) => {let new_selection =
let path = changed_file_path(ix);cursor::Selection::File { ix, path }
changed_file_selection(ix)};Some(new_selection)}None => {if state.repo.untracked_files.is_empty() {if state.repo.changed_files.is_empty() {None} else {let ix = 0;Some(changed_file_selection(ix))
state.cursor.selection =Some(match state.cursor.selection.as_ref() {Some(cursor::Selection::Channel) | None => {
state.cursor.selection = match state.cursor.selection.as_ref() {Some(cursor::Selection::UntrackedFile { ix, path: _ }) => {let new_selection = if 0 == *ix {
}Some(cursor::Selection::File { ix, path: _ }) => {if 0 == *ix {cursor::Selection::Channel
} else {let ix = ix - 1;untracked_file_selection(ix)};Some(new_selection)}Some(cursor::Selection::ChangedFile { ix, path: _ }) => {let new_selection = if 0 == *ix {if state.repo.untracked_files.is_empty() {let ix = state.repo.changed_files.len() - 1;changed_file_selection(ix)
let ix = *ix - 1;let path = changed_file_path(ix);cursor::Selection::File { ix, path }
let ix = state.repo.untracked_files.len() - 1;untracked_file_selection(ix)}} else {let ix = ix - 1;changed_file_selection(ix)};Some(new_selection)}None => {if state.repo.changed_files.is_empty() {if state.repo.untracked_files.is_empty() {None} else {let ix = state.repo.untracked_files.len() - 1;Some(untracked_file_selection(ix))
let untracked_files =Element::from(column(state.repo.untracked_files.iter().enumerate().map(|(ix, path)| {let is_selected = matches!(state.cursor.selection.as_ref() ,Some(cursor::Selection::UntrackedFile{ix: selected_ix, path:_}) if &ix == selected_ix);Element::from(button(text(path)).on_press(Message::CursorSelect(cursor::Selection::UntrackedFile{ix, path: path.clone()},)).style(selectable_button_style(is_selected)),)},)));