load changed files src when selected

[?]
Apr 22, 2025, 6:25 PM
NRCUG4R2NIM2ANIETSUZ7WZDXFOOCMJ73ROP5MDYJA4RUT4PYA4QC

Dependencies

  • [2] WT3GA27P add cursor with selection
  • [3] EC3TVL4X add untracked files
  • [4] KT5UYXGK fix selection after adding file, add changed file diffs
  • [5] YBJRDOTC make all repo actions async
  • [6] D7A7MSIH allow to defer or abandon record, add buttons
  • [7] 4WO3ZJM2 show untracked files' contents
  • [8] W4LFX7IH group diffs by file name
  • [9] PTFDJ567 add untracked files encoding
  • [10] AMPZ2BXK show changed files diffs (only Edit atm)
  • [11] V55EAIWQ add src file LRU cache
  • [12] ELG3UDT6 allow to rm added files
  • [13] W7IUT3ZV start recording impl
  • [14] UCBNZULE make changed files paths optional (no path for root)
  • [15] 6YZAVBWU Initial commit
  • [16] BJXUYQ2Y show untracked file contents in read-only text editor
  • [17] NOB64XMR fmt and clippy

Change contents

  • edit in crates/flowers_ui/src/main.rs at line 161
    [11.1790][7.2460:2567](),[6.78][7.2460:2567](),[7.2567][9.179:215](),[9.215][7.2696:2705](),[7.2696][7.2696:2705](),[7.2705][9.216:217](),[7.2706][7.2706:2723]()
    enum UntrackedFileContents {
    Loading {
    path: String,
    },
    Loaded {
    path: String,
    content: FileEditorContent,
    },
    }
    #[derive(Debug)]
  • edit in crates/flowers_ui/src/main.rs at line 171
    [11.1792]
    [11.1792]
    /// The order of the vec matches `repo::ChangedFile`
    type ChangedFileContents = Vec<Option<FileEditorContent>>;
  • replacement in crates/flowers_ui/src/main.rs at line 192
    [11.2159][11.2159:2201]()
    pub enum ChangedFileDiffWithoutContents {
    [11.2159]
    [11.2201]
    enum ChangedFileDiffWithoutContents {
  • edit in crates/flowers_ui/src/main.rs at line 204
    [10.1689][9.507:508](),[11.2380][9.507:508](),[9.507][9.507:508](),[9.508][10.1690:1802]()
    /// The order of the vec matches `repo::ChangedFile`
    type ChangedFileContents = Vec<Option<FileEditorContent>>;
  • edit in crates/flowers_ui/src/main.rs at line 258
    [7.3003][11.2874:2899]()
    // Load the file
  • replacement in crates/flowers_ui/src/main.rs at line 263
    [5.6557][4.4765:4798](),[3.2511][4.4765:4798](),[4.4798][5.6558:6621](),[5.6621][8.3205:3399](),[8.3399][4.5061:5128](),[5.6701][4.5061:5128](),[4.5061][4.5061:5128]()
    let changed_file_selection =
    |repo: &repo::State, ix: usize| -> cursor::Selection {
    let path = repo
    .changed_files
    .iter()
    .nth(ix)
    .map(|(k, _v)| k)
    .unwrap()
    .clone();
    cursor::Selection::ChangedFile { ix, path }
    };
    [5.6557]
    [3.2511]
    let changed_file_selection = |repo: &repo::State,
    ix: usize,
    src_files_cache: &mut SrcFilesCache,
    src_file_load_tx: &watch::Sender<String>|
    -> cursor::Selection {
    let path = repo
    .changed_files
    .iter()
    .nth(ix)
    .map(|(k, _v)| k)
    .unwrap()
    .clone();
    load_src_file_if_not_cached(src_files_cache, src_file_load_tx, &path);
  • edit in crates/flowers_ui/src/main.rs at line 278
    [3.2512]
    [5.6702]
    cursor::Selection::ChangedFile { ix, path }
    };
  • replacement in crates/flowers_ui/src/main.rs at line 317
    [5.7721][5.7721:7790]()
    changed_file_selection(repo, ix)
    [5.7721]
    [5.7790]
    changed_file_selection(
    repo,
    ix,
    &mut state.src_files_cache,
    &state.src_file_load_tx,
    )
  • replacement in crates/flowers_ui/src/main.rs at line 344
    [3.4211][5.8396:8461]()
    changed_file_selection(repo, ix)
    [3.4211]
    [3.4272]
    changed_file_selection(
    repo,
    ix,
    &mut state.src_files_cache,
    &state.src_file_load_tx,
    )
  • replacement in crates/flowers_ui/src/main.rs at line 361
    [3.4488][5.8530:8591]()
    changed_file_selection(repo, ix)
    [3.4488]
    [3.4545]
    changed_file_selection(
    repo,
    ix,
    &mut state.src_files_cache,
    &state.src_file_load_tx,
    )
  • replacement in crates/flowers_ui/src/main.rs at line 376
    [3.5000][5.8850:8921]()
    Some(changed_file_selection(repo, ix))
    [3.5000]
    [3.5061]
    Some(changed_file_selection(
    repo,
    ix,
    &mut state.src_files_cache,
    &state.src_file_load_tx,
    ))
  • replacement in crates/flowers_ui/src/main.rs at line 412
    [5.9610][5.9610:9675]()
    changed_file_selection(repo, ix)
    [5.9610]
    [5.9675]
    changed_file_selection(
    repo,
    ix,
    &mut state.src_files_cache,
    &state.src_file_load_tx,
    )
  • replacement in crates/flowers_ui/src/main.rs at line 434
    [5.10179][5.10179:10244]()
    changed_file_selection(repo, ix)
    [5.10179]
    [5.10244]
    changed_file_selection(
    repo,
    ix,
    &mut state.src_files_cache,
    &state.src_file_load_tx,
    )
  • replacement in crates/flowers_ui/src/main.rs at line 451
    [5.10497][5.10497:10558]()
    changed_file_selection(repo, ix)
    [5.10497]
    [5.10558]
    changed_file_selection(
    repo,
    ix,
    &mut state.src_files_cache,
    &state.src_file_load_tx,
    )
  • replacement in crates/flowers_ui/src/main.rs at line 475
    [5.11123][5.11123:11190]()
    Some(changed_file_selection(repo, ix))
    [5.11123]
    [2.2471]
    Some(changed_file_selection(
    repo,
    ix,
    &mut state.src_files_cache,
    &state.src_file_load_tx,
    ))
  • replacement in crates/flowers_ui/src/main.rs at line 490
    [7.5852][7.5852:5889]()
    // Load the file
    [7.5852]
    [11.4041]
    load_src_file_if_not_cached(
    &mut state.src_files_cache,
    &state.src_file_load_tx,
    path,
    );
    }
    cursor::Selection::ChangedFile { path, .. } => {
  • edit in crates/flowers_ui/src/main.rs at line 503
    [7.6175][7.6175:6235]()
    cursor::Selection::ChangedFile { .. } => {}
  • replacement in crates/flowers_ui/src/main.rs at line 583
    [5.13827][5.13827:13898]()
    Some(changed_file_selection(repo, ix))
    [5.13827]
    [5.13898]
    Some(changed_file_selection(
    repo,
    ix,
    &mut state.src_files_cache,
    &state.src_file_load_tx,
    ))
  • replacement in crates/flowers_ui/src/main.rs at line 827
    [7.8142][5.15972:16155](),[5.15972][5.15972:16155](),[5.16155][8.4198:4520](),[8.4520][5.16379:16407](),[5.16379][5.16379:16407]()
    cursor::Selection::ChangedFile { ix: _, path } => repo
    .changed_files
    .iter()
    .enumerate()
    .find(|(_ix, (file_path, _diffs))| file_path == &path)
    .map(|(ix, (file_path, _diffs))| {
    cursor::Selection::ChangedFile {
    ix,
    path: file_path.clone(),
    }
    }),
    [7.8142]
    [5.16407]
    cursor::Selection::ChangedFile { ix: _, path } => {
    load_src_file_if_not_cached(
    &mut state.src_files_cache,
    &state.src_file_load_tx,
    &path,
    );
    repo.changed_files
    .iter()
    .enumerate()
    .find(|(_ix, (file_path, _diffs))| {
    file_path == &path
    })
    .map(|(ix, (file_path, _diffs))| {
    cursor::Selection::ChangedFile {
    ix,
    path: file_path.clone(),
    }
    })
    }