Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/edit_prediction/src/edit_prediction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ fn compute_diff_between_snapshots_in_range(
Some((diff, new_start_point..new_end_point))
}

fn buffer_path_with_id_fallback(
pub(crate) fn buffer_path_with_id_fallback(
file: Option<&Arc<dyn File>>,
snapshot: &TextBufferSnapshot,
cx: &App,
Expand Down
22 changes: 22 additions & 0 deletions crates/edit_prediction/src/edit_prediction_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3417,6 +3417,28 @@ async fn test_edit_prediction_settled(cx: &mut TestAppContext) {
}
}

#[gpui::test]
fn test_buffer_path_with_id_fallback_for_untitled_buffers(cx: &mut TestAppContext) {
let buffer_1 = cx.new(|cx| Buffer::local("one", cx));
let buffer_2 = cx.new(|cx| Buffer::local("two", cx));

let snapshot_1 = buffer_1.read_with(cx, |buffer, _| buffer.text_snapshot());
let snapshot_2 = buffer_2.read_with(cx, |buffer, _| buffer.text_snapshot());

let path_1 = cx.read(|cx| buffer_path_with_id_fallback(None, &snapshot_1, cx));
let path_2 = cx.read(|cx| buffer_path_with_id_fallback(None, &snapshot_2, cx));

assert_eq!(
path_1.as_ref(),
Path::new(&format!("untitled-{}", snapshot_1.remote_id()))
);
assert_eq!(
path_2.as_ref(),
Path::new(&format!("untitled-{}", snapshot_2.remote_id()))
);
assert_ne!(path_1.as_ref(), path_2.as_ref());
}

#[gpui::test]
async fn test_data_collection_disabled_by_default(cx: &mut TestAppContext) {
let (ep_store, _channels) = init_test_with_fake_client(cx);
Expand Down
7 changes: 2 additions & 5 deletions crates/edit_prediction/src/zeta.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
CurrentEditPrediction, DebugEvent, EditPredictionFinishedDebugEvent, EditPredictionId,
EditPredictionModelInput, EditPredictionStartedDebugEvent, EditPredictionStore, StoredEvent,
ZedUpdateRequiredError,
ZedUpdateRequiredError, buffer_path_with_id_fallback,
cursor_excerpt::{self, compute_cursor_excerpt, compute_syntax_ranges},
prediction::EditPredictionResult,
};
Expand Down Expand Up @@ -70,10 +70,7 @@ pub fn request_prediction_with_zeta(
let preferred_experiment = store.preferred_experiment().map(|s| s.to_owned());
let open_ai_compatible_api_key = load_open_ai_compatible_api_key_if_needed(provider, cx);

let excerpt_path: Arc<Path> = snapshot
.file()
.map(|file| -> Arc<Path> { file.full_path(cx).into() })
.unwrap_or_else(|| Arc::from(Path::new("untitled")));
let excerpt_path = buffer_path_with_id_fallback(snapshot.file(), &snapshot.text, cx);

let repo_url = if can_collect_data {
let buffer_id = buffer.read(cx).remote_id();
Expand Down
4 changes: 1 addition & 3 deletions crates/zed/src/zed/edit_prediction_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,7 @@ fn assign_edit_prediction_provider(
ep_store.update(cx, |this, cx| this.start_copilot_for_project(&project, cx));

if let Some(copilot) = copilot {
if let Some(buffer) = singleton_buffer
&& buffer.read(cx).file().is_some()
{
if let Some(buffer) = singleton_buffer {
copilot.update(cx, |copilot, cx| {
copilot.register_buffer(&buffer, cx);
});
Expand Down
Loading