edit prediction cli: Skip worktree scan (#44658)

Release Notes:

- N/A

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
Agus Zubiaga
2025-12-11 21:05:50 +00:00
committed by GitHub
co-authored by Max Brunsfeld
parent b5a0a3322d
commit 37f2ac24b8
10 changed files with 149 additions and 51 deletions
+22 -2
View File
@@ -11,7 +11,7 @@ use futures::{
lock::{Mutex, OwnedMutexGuard},
};
use gpui::{AsyncApp, Entity};
use language::{Anchor, Buffer, ToOffset, ToPoint};
use language::{Anchor, Buffer, LanguageNotFound, ToOffset, ToPoint};
use project::buffer_store::BufferStoreEvent;
use project::{Project, ProjectPath};
use std::{
@@ -77,6 +77,19 @@ async fn cursor_position(
project: &Entity<Project>,
cx: &mut AsyncApp,
) -> (Entity<Buffer>, Anchor) {
let language_registry = project
.read_with(cx, |project, _| project.languages().clone())
.unwrap();
let result = language_registry
.load_language_for_file_path(&example.cursor_path)
.await;
if let Err(error) = result
&& !error.is::<LanguageNotFound>()
{
panic!("Failed to load language for file path: {}", error);
}
let worktree = project
.read_with(cx, |project, cx| {
project.visible_worktrees(cx).next().unwrap()
@@ -115,7 +128,8 @@ async fn cursor_position(
let mut matches = text.match_indices(&cursor_excerpt);
let (excerpt_offset, _) = matches.next().unwrap_or_else(|| {
panic!(
"\nExcerpt:\n\n{cursor_excerpt}\nBuffer text:\n{text}\n.Cursor excerpt did not exist in buffer."
"\nExcerpt:\n\n{cursor_excerpt}\nBuffer text:\n{text}\n.Example: {}\nCursor excerpt did not exist in buffer.",
example.name
);
});
assert!(matches.next().is_none(), "More than one cursor position match found for {}", &example.name);
@@ -151,6 +165,12 @@ async fn setup_project(
})
.unwrap();
project
.update(cx, |project, cx| {
project.disable_worktree_scanner(cx);
})
.unwrap();
let worktree = project
.update(cx, |project, cx| {
project.create_worktree(&example.worktree_path(), true, cx)
+7 -3
View File
@@ -45,7 +45,7 @@ enum Command {
/// Parse markdown examples and output a combined .jsonl file
ParseExample,
/// Create git worktrees for each example and load file contents
LoadBuffer,
LoadProject,
/// Retrieve context for input examples.
Context,
/// Generate a prompt string for a specific model
@@ -144,15 +144,19 @@ fn main() {
_ => (),
};
for data in examples.chunks_mut(args.max_parallelism) {
let chunks = examples.chunks_mut(args.max_parallelism);
let total_chunks = chunks.len();
for (batch_ix, data) in chunks.enumerate() {
let mut futures = Vec::new();
eprintln!("Processing batch: {}/{}", batch_ix + 1, total_chunks);
for example in data.iter_mut() {
let cx = cx.clone();
let app_state = app_state.clone();
futures.push(async {
match &command {
Command::ParseExample => {}
Command::LoadBuffer => {
Command::LoadProject => {
run_load_project(example, app_state.clone(), cx).await;
}
Command::Context => {
@@ -8,7 +8,7 @@ use collections::HashSet;
use edit_prediction::{DebugEvent, EditPredictionStore};
use futures::{FutureExt as _, StreamExt as _, channel::mpsc};
use gpui::{AsyncApp, Entity, Task};
use language::{Buffer, LanguageNotFound};
use language::Buffer;
use project::Project;
use std::{sync::Arc, time::Duration};
@@ -71,19 +71,6 @@ async fn wait_for_language_server_to_start(
buffer: &Entity<Buffer>,
cx: &mut AsyncApp,
) {
let language_registry = project
.read_with(cx, |project, _| project.languages().clone())
.unwrap();
let result = language_registry
.load_language_for_file_path(&example.cursor_path)
.await;
if let Err(error) = result
&& !error.is::<LanguageNotFound>()
{
panic!("Failed to load language for file path: {}", error);
}
let Some(language_id) = buffer
.read_with(cx, |buffer, _cx| {
buffer.language().map(|language| language.id())