@@ -2097,6 +2097,17 @@ impl EditPredictionStore {
});
}
+ #[cfg(feature = "cli-support")]
+ pub fn set_recent_paths_for_project(
+ &mut self,
+ project: &Entity<Project>,
+ paths: impl IntoIterator<Item = project::ProjectPath>,
+ cx: &mut Context<Self>,
+ ) {
+ let project_state = self.get_or_init_project(project, cx);
+ project_state.recent_paths = paths.into_iter().collect();
+ }
+
fn is_file_open_source(
&self,
project: &Entity<Project>,
@@ -23,6 +23,10 @@ impl OpenedBuffers {
pub fn get(&self, path: &str) -> Option<&Entity<Buffer>> {
self.0.get(path)
}
+
+ pub fn buffers(&self) -> impl Iterator<Item = &Entity<Buffer>> {
+ self.0.values()
+ }
}
#[must_use]
@@ -12,8 +12,7 @@ use edit_prediction::{
use futures::AsyncWriteExt as _;
use gpui::{AsyncApp, Entity};
use language::{Anchor, Buffer, LanguageNotFound, ToOffset, ToPoint};
-use project::Project;
-use project::buffer_store::BufferStoreEvent;
+use project::{Project, ProjectPath, buffer_store::BufferStoreEvent};
use std::{fs, path::PathBuf, sync::Arc};
pub async fn run_load_project(
@@ -32,6 +31,25 @@ pub async fn run_load_project(
progress.set_substatus("applying edit history");
let open_buffers = apply_edit_history(example, &project, &mut cx).await?;
+ let ep_store = cx
+ .update(|cx| EditPredictionStore::try_global(cx))
+ .context("EditPredictionStore not initialized")?;
+
+ let recent_paths: Vec<ProjectPath> = open_buffers
+ .buffers()
+ .filter_map(|buffer| {
+ buffer.read_with(&cx, |buffer, cx| {
+ buffer
+ .file()
+ .map(|file| ProjectPath::from_file(file.as_ref(), cx))
+ })
+ })
+ .collect();
+
+ ep_store.update(&mut cx, |store, cx| {
+ store.set_recent_paths_for_project(&project, recent_paths, cx);
+ });
+
progress.set_substatus("resolving cursor");
let (buffer, cursor_position) =
cursor_position(example, &project, &open_buffers, &mut cx).await?;
@@ -39,10 +57,6 @@ pub async fn run_load_project(
.read_with(&cx, |buffer, _| buffer.parsing_idle())
.await;
- let ep_store = cx
- .update(|cx| EditPredictionStore::try_global(cx))
- .context("EditPredictionStore not initialized")?;
-
let edit_history = ep_store.update(&mut cx, |store, cx| {
store
.edit_history_for_project(&project, cx)