Rename remaining mentions of "inline completion" to "edit prediction" (#35512)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-08-04 10:22:18 -06:00 committed by GitHub
parent 85885723a9
commit 65018c28c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 480 additions and 498 deletions

96
Cargo.lock generated
View file

@ -3542,13 +3542,13 @@ dependencies = [
"command_palette_hooks",
"ctor",
"dirs 4.0.0",
"edit_prediction",
"editor",
"fs",
"futures 0.3.31",
"gpui",
"http_client",
"indoc",
"inline_completion",
"itertools 0.14.0",
"language",
"log",
@ -4855,6 +4855,49 @@ dependencies = [
"signature 1.6.4",
]
[[package]]
name = "edit_prediction"
version = "0.1.0"
dependencies = [
"client",
"gpui",
"language",
"project",
"workspace-hack",
]
[[package]]
name = "edit_prediction_button"
version = "0.1.0"
dependencies = [
"anyhow",
"client",
"cloud_llm_client",
"copilot",
"edit_prediction",
"editor",
"feature_flags",
"fs",
"futures 0.3.31",
"gpui",
"indoc",
"language",
"lsp",
"paths",
"project",
"regex",
"serde_json",
"settings",
"supermaven",
"telemetry",
"theme",
"ui",
"workspace",
"workspace-hack",
"zed_actions",
"zeta",
]
[[package]]
name = "editor"
version = "0.1.0"
@ -4870,6 +4913,7 @@ dependencies = [
"ctor",
"dap",
"db",
"edit_prediction",
"emojis",
"file_icons",
"fs",
@ -4879,7 +4923,6 @@ dependencies = [
"gpui",
"http_client",
"indoc",
"inline_completion",
"itertools 0.14.0",
"language",
"languages",
@ -8287,49 +8330,6 @@ dependencies = [
"syn 2.0.101",
]
[[package]]
name = "inline_completion"
version = "0.1.0"
dependencies = [
"client",
"gpui",
"language",
"project",
"workspace-hack",
]
[[package]]
name = "inline_completion_button"
version = "0.1.0"
dependencies = [
"anyhow",
"client",
"cloud_llm_client",
"copilot",
"editor",
"feature_flags",
"fs",
"futures 0.3.31",
"gpui",
"indoc",
"inline_completion",
"language",
"lsp",
"paths",
"project",
"regex",
"serde_json",
"settings",
"supermaven",
"telemetry",
"theme",
"ui",
"workspace",
"workspace-hack",
"zed_actions",
"zeta",
]
[[package]]
name = "inotify"
version = "0.9.6"
@ -15584,12 +15584,12 @@ dependencies = [
"anyhow",
"client",
"collections",
"edit_prediction",
"editor",
"env_logger 0.11.8",
"futures 0.3.31",
"gpui",
"http_client",
"inline_completion",
"language",
"log",
"postage",
@ -20221,6 +20221,7 @@ dependencies = [
"debugger_tools",
"debugger_ui",
"diagnostics",
"edit_prediction_button",
"editor",
"env_logger 0.11.8",
"extension",
@ -20240,7 +20241,6 @@ dependencies = [
"http_client",
"image_viewer",
"indoc",
"inline_completion_button",
"inspector_ui",
"install_cli",
"itertools 0.14.0",
@ -20572,6 +20572,7 @@ dependencies = [
"copilot",
"ctor",
"db",
"edit_prediction",
"editor",
"feature_flags",
"fs",
@ -20579,7 +20580,6 @@ dependencies = [
"gpui",
"http_client",
"indoc",
"inline_completion",
"language",
"language_model",
"log",

View file

@ -79,8 +79,8 @@ members = [
"crates/icons",
"crates/image_viewer",
"crates/indexed_docs",
"crates/inline_completion",
"crates/inline_completion_button",
"crates/edit_prediction",
"crates/edit_prediction_button",
"crates/inspector_ui",
"crates/install_cli",
"crates/jj",
@ -302,8 +302,8 @@ http_client_tls = { path = "crates/http_client_tls" }
icons = { path = "crates/icons" }
image_viewer = { path = "crates/image_viewer" }
indexed_docs = { path = "crates/indexed_docs" }
inline_completion = { path = "crates/inline_completion" }
inline_completion_button = { path = "crates/inline_completion_button" }
edit_prediction = { path = "crates/edit_prediction" }
edit_prediction_button = { path = "crates/edit_prediction_button" }
inspector_ui = { path = "crates/inspector_ui" }
install_cli = { path = "crates/install_cli" }
jj = { path = "crates/jj" }
@ -756,7 +756,7 @@ feature_flags = { codegen-units = 1 }
file_icons = { codegen-units = 1 }
fsevent = { codegen-units = 1 }
image_viewer = { codegen-units = 1 }
inline_completion_button = { codegen-units = 1 }
edit_prediction_button = { codegen-units = 1 }
install_cli = { codegen-units = 1 }
journal = { codegen-units = 1 }
lmstudio = { codegen-units = 1 }

View file

@ -162,7 +162,7 @@ impl InlineAssistant {
let window = windows[0];
let _ = window.update(cx, |_, window, cx| {
editor.update(cx, |editor, cx| {
if editor.has_active_inline_completion() {
if editor.has_active_edit_prediction() {
editor.cancel(&Default::default(), window, cx);
}
});
@ -231,8 +231,8 @@ impl InlineAssistant {
);
if DisableAiSettings::get_global(cx).disable_ai {
// Cancel any active completions
if editor.has_active_inline_completion() {
// Cancel any active edit predictions
if editor.has_active_edit_prediction() {
editor.cancel(&Default::default(), window, cx);
}
}

View file

@ -12,7 +12,7 @@ use assistant_slash_commands::{
use client::{proto, zed_urls};
use collections::{BTreeSet, HashMap, HashSet, hash_map};
use editor::{
Anchor, Editor, EditorEvent, MenuInlineCompletionsPolicy, MultiBuffer, MultiBufferSnapshot,
Anchor, Editor, EditorEvent, MenuEditPredictionsPolicy, MultiBuffer, MultiBufferSnapshot,
RowExt, ToOffset as _, ToPoint,
actions::{MoveToEndOfLine, Newline, ShowCompletions},
display_map::{
@ -254,7 +254,7 @@ impl TextThreadEditor {
editor.set_show_wrap_guides(false, cx);
editor.set_show_indent_guides(false, cx);
editor.set_completion_provider(Some(Rc::new(completion_provider)));
editor.set_menu_inline_completions_policy(MenuInlineCompletionsPolicy::Never);
editor.set_menu_edit_predictions_policy(MenuEditPredictionsPolicy::Never);
editor.set_collaboration_hub(Box::new(project.clone()));
let show_edit_predictions = all_language_settings(None, cx)

View file

@ -580,7 +580,7 @@ fn for_snowflake(
},
serde_json::to_value(e).unwrap(),
),
Event::InlineCompletion(e) => (
Event::EditPrediction(e) => (
format!(
"Edit Prediction {}",
if e.suggestion_accepted {
@ -591,7 +591,7 @@ fn for_snowflake(
),
serde_json::to_value(e).unwrap(),
),
Event::InlineCompletionRating(e) => (
Event::EditPredictionRating(e) => (
"Edit Prediction Rated".to_string(),
serde_json::to_value(e).unwrap(),
),

View file

@ -34,7 +34,7 @@ fs.workspace = true
futures.workspace = true
gpui.workspace = true
http_client.workspace = true
inline_completion.workspace = true
edit_prediction.workspace = true
language.workspace = true
log.workspace = true
lsp.workspace = true

View file

@ -1,7 +1,7 @@
use crate::{Completion, Copilot};
use anyhow::Result;
use edit_prediction::{Direction, EditPrediction, EditPredictionProvider};
use gpui::{App, Context, Entity, EntityId, Task};
use inline_completion::{Direction, EditPredictionProvider, InlineCompletion};
use language::{Buffer, OffsetRangeExt, ToOffset, language_settings::AllLanguageSettings};
use project::Project;
use settings::Settings;
@ -210,7 +210,7 @@ impl EditPredictionProvider for CopilotCompletionProvider {
buffer: &Entity<Buffer>,
cursor_position: language::Anchor,
cx: &mut Context<Self>,
) -> Option<InlineCompletion> {
) -> Option<EditPrediction> {
let buffer_id = buffer.entity_id();
let buffer = buffer.read(cx);
let completion = self.active_completion()?;
@ -241,7 +241,7 @@ impl EditPredictionProvider for CopilotCompletionProvider {
None
} else {
let position = cursor_position.bias_right(buffer);
Some(InlineCompletion {
Some(EditPrediction {
id: None,
edits: vec![(position..position, completion_text.into())],
edit_preview: None,
@ -343,7 +343,7 @@ mod tests {
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
cx.update_editor(|editor, window, cx| {
assert!(editor.context_menu_visible());
assert!(!editor.has_active_inline_completion());
assert!(!editor.has_active_edit_prediction());
// Since we have both, the copilot suggestion is not shown inline
assert_eq!(editor.text(cx), "one.\ntwo\nthree\n");
assert_eq!(editor.display_text(cx), "one.\ntwo\nthree\n");
@ -355,7 +355,7 @@ mod tests {
.unwrap()
.detach();
assert!(!editor.context_menu_visible());
assert!(!editor.has_active_inline_completion());
assert!(!editor.has_active_edit_prediction());
assert_eq!(editor.text(cx), "one.completion_a\ntwo\nthree\n");
assert_eq!(editor.display_text(cx), "one.completion_a\ntwo\nthree\n");
});
@ -389,7 +389,7 @@ mod tests {
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
cx.update_editor(|editor, _, cx| {
assert!(!editor.context_menu_visible());
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
// Since only the copilot is available, it's shown inline
assert_eq!(editor.display_text(cx), "one.copilot1\ntwo\nthree\n");
assert_eq!(editor.text(cx), "one.\ntwo\nthree\n");
@ -400,7 +400,7 @@ mod tests {
executor.run_until_parked();
cx.update_editor(|editor, _, cx| {
assert!(!editor.context_menu_visible());
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one.copilot1\ntwo\nthree\n");
assert_eq!(editor.text(cx), "one.c\ntwo\nthree\n");
});
@ -418,25 +418,25 @@ mod tests {
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
cx.update_editor(|editor, window, cx| {
assert!(!editor.context_menu_visible());
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one.copilot2\ntwo\nthree\n");
assert_eq!(editor.text(cx), "one.c\ntwo\nthree\n");
// Canceling should remove the active Copilot suggestion.
editor.cancel(&Default::default(), window, cx);
assert!(!editor.has_active_inline_completion());
assert!(!editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one.c\ntwo\nthree\n");
assert_eq!(editor.text(cx), "one.c\ntwo\nthree\n");
// After canceling, tabbing shouldn't insert the previously shown suggestion.
editor.tab(&Default::default(), window, cx);
assert!(!editor.has_active_inline_completion());
assert!(!editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one.c \ntwo\nthree\n");
assert_eq!(editor.text(cx), "one.c \ntwo\nthree\n");
// When undoing the previously active suggestion is shown again.
editor.undo(&Default::default(), window, cx);
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one.copilot2\ntwo\nthree\n");
assert_eq!(editor.text(cx), "one.c\ntwo\nthree\n");
});
@ -444,25 +444,25 @@ mod tests {
// If an edit occurs outside of this editor, the suggestion is still correctly interpolated.
cx.update_buffer(|buffer, cx| buffer.edit([(5..5, "o")], None, cx));
cx.update_editor(|editor, window, cx| {
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one.copilot2\ntwo\nthree\n");
assert_eq!(editor.text(cx), "one.co\ntwo\nthree\n");
// AcceptEditPrediction when there is an active suggestion inserts it.
editor.accept_edit_prediction(&Default::default(), window, cx);
assert!(!editor.has_active_inline_completion());
assert!(!editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one.copilot2\ntwo\nthree\n");
assert_eq!(editor.text(cx), "one.copilot2\ntwo\nthree\n");
// When undoing the previously active suggestion is shown again.
editor.undo(&Default::default(), window, cx);
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one.copilot2\ntwo\nthree\n");
assert_eq!(editor.text(cx), "one.co\ntwo\nthree\n");
// Hide suggestion.
editor.cancel(&Default::default(), window, cx);
assert!(!editor.has_active_inline_completion());
assert!(!editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one.co\ntwo\nthree\n");
assert_eq!(editor.text(cx), "one.co\ntwo\nthree\n");
});
@ -471,7 +471,7 @@ mod tests {
// we won't make it visible.
cx.update_buffer(|buffer, cx| buffer.edit([(6..6, "p")], None, cx));
cx.update_editor(|editor, _, cx| {
assert!(!editor.has_active_inline_completion());
assert!(!editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one.cop\ntwo\nthree\n");
assert_eq!(editor.text(cx), "one.cop\ntwo\nthree\n");
});
@ -498,19 +498,19 @@ mod tests {
});
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
cx.update_editor(|editor, window, cx| {
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "fn foo() {\n let x = 4;\n}");
assert_eq!(editor.text(cx), "fn foo() {\n \n}");
// Tabbing inside of leading whitespace inserts indentation without accepting the suggestion.
editor.tab(&Default::default(), window, cx);
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.text(cx), "fn foo() {\n \n}");
assert_eq!(editor.display_text(cx), "fn foo() {\n let x = 4;\n}");
// Using AcceptEditPrediction again accepts the suggestion.
editor.accept_edit_prediction(&Default::default(), window, cx);
assert!(!editor.has_active_inline_completion());
assert!(!editor.has_active_edit_prediction());
assert_eq!(editor.text(cx), "fn foo() {\n let x = 4;\n}");
assert_eq!(editor.display_text(cx), "fn foo() {\n let x = 4;\n}");
});
@ -575,17 +575,17 @@ mod tests {
);
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
cx.update_editor(|editor, window, cx| {
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
// Accepting the first word of the suggestion should only accept the first word and still show the rest.
editor.accept_partial_inline_completion(&Default::default(), window, cx);
assert!(editor.has_active_inline_completion());
editor.accept_partial_edit_prediction(&Default::default(), window, cx);
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.text(cx), "one.copilot\ntwo\nthree\n");
assert_eq!(editor.display_text(cx), "one.copilot1\ntwo\nthree\n");
// Accepting next word should accept the non-word and copilot suggestion should be gone
editor.accept_partial_inline_completion(&Default::default(), window, cx);
assert!(!editor.has_active_inline_completion());
editor.accept_partial_edit_prediction(&Default::default(), window, cx);
assert!(!editor.has_active_edit_prediction());
assert_eq!(editor.text(cx), "one.copilot1\ntwo\nthree\n");
assert_eq!(editor.display_text(cx), "one.copilot1\ntwo\nthree\n");
});
@ -617,11 +617,11 @@ mod tests {
);
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
cx.update_editor(|editor, window, cx| {
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
// Accepting the first word (non-word) of the suggestion should only accept the first word and still show the rest.
editor.accept_partial_inline_completion(&Default::default(), window, cx);
assert!(editor.has_active_inline_completion());
editor.accept_partial_edit_prediction(&Default::default(), window, cx);
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.text(cx), "one.123. \ntwo\nthree\n");
assert_eq!(
editor.display_text(cx),
@ -629,8 +629,8 @@ mod tests {
);
// Accepting next word should accept the next word and copilot suggestion should still exist
editor.accept_partial_inline_completion(&Default::default(), window, cx);
assert!(editor.has_active_inline_completion());
editor.accept_partial_edit_prediction(&Default::default(), window, cx);
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.text(cx), "one.123. copilot\ntwo\nthree\n");
assert_eq!(
editor.display_text(cx),
@ -638,8 +638,8 @@ mod tests {
);
// Accepting the whitespace should accept the non-word/whitespaces with newline and copilot suggestion should be gone
editor.accept_partial_inline_completion(&Default::default(), window, cx);
assert!(!editor.has_active_inline_completion());
editor.accept_partial_edit_prediction(&Default::default(), window, cx);
assert!(!editor.has_active_edit_prediction());
assert_eq!(editor.text(cx), "one.123. copilot\n 456\ntwo\nthree\n");
assert_eq!(
editor.display_text(cx),
@ -692,29 +692,29 @@ mod tests {
});
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
cx.update_editor(|editor, window, cx| {
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one\ntwo.foo()\nthree\n");
assert_eq!(editor.text(cx), "one\ntw\nthree\n");
editor.backspace(&Default::default(), window, cx);
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one\ntwo.foo()\nthree\n");
assert_eq!(editor.text(cx), "one\nt\nthree\n");
editor.backspace(&Default::default(), window, cx);
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one\ntwo.foo()\nthree\n");
assert_eq!(editor.text(cx), "one\n\nthree\n");
// Deleting across the original suggestion range invalidates it.
editor.backspace(&Default::default(), window, cx);
assert!(!editor.has_active_inline_completion());
assert!(!editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one\nthree\n");
assert_eq!(editor.text(cx), "one\nthree\n");
// Undoing the deletion restores the suggestion.
editor.undo(&Default::default(), window, cx);
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one\ntwo.foo()\nthree\n");
assert_eq!(editor.text(cx), "one\n\nthree\n");
});
@ -775,7 +775,7 @@ mod tests {
});
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
_ = editor.update(cx, |editor, _, cx| {
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(
editor.display_text(cx),
"\n\na = 1\nb = 2 + a\n\n\n\nc = 3\nd = 4\n"
@ -797,7 +797,7 @@ mod tests {
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
s.select_ranges([Point::new(4, 5)..Point::new(4, 5)])
});
assert!(!editor.has_active_inline_completion());
assert!(!editor.has_active_edit_prediction());
assert_eq!(
editor.display_text(cx),
"\n\na = 1\nb = 2\n\n\n\nc = 3\nd = 4\n"
@ -806,7 +806,7 @@ mod tests {
// Type a character, ensuring we don't even try to interpolate the previous suggestion.
editor.handle_input(" ", window, cx);
assert!(!editor.has_active_inline_completion());
assert!(!editor.has_active_edit_prediction());
assert_eq!(
editor.display_text(cx),
"\n\na = 1\nb = 2\n\n\n\nc = 3\nd = 4 \n"
@ -817,7 +817,7 @@ mod tests {
// Ensure the new suggestion is displayed when the debounce timeout expires.
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
_ = editor.update(cx, |editor, _, cx| {
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(
editor.display_text(cx),
"\n\na = 1\nb = 2\n\n\n\nc = 3\nd = 4 + c\n"
@ -880,7 +880,7 @@ mod tests {
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
cx.update_editor(|editor, _, cx| {
assert!(!editor.context_menu_visible());
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one\ntwo.foo()\nthree\n");
assert_eq!(editor.text(cx), "one\ntw\nthree\n");
});
@ -907,7 +907,7 @@ mod tests {
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
cx.update_editor(|editor, _, cx| {
assert!(!editor.context_menu_visible());
assert!(editor.has_active_inline_completion());
assert!(editor.has_active_edit_prediction());
assert_eq!(editor.display_text(cx), "one\ntwo.foo()\nthree\n");
assert_eq!(editor.text(cx), "one\ntwo\nthree\n");
});
@ -934,7 +934,7 @@ mod tests {
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
cx.update_editor(|editor, _, cx| {
assert!(editor.context_menu_visible());
assert!(!editor.has_active_inline_completion(),);
assert!(!editor.has_active_edit_prediction(),);
assert_eq!(editor.text(cx), "one\ntwo.\nthree\n");
});
}
@ -1023,7 +1023,7 @@ mod tests {
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |selections| {
selections.select_ranges([Point::new(0, 0)..Point::new(0, 0)])
});
editor.refresh_inline_completion(true, false, window, cx);
editor.refresh_edit_prediction(true, false, window, cx);
});
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
@ -1033,7 +1033,7 @@ mod tests {
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
s.select_ranges([Point::new(5, 0)..Point::new(5, 0)])
});
editor.refresh_inline_completion(true, false, window, cx);
editor.refresh_edit_prediction(true, false, window, cx);
});
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);

View file

@ -873,7 +873,7 @@ async fn test_random_diagnostics_with_inlays(cx: &mut TestAppContext, mut rng: S
editor.splice_inlays(
&[],
vec![Inlay::inline_completion(
vec![Inlay::edit_prediction(
post_inc(&mut next_inlay_id),
snapshot.buffer_snapshot.anchor_before(position),
format!("Test inlay {next_inlay_id}"),

View file

@ -1,5 +1,5 @@
[package]
name = "inline_completion"
name = "edit_prediction"
version = "0.1.0"
edition.workspace = true
publish.workspace = true
@ -9,7 +9,7 @@ license = "GPL-3.0-or-later"
workspace = true
[lib]
path = "src/inline_completion.rs"
path = "src/edit_prediction.rs"
[dependencies]
client.workspace = true

View file

@ -7,7 +7,7 @@ use project::Project;
// TODO: Find a better home for `Direction`.
//
// This should live in an ancestor crate of `editor` and `inline_completion`,
// This should live in an ancestor crate of `editor` and `edit_prediction`,
// but at time of writing there isn't an obvious spot.
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum Direction {
@ -16,7 +16,7 @@ pub enum Direction {
}
#[derive(Clone)]
pub struct InlineCompletion {
pub struct EditPrediction {
/// The ID of the completion, if it has one.
pub id: Option<SharedString>,
pub edits: Vec<(Range<language::Anchor>, String)>,
@ -102,10 +102,10 @@ pub trait EditPredictionProvider: 'static + Sized {
buffer: &Entity<Buffer>,
cursor_position: language::Anchor,
cx: &mut Context<Self>,
) -> Option<InlineCompletion>;
) -> Option<EditPrediction>;
}
pub trait InlineCompletionProviderHandle {
pub trait EditPredictionProviderHandle {
fn name(&self) -> &'static str;
fn display_name(&self) -> &'static str;
fn is_enabled(
@ -143,10 +143,10 @@ pub trait InlineCompletionProviderHandle {
buffer: &Entity<Buffer>,
cursor_position: language::Anchor,
cx: &mut App,
) -> Option<InlineCompletion>;
) -> Option<EditPrediction>;
}
impl<T> InlineCompletionProviderHandle for Entity<T>
impl<T> EditPredictionProviderHandle for Entity<T>
where
T: EditPredictionProvider,
{
@ -233,7 +233,7 @@ where
buffer: &Entity<Buffer>,
cursor_position: language::Anchor,
cx: &mut App,
) -> Option<InlineCompletion> {
) -> Option<EditPrediction> {
self.update(cx, |this, cx| this.suggest(buffer, cursor_position, cx))
}
}

View file

@ -1,5 +1,5 @@
[package]
name = "inline_completion_button"
name = "edit_prediction_button"
version = "0.1.0"
edition.workspace = true
publish.workspace = true
@ -9,7 +9,7 @@ license = "GPL-3.0-or-later"
workspace = true
[lib]
path = "src/inline_completion_button.rs"
path = "src/edit_prediction_button.rs"
doctest = false
[dependencies]
@ -22,7 +22,7 @@ feature_flags.workspace = true
fs.workspace = true
gpui.workspace = true
indoc.workspace = true
inline_completion.workspace = true
edit_prediction.workspace = true
language.workspace = true
paths.workspace = true
project.workspace = true

View file

@ -41,7 +41,7 @@ use zeta::RateCompletions;
actions!(
edit_prediction,
[
/// Toggles the inline completion menu.
/// Toggles the edit prediction menu.
ToggleMenu
]
);
@ -51,14 +51,14 @@ const PRIVACY_DOCS: &str = "https://zed.dev/docs/ai/privacy-and-security";
struct CopilotErrorToast;
pub struct InlineCompletionButton {
pub struct EditPredictionButton {
editor_subscription: Option<(Subscription, usize)>,
editor_enabled: Option<bool>,
editor_show_predictions: bool,
editor_focus_handle: Option<FocusHandle>,
language: Option<Arc<Language>>,
file: Option<Arc<dyn File>>,
edit_prediction_provider: Option<Arc<dyn inline_completion::InlineCompletionProviderHandle>>,
edit_prediction_provider: Option<Arc<dyn edit_prediction::EditPredictionProviderHandle>>,
fs: Arc<dyn Fs>,
user_store: Entity<UserStore>,
popover_menu_handle: PopoverMenuHandle<ContextMenu>,
@ -71,7 +71,7 @@ enum SupermavenButtonStatus {
Initializing,
}
impl Render for InlineCompletionButton {
impl Render for EditPredictionButton {
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
// Return empty div if AI is disabled
if DisableAiSettings::get_global(cx).disable_ai {
@ -369,7 +369,7 @@ impl Render for InlineCompletionButton {
}
}
impl InlineCompletionButton {
impl EditPredictionButton {
pub fn new(
fs: Arc<dyn Fs>,
user_store: Entity<UserStore>,
@ -470,7 +470,7 @@ impl InlineCompletionButton {
IconPosition::Start,
None,
move |_, cx| {
toggle_show_inline_completions_for_language(language.clone(), fs.clone(), cx)
toggle_show_edit_predictions_for_language(language.clone(), fs.clone(), cx)
},
);
}
@ -480,7 +480,7 @@ impl InlineCompletionButton {
let globally_enabled = settings.show_edit_predictions(None, cx);
menu = menu.toggleable_entry("All Files", globally_enabled, IconPosition::Start, None, {
let fs = fs.clone();
move |_, cx| toggle_inline_completions_globally(fs.clone(), cx)
move |_, cx| toggle_edit_predictions_globally(fs.clone(), cx)
});
let provider = settings.edit_predictions.provider;
@ -835,7 +835,7 @@ impl InlineCompletionButton {
}
}
impl StatusItemView for InlineCompletionButton {
impl StatusItemView for EditPredictionButton {
fn set_active_pane_item(
&mut self,
item: Option<&dyn ItemHandle>,
@ -905,7 +905,7 @@ async fn open_disabled_globs_setting_in_editor(
let settings = cx.global::<SettingsStore>();
// Ensure that we always have "inline_completions { "disabled_globs": [] }"
// Ensure that we always have "edit_predictions { "disabled_globs": [] }"
let edits = settings.edits_for_update::<AllLanguageSettings>(&text, |file| {
file.edit_predictions
.get_or_insert_with(Default::default)
@ -943,7 +943,7 @@ async fn open_disabled_globs_setting_in_editor(
anyhow::Ok(())
}
fn toggle_inline_completions_globally(fs: Arc<dyn Fs>, cx: &mut App) {
fn toggle_edit_predictions_globally(fs: Arc<dyn Fs>, cx: &mut App) {
let show_edit_predictions = all_language_settings(None, cx).show_edit_predictions(None, cx);
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
file.defaults.show_edit_predictions = Some(!show_edit_predictions)
@ -958,7 +958,7 @@ fn set_completion_provider(fs: Arc<dyn Fs>, cx: &mut App, provider: EditPredicti
});
}
fn toggle_show_inline_completions_for_language(
fn toggle_show_edit_predictions_for_language(
language: Arc<Language>,
fs: Arc<dyn Fs>,
cx: &mut App,

View file

@ -48,7 +48,7 @@ fs.workspace = true
git.workspace = true
gpui.workspace = true
indoc.workspace = true
inline_completion.workspace = true
edit_prediction.workspace = true
itertools.workspace = true
language.workspace = true
linkify.workspace = true

View file

@ -635,7 +635,7 @@ pub(crate) struct Highlights<'a> {
}
#[derive(Clone, Copy, Debug)]
pub struct InlineCompletionStyles {
pub struct EditPredictionStyles {
pub insertion: HighlightStyle,
pub whitespace: HighlightStyle,
}
@ -643,7 +643,7 @@ pub struct InlineCompletionStyles {
#[derive(Default, Debug, Clone, Copy)]
pub struct HighlightStyles {
pub inlay_hint: Option<HighlightStyle>,
pub inline_completion: Option<InlineCompletionStyles>,
pub edit_prediction: Option<EditPredictionStyles>,
}
#[derive(Clone)]
@ -958,7 +958,7 @@ impl DisplaySnapshot {
language_aware,
HighlightStyles {
inlay_hint: Some(editor_style.inlay_hints_style),
inline_completion: Some(editor_style.inline_completion_styles),
edit_prediction: Some(editor_style.edit_prediction_styles),
},
)
.flat_map(|chunk| {
@ -2036,7 +2036,7 @@ pub mod tests {
map.update(cx, |map, cx| {
map.splice_inlays(
&[],
vec![Inlay::inline_completion(
vec![Inlay::edit_prediction(
0,
buffer_snapshot.anchor_after(0),
"\n",

View file

@ -81,9 +81,9 @@ impl Inlay {
}
}
pub fn inline_completion<T: Into<Rope>>(id: usize, position: Anchor, text: T) -> Self {
pub fn edit_prediction<T: Into<Rope>>(id: usize, position: Anchor, text: T) -> Self {
Self {
id: InlayId::InlineCompletion(id),
id: InlayId::EditPrediction(id),
position,
text: text.into(),
color: None,
@ -340,15 +340,13 @@ impl<'a> Iterator for InlayChunks<'a> {
let mut renderer = None;
let mut highlight_style = match inlay.id {
InlayId::InlineCompletion(_) => {
self.highlight_styles.inline_completion.map(|s| {
if inlay.text.chars().all(|c| c.is_whitespace()) {
s.whitespace
} else {
s.insertion
}
})
}
InlayId::EditPrediction(_) => self.highlight_styles.edit_prediction.map(|s| {
if inlay.text.chars().all(|c| c.is_whitespace()) {
s.whitespace
} else {
s.insertion
}
}),
InlayId::Hint(_) => self.highlight_styles.inlay_hint,
InlayId::DebuggerValue(_) => self.highlight_styles.inlay_hint,
InlayId::Color(_) => {
@ -740,7 +738,7 @@ impl InlayMap {
text.clone(),
)
} else {
Inlay::inline_completion(
Inlay::edit_prediction(
post_inc(next_inlay_id),
snapshot.buffer.anchor_at(position, bias),
text.clone(),
@ -1389,7 +1387,7 @@ mod tests {
buffer.read(cx).snapshot(cx).anchor_before(3),
"|123|",
),
Inlay::inline_completion(
Inlay::edit_prediction(
post_inc(&mut next_inlay_id),
buffer.read(cx).snapshot(cx).anchor_after(3),
"|456|",
@ -1609,7 +1607,7 @@ mod tests {
buffer.read(cx).snapshot(cx).anchor_before(4),
"|456|",
),
Inlay::inline_completion(
Inlay::edit_prediction(
post_inc(&mut next_inlay_id),
buffer.read(cx).snapshot(cx).anchor_before(7),
"\n|567|\n",

View file

@ -1,26 +1,26 @@
use edit_prediction::EditPredictionProvider;
use gpui::{Entity, prelude::*};
use indoc::indoc;
use inline_completion::EditPredictionProvider;
use multi_buffer::{Anchor, MultiBufferSnapshot, ToPoint};
use project::Project;
use std::ops::Range;
use text::{Point, ToOffset};
use crate::{
InlineCompletion, editor_tests::init_test, test::editor_test_context::EditorTestContext,
EditPrediction, editor_tests::init_test, test::editor_test_context::EditorTestContext,
};
#[gpui::test]
async fn test_inline_completion_insert(cx: &mut gpui::TestAppContext) {
async fn test_edit_prediction_insert(cx: &mut gpui::TestAppContext) {
init_test(cx, |_| {});
let mut cx = EditorTestContext::new(cx).await;
let provider = cx.new(|_| FakeInlineCompletionProvider::default());
let provider = cx.new(|_| FakeEditPredictionProvider::default());
assign_editor_completion_provider(provider.clone(), &mut cx);
cx.set_state("let absolute_zero_celsius = ˇ;");
propose_edits(&provider, vec![(28..28, "-273.15")], &mut cx);
cx.update_editor(|editor, window, cx| editor.update_visible_inline_completion(window, cx));
cx.update_editor(|editor, window, cx| editor.update_visible_edit_prediction(window, cx));
assert_editor_active_edit_completion(&mut cx, |_, edits| {
assert_eq!(edits.len(), 1);
@ -33,16 +33,16 @@ async fn test_inline_completion_insert(cx: &mut gpui::TestAppContext) {
}
#[gpui::test]
async fn test_inline_completion_modification(cx: &mut gpui::TestAppContext) {
async fn test_edit_prediction_modification(cx: &mut gpui::TestAppContext) {
init_test(cx, |_| {});
let mut cx = EditorTestContext::new(cx).await;
let provider = cx.new(|_| FakeInlineCompletionProvider::default());
let provider = cx.new(|_| FakeEditPredictionProvider::default());
assign_editor_completion_provider(provider.clone(), &mut cx);
cx.set_state("let pi = ˇ\"foo\";");
propose_edits(&provider, vec![(9..14, "3.14159")], &mut cx);
cx.update_editor(|editor, window, cx| editor.update_visible_inline_completion(window, cx));
cx.update_editor(|editor, window, cx| editor.update_visible_edit_prediction(window, cx));
assert_editor_active_edit_completion(&mut cx, |_, edits| {
assert_eq!(edits.len(), 1);
@ -55,11 +55,11 @@ async fn test_inline_completion_modification(cx: &mut gpui::TestAppContext) {
}
#[gpui::test]
async fn test_inline_completion_jump_button(cx: &mut gpui::TestAppContext) {
async fn test_edit_prediction_jump_button(cx: &mut gpui::TestAppContext) {
init_test(cx, |_| {});
let mut cx = EditorTestContext::new(cx).await;
let provider = cx.new(|_| FakeInlineCompletionProvider::default());
let provider = cx.new(|_| FakeEditPredictionProvider::default());
assign_editor_completion_provider(provider.clone(), &mut cx);
// Cursor is 2+ lines above the proposed edit
@ -77,7 +77,7 @@ async fn test_inline_completion_jump_button(cx: &mut gpui::TestAppContext) {
&mut cx,
);
cx.update_editor(|editor, window, cx| editor.update_visible_inline_completion(window, cx));
cx.update_editor(|editor, window, cx| editor.update_visible_edit_prediction(window, cx));
assert_editor_active_move_completion(&mut cx, |snapshot, move_target| {
assert_eq!(move_target.to_point(&snapshot), Point::new(4, 3));
});
@ -107,7 +107,7 @@ async fn test_inline_completion_jump_button(cx: &mut gpui::TestAppContext) {
&mut cx,
);
cx.update_editor(|editor, window, cx| editor.update_visible_inline_completion(window, cx));
cx.update_editor(|editor, window, cx| editor.update_visible_edit_prediction(window, cx));
assert_editor_active_move_completion(&mut cx, |snapshot, move_target| {
assert_eq!(move_target.to_point(&snapshot), Point::new(1, 3));
});
@ -124,11 +124,11 @@ async fn test_inline_completion_jump_button(cx: &mut gpui::TestAppContext) {
}
#[gpui::test]
async fn test_inline_completion_invalidation_range(cx: &mut gpui::TestAppContext) {
async fn test_edit_prediction_invalidation_range(cx: &mut gpui::TestAppContext) {
init_test(cx, |_| {});
let mut cx = EditorTestContext::new(cx).await;
let provider = cx.new(|_| FakeInlineCompletionProvider::default());
let provider = cx.new(|_| FakeEditPredictionProvider::default());
assign_editor_completion_provider(provider.clone(), &mut cx);
// Cursor is 3+ lines above the proposed edit
@ -148,7 +148,7 @@ async fn test_inline_completion_invalidation_range(cx: &mut gpui::TestAppContext
&mut cx,
);
cx.update_editor(|editor, window, cx| editor.update_visible_inline_completion(window, cx));
cx.update_editor(|editor, window, cx| editor.update_visible_edit_prediction(window, cx));
assert_editor_active_move_completion(&mut cx, |snapshot, move_target| {
assert_eq!(move_target.to_point(&snapshot), edit_location);
});
@ -176,7 +176,7 @@ async fn test_inline_completion_invalidation_range(cx: &mut gpui::TestAppContext
line
"});
cx.editor(|editor, _, _| {
assert!(editor.active_inline_completion.is_none());
assert!(editor.active_edit_prediction.is_none());
});
// Cursor is 3+ lines below the proposed edit
@ -196,7 +196,7 @@ async fn test_inline_completion_invalidation_range(cx: &mut gpui::TestAppContext
&mut cx,
);
cx.update_editor(|editor, window, cx| editor.update_visible_inline_completion(window, cx));
cx.update_editor(|editor, window, cx| editor.update_visible_edit_prediction(window, cx));
assert_editor_active_move_completion(&mut cx, |snapshot, move_target| {
assert_eq!(move_target.to_point(&snapshot), edit_location);
});
@ -224,7 +224,7 @@ async fn test_inline_completion_invalidation_range(cx: &mut gpui::TestAppContext
line ˇ5
"});
cx.editor(|editor, _, _| {
assert!(editor.active_inline_completion.is_none());
assert!(editor.active_edit_prediction.is_none());
});
}
@ -234,11 +234,11 @@ fn assert_editor_active_edit_completion(
) {
cx.editor(|editor, _, cx| {
let completion_state = editor
.active_inline_completion
.active_edit_prediction
.as_ref()
.expect("editor has no active completion");
if let InlineCompletion::Edit { edits, .. } = &completion_state.completion {
if let EditPrediction::Edit { edits, .. } = &completion_state.completion {
assert(editor.buffer().read(cx).snapshot(cx), edits);
} else {
panic!("expected edit completion");
@ -252,11 +252,11 @@ fn assert_editor_active_move_completion(
) {
cx.editor(|editor, _, cx| {
let completion_state = editor
.active_inline_completion
.active_edit_prediction
.as_ref()
.expect("editor has no active completion");
if let InlineCompletion::Move { target, .. } = &completion_state.completion {
if let EditPrediction::Move { target, .. } = &completion_state.completion {
assert(editor.buffer().read(cx).snapshot(cx), *target);
} else {
panic!("expected move completion");
@ -271,7 +271,7 @@ fn accept_completion(cx: &mut EditorTestContext) {
}
fn propose_edits<T: ToOffset>(
provider: &Entity<FakeInlineCompletionProvider>,
provider: &Entity<FakeEditPredictionProvider>,
edits: Vec<(Range<T>, &str)>,
cx: &mut EditorTestContext,
) {
@ -283,7 +283,7 @@ fn propose_edits<T: ToOffset>(
cx.update(|_, cx| {
provider.update(cx, |provider, _| {
provider.set_inline_completion(Some(inline_completion::InlineCompletion {
provider.set_edit_prediction(Some(edit_prediction::EditPrediction {
id: None,
edits: edits.collect(),
edit_preview: None,
@ -293,7 +293,7 @@ fn propose_edits<T: ToOffset>(
}
fn assign_editor_completion_provider(
provider: Entity<FakeInlineCompletionProvider>,
provider: Entity<FakeEditPredictionProvider>,
cx: &mut EditorTestContext,
) {
cx.update_editor(|editor, window, cx| {
@ -302,20 +302,17 @@ fn assign_editor_completion_provider(
}
#[derive(Default, Clone)]
pub struct FakeInlineCompletionProvider {
pub completion: Option<inline_completion::InlineCompletion>,
pub struct FakeEditPredictionProvider {
pub completion: Option<edit_prediction::EditPrediction>,
}
impl FakeInlineCompletionProvider {
pub fn set_inline_completion(
&mut self,
completion: Option<inline_completion::InlineCompletion>,
) {
impl FakeEditPredictionProvider {
pub fn set_edit_prediction(&mut self, completion: Option<edit_prediction::EditPrediction>) {
self.completion = completion;
}
}
impl EditPredictionProvider for FakeInlineCompletionProvider {
impl EditPredictionProvider for FakeEditPredictionProvider {
fn name() -> &'static str {
"fake-completion-provider"
}
@ -355,7 +352,7 @@ impl EditPredictionProvider for FakeInlineCompletionProvider {
&mut self,
_buffer: gpui::Entity<language::Buffer>,
_cursor_position: language::Anchor,
_direction: inline_completion::Direction,
_direction: edit_prediction::Direction,
_cx: &mut gpui::Context<Self>,
) {
}
@ -369,7 +366,7 @@ impl EditPredictionProvider for FakeInlineCompletionProvider {
_buffer: &gpui::Entity<language::Buffer>,
_cursor_position: language::Anchor,
_cx: &mut gpui::Context<Self>,
) -> Option<inline_completion::InlineCompletion> {
) -> Option<edit_prediction::EditPrediction> {
self.completion.clone()
}
}

View file

@ -43,15 +43,16 @@ pub mod tasks;
#[cfg(test)]
mod code_completion_tests;
#[cfg(test)]
mod editor_tests;
mod edit_prediction_tests;
#[cfg(test)]
mod inline_completion_tests;
mod editor_tests;
mod signature_help;
#[cfg(any(test, feature = "test-support"))]
pub mod test;
pub(crate) use actions::*;
pub use display_map::{ChunkRenderer, ChunkRendererContext, DisplayPoint, FoldPlaceholder};
pub use edit_prediction::Direction;
pub use editor_settings::{
CurrentLineHighlight, DocumentColorsRenderMode, EditorSettings, HideMouseMode,
ScrollBeyondLastLine, ScrollbarAxes, SearchSettings, ShowMinimap, ShowScrollbar,
@ -62,7 +63,6 @@ pub use element::{
};
pub use git::blame::BlameRenderer;
pub use hover_popover::hover_markdown_style;
pub use inline_completion::Direction;
pub use items::MAX_TAB_TITLE_LEN;
pub use lsp::CompletionContext;
pub use lsp_ext::lsp_tasks;
@ -93,6 +93,7 @@ use collections::{BTreeMap, HashMap, HashSet, VecDeque};
use convert_case::{Case, Casing};
use dap::TelemetrySpawnLocation;
use display_map::*;
use edit_prediction::{EditPredictionProvider, EditPredictionProviderHandle};
use editor_settings::{GoToDefinitionFallback, Minimap as MinimapSettings};
use element::{AcceptEditPredictionBinding, LineWithInvisibles, PositionMap, layout_line};
use futures::{
@ -117,7 +118,6 @@ use hover_links::{HoverLink, HoveredLinkState, InlayHighlight, find_file};
use hover_popover::{HoverState, hide_hover};
use indent_guides::ActiveIndentGuidesState;
use inlay_hint_cache::{InlayHintCache, InlaySplice, InvalidationStrategy};
use inline_completion::{EditPredictionProvider, InlineCompletionProviderHandle};
use itertools::Itertools;
use language::{
AutoindentMode, BlockCommentConfig, BracketMatch, BracketPair, Buffer, BufferRow,
@ -268,7 +268,7 @@ impl InlineValueCache {
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum InlayId {
InlineCompletion(usize),
EditPrediction(usize),
DebuggerValue(usize),
// LSP
Hint(usize),
@ -278,7 +278,7 @@ pub enum InlayId {
impl InlayId {
fn id(&self) -> usize {
match self {
Self::InlineCompletion(id) => *id,
Self::EditPrediction(id) => *id,
Self::DebuggerValue(id) => *id,
Self::Hint(id) => *id,
Self::Color(id) => *id,
@ -547,7 +547,7 @@ pub struct EditorStyle {
pub syntax: Arc<SyntaxTheme>,
pub status: StatusColors,
pub inlay_hints_style: HighlightStyle,
pub inline_completion_styles: InlineCompletionStyles,
pub edit_prediction_styles: EditPredictionStyles,
pub unnecessary_code_fade: f32,
pub show_underlines: bool,
}
@ -566,7 +566,7 @@ impl Default for EditorStyle {
// style and retrieve them directly from the theme.
status: StatusColors::dark(),
inlay_hints_style: HighlightStyle::default(),
inline_completion_styles: InlineCompletionStyles {
edit_prediction_styles: EditPredictionStyles {
insertion: HighlightStyle::default(),
whitespace: HighlightStyle::default(),
},
@ -588,8 +588,8 @@ pub fn make_inlay_hints_style(cx: &mut App) -> HighlightStyle {
}
}
pub fn make_suggestion_styles(cx: &mut App) -> InlineCompletionStyles {
InlineCompletionStyles {
pub fn make_suggestion_styles(cx: &mut App) -> EditPredictionStyles {
EditPredictionStyles {
insertion: HighlightStyle {
color: Some(cx.theme().status().predictive),
..HighlightStyle::default()
@ -609,7 +609,7 @@ pub(crate) enum EditDisplayMode {
Inline,
}
enum InlineCompletion {
enum EditPrediction {
Edit {
edits: Vec<(Range<Anchor>, String)>,
edit_preview: Option<EditPreview>,
@ -622,9 +622,9 @@ enum InlineCompletion {
},
}
struct InlineCompletionState {
struct EditPredictionState {
inlay_ids: Vec<InlayId>,
completion: InlineCompletion,
completion: EditPrediction,
completion_id: Option<SharedString>,
invalidation_range: Range<Anchor>,
}
@ -637,7 +637,7 @@ enum EditPredictionSettings {
},
}
enum InlineCompletionHighlight {}
enum EditPredictionHighlight {}
#[derive(Debug, Clone)]
struct InlineDiagnostic {
@ -648,7 +648,7 @@ struct InlineDiagnostic {
severity: lsp::DiagnosticSeverity,
}
pub enum MenuInlineCompletionsPolicy {
pub enum MenuEditPredictionsPolicy {
Never,
ByProvider,
}
@ -1087,15 +1087,15 @@ pub struct Editor {
pending_mouse_down: Option<Rc<RefCell<Option<MouseDownEvent>>>>,
gutter_hovered: bool,
hovered_link_state: Option<HoveredLinkState>,
edit_prediction_provider: Option<RegisteredInlineCompletionProvider>,
edit_prediction_provider: Option<RegisteredEditPredictionProvider>,
code_action_providers: Vec<Rc<dyn CodeActionProvider>>,
active_inline_completion: Option<InlineCompletionState>,
active_edit_prediction: Option<EditPredictionState>,
/// Used to prevent flickering as the user types while the menu is open
stale_inline_completion_in_menu: Option<InlineCompletionState>,
stale_edit_prediction_in_menu: Option<EditPredictionState>,
edit_prediction_settings: EditPredictionSettings,
inline_completions_hidden_for_vim_mode: bool,
show_inline_completions_override: Option<bool>,
menu_inline_completions_policy: MenuInlineCompletionsPolicy,
edit_predictions_hidden_for_vim_mode: bool,
show_edit_predictions_override: Option<bool>,
menu_edit_predictions_policy: MenuEditPredictionsPolicy,
edit_prediction_preview: EditPredictionPreview,
edit_prediction_indent_conflict: bool,
edit_prediction_requires_modifier_in_indent_conflict: bool,
@ -1510,8 +1510,8 @@ pub struct RenameState {
struct InvalidationStack<T>(Vec<T>);
struct RegisteredInlineCompletionProvider {
provider: Arc<dyn InlineCompletionProviderHandle>,
struct RegisteredEditPredictionProvider {
provider: Arc<dyn EditPredictionProviderHandle>,
_subscription: Subscription,
}
@ -2096,8 +2096,8 @@ impl Editor {
pending_mouse_down: None,
hovered_link_state: None,
edit_prediction_provider: None,
active_inline_completion: None,
stale_inline_completion_in_menu: None,
active_edit_prediction: None,
stale_edit_prediction_in_menu: None,
edit_prediction_preview: EditPredictionPreview::Inactive {
released_too_fast: false,
},
@ -2116,9 +2116,9 @@ impl Editor {
hovered_cursors: HashMap::default(),
next_editor_action_id: EditorActionId::default(),
editor_actions: Rc::default(),
inline_completions_hidden_for_vim_mode: false,
show_inline_completions_override: None,
menu_inline_completions_policy: MenuInlineCompletionsPolicy::ByProvider,
edit_predictions_hidden_for_vim_mode: false,
show_edit_predictions_override: None,
menu_edit_predictions_policy: MenuEditPredictionsPolicy::ByProvider,
edit_prediction_settings: EditPredictionSettings::Disabled,
edit_prediction_indent_conflict: false,
edit_prediction_requires_modifier_in_indent_conflict: true,
@ -2350,7 +2350,7 @@ impl Editor {
}
pub fn key_context(&self, window: &Window, cx: &App) -> KeyContext {
self.key_context_internal(self.has_active_inline_completion(), window, cx)
self.key_context_internal(self.has_active_edit_prediction(), window, cx)
}
fn key_context_internal(
@ -2717,17 +2717,16 @@ impl Editor {
) where
T: EditPredictionProvider,
{
self.edit_prediction_provider =
provider.map(|provider| RegisteredInlineCompletionProvider {
_subscription: cx.observe_in(&provider, window, |this, _, window, cx| {
if this.focus_handle.is_focused(window) {
this.update_visible_inline_completion(window, cx);
}
}),
provider: Arc::new(provider),
});
self.edit_prediction_provider = provider.map(|provider| RegisteredEditPredictionProvider {
_subscription: cx.observe_in(&provider, window, |this, _, window, cx| {
if this.focus_handle.is_focused(window) {
this.update_visible_edit_prediction(window, cx);
}
}),
provider: Arc::new(provider),
});
self.update_edit_prediction_settings(cx);
self.refresh_inline_completion(false, false, window, cx);
self.refresh_edit_prediction(false, false, window, cx);
}
pub fn placeholder_text(&self) -> Option<&str> {
@ -2798,24 +2797,24 @@ impl Editor {
self.input_enabled = input_enabled;
}
pub fn set_inline_completions_hidden_for_vim_mode(
pub fn set_edit_predictions_hidden_for_vim_mode(
&mut self,
hidden: bool,
window: &mut Window,
cx: &mut Context<Self>,
) {
if hidden != self.inline_completions_hidden_for_vim_mode {
self.inline_completions_hidden_for_vim_mode = hidden;
if hidden != self.edit_predictions_hidden_for_vim_mode {
self.edit_predictions_hidden_for_vim_mode = hidden;
if hidden {
self.update_visible_inline_completion(window, cx);
self.update_visible_edit_prediction(window, cx);
} else {
self.refresh_inline_completion(true, false, window, cx);
self.refresh_edit_prediction(true, false, window, cx);
}
}
}
pub fn set_menu_inline_completions_policy(&mut self, value: MenuInlineCompletionsPolicy) {
self.menu_inline_completions_policy = value;
pub fn set_menu_edit_predictions_policy(&mut self, value: MenuEditPredictionsPolicy) {
self.menu_edit_predictions_policy = value;
}
pub fn set_autoindent(&mut self, autoindent: bool) {
@ -2852,7 +2851,7 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
if self.show_inline_completions_override.is_some() {
if self.show_edit_predictions_override.is_some() {
self.set_show_edit_predictions(None, window, cx);
} else {
let show_edit_predictions = !self.edit_predictions_enabled();
@ -2866,17 +2865,17 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
self.show_inline_completions_override = show_edit_predictions;
self.show_edit_predictions_override = show_edit_predictions;
self.update_edit_prediction_settings(cx);
if let Some(false) = show_edit_predictions {
self.discard_inline_completion(false, cx);
self.discard_edit_prediction(false, cx);
} else {
self.refresh_inline_completion(false, true, window, cx);
self.refresh_edit_prediction(false, true, window, cx);
}
}
fn inline_completions_disabled_in_scope(
fn edit_predictions_disabled_in_scope(
&self,
buffer: &Entity<Buffer>,
buffer_position: language::Anchor,
@ -3043,7 +3042,7 @@ impl Editor {
self.refresh_document_highlights(cx);
self.refresh_selected_text_highlights(false, window, cx);
refresh_matching_bracket_highlights(self, window, cx);
self.update_visible_inline_completion(window, cx);
self.update_visible_edit_prediction(window, cx);
self.edit_prediction_requires_modifier_in_indent_conflict = true;
linked_editing_ranges::refresh_linked_ranges(self, window, cx);
self.inline_blame_popover.take();
@ -3833,7 +3832,7 @@ impl Editor {
return true;
}
if is_user_requested && self.discard_inline_completion(true, cx) {
if is_user_requested && self.discard_edit_prediction(true, cx) {
return true;
}
@ -4239,7 +4238,7 @@ impl Editor {
);
}
let had_active_inline_completion = this.has_active_inline_completion();
let had_active_edit_prediction = this.has_active_edit_prediction();
this.change_selections(
SelectionEffects::scroll(Autoscroll::fit()).completions(false),
window,
@ -4264,7 +4263,7 @@ impl Editor {
}
let trigger_in_words =
this.show_edit_predictions_in_menu() || !had_active_inline_completion;
this.show_edit_predictions_in_menu() || !had_active_edit_prediction;
if this.hard_wrap.is_some() {
let latest: Range<Point> = this.selections.newest(cx).range();
if latest.is_empty()
@ -4286,7 +4285,7 @@ impl Editor {
}
this.trigger_completion_on_input(&text, trigger_in_words, window, cx);
linked_editing_ranges::refresh_linked_ranges(this, window, cx);
this.refresh_inline_completion(true, false, window, cx);
this.refresh_edit_prediction(true, false, window, cx);
jsx_tag_auto_close::handle_from(this, initial_buffer_versions, window, cx);
});
}
@ -4621,7 +4620,7 @@ impl Editor {
.collect();
this.change_selections(Default::default(), window, cx, |s| s.select(new_selections));
this.refresh_inline_completion(true, false, window, cx);
this.refresh_edit_prediction(true, false, window, cx);
});
}
@ -5669,9 +5668,9 @@ impl Editor {
crate::hover_popover::hide_hover(editor, cx);
if editor.show_edit_predictions_in_menu() {
editor.update_visible_inline_completion(window, cx);
editor.update_visible_edit_prediction(window, cx);
} else {
editor.discard_inline_completion(false, cx);
editor.discard_edit_prediction(false, cx);
}
cx.notify();
@ -5682,10 +5681,10 @@ impl Editor {
if editor.completion_tasks.len() <= 1 {
// If there are no more completion tasks and the last menu was empty, we should hide it.
let was_hidden = editor.hide_context_menu(window, cx).is_none();
// If it was already hidden and we don't show inline completions in the menu, we should
// also show the inline-completion when available.
// If it was already hidden and we don't show edit predictions in the menu,
// we should also show the edit prediction when available.
if was_hidden && editor.show_edit_predictions_in_menu() {
editor.update_visible_inline_completion(window, cx);
editor.update_visible_edit_prediction(window, cx);
}
}
})
@ -5779,7 +5778,7 @@ impl Editor {
let entries = completions_menu.entries.borrow();
let mat = entries.get(item_ix.unwrap_or(completions_menu.selected_item))?;
if self.show_edit_predictions_in_menu() {
self.discard_inline_completion(true, cx);
self.discard_edit_prediction(true, cx);
}
mat.candidate_id
};
@ -5923,7 +5922,7 @@ impl Editor {
})
}
editor.refresh_inline_completion(true, false, window, cx);
editor.refresh_edit_prediction(true, false, window, cx);
});
self.invalidate_autoclose_regions(&self.selections.disjoint_anchors(), &snapshot);
@ -5983,7 +5982,7 @@ impl Editor {
let deployed_from = action.deployed_from.clone();
let action = action.clone();
self.completion_tasks.clear();
self.discard_inline_completion(false, cx);
self.discard_edit_prediction(false, cx);
let multibuffer_point = match &action.deployed_from {
Some(CodeActionSource::Indicator(row)) | Some(CodeActionSource::RunMenu(row)) => {
@ -6988,7 +6987,7 @@ impl Editor {
}
}
pub fn refresh_inline_completion(
pub fn refresh_edit_prediction(
&mut self,
debounce: bool,
user_requested: bool,
@ -7005,7 +7004,7 @@ impl Editor {
self.buffer.read(cx).text_anchor_for_position(cursor, cx)?;
if !self.edit_predictions_enabled_in_buffer(&buffer, cursor_buffer_position, cx) {
self.discard_inline_completion(false, cx);
self.discard_edit_prediction(false, cx);
return None;
}
@ -7014,11 +7013,11 @@ impl Editor {
|| !self.is_focused(window)
|| buffer.read(cx).is_empty())
{
self.discard_inline_completion(false, cx);
self.discard_edit_prediction(false, cx);
return None;
}
self.update_visible_inline_completion(window, cx);
self.update_visible_edit_prediction(window, cx);
provider.refresh(
self.project.clone(),
buffer,
@ -7056,7 +7055,7 @@ impl Editor {
pub fn update_edit_prediction_settings(&mut self, cx: &mut Context<Self>) {
if self.edit_prediction_provider.is_none() || DisableAiSettings::get_global(cx).disable_ai {
self.edit_prediction_settings = EditPredictionSettings::Disabled;
self.discard_inline_completion(false, cx);
self.discard_edit_prediction(false, cx);
} else {
let selection = self.selections.newest_anchor();
let cursor = selection.head();
@ -7077,8 +7076,8 @@ impl Editor {
cx: &App,
) -> EditPredictionSettings {
if !self.mode.is_full()
|| !self.show_inline_completions_override.unwrap_or(true)
|| self.inline_completions_disabled_in_scope(buffer, buffer_position, cx)
|| !self.show_edit_predictions_override.unwrap_or(true)
|| self.edit_predictions_disabled_in_scope(buffer, buffer_position, cx)
{
return EditPredictionSettings::Disabled;
}
@ -7092,8 +7091,8 @@ impl Editor {
};
let by_provider = matches!(
self.menu_inline_completions_policy,
MenuInlineCompletionsPolicy::ByProvider
self.menu_edit_predictions_policy,
MenuEditPredictionsPolicy::ByProvider
);
let show_in_menu = by_provider
@ -7163,7 +7162,7 @@ impl Editor {
.unwrap_or(false)
}
fn cycle_inline_completion(
fn cycle_edit_prediction(
&mut self,
direction: Direction,
window: &mut Window,
@ -7173,28 +7172,28 @@ impl Editor {
let cursor = self.selections.newest_anchor().head();
let (buffer, cursor_buffer_position) =
self.buffer.read(cx).text_anchor_for_position(cursor, cx)?;
if self.inline_completions_hidden_for_vim_mode || !self.should_show_edit_predictions() {
if self.edit_predictions_hidden_for_vim_mode || !self.should_show_edit_predictions() {
return None;
}
provider.cycle(buffer, cursor_buffer_position, direction, cx);
self.update_visible_inline_completion(window, cx);
self.update_visible_edit_prediction(window, cx);
Some(())
}
pub fn show_inline_completion(
pub fn show_edit_prediction(
&mut self,
_: &ShowEditPrediction,
window: &mut Window,
cx: &mut Context<Self>,
) {
if !self.has_active_inline_completion() {
self.refresh_inline_completion(false, true, window, cx);
if !self.has_active_edit_prediction() {
self.refresh_edit_prediction(false, true, window, cx);
return;
}
self.update_visible_inline_completion(window, cx);
self.update_visible_edit_prediction(window, cx);
}
pub fn display_cursor_names(
@ -7226,11 +7225,11 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
if self.has_active_inline_completion() {
self.cycle_inline_completion(Direction::Next, window, cx);
if self.has_active_edit_prediction() {
self.cycle_edit_prediction(Direction::Next, window, cx);
} else {
let is_copilot_disabled = self
.refresh_inline_completion(false, true, window, cx)
.refresh_edit_prediction(false, true, window, cx)
.is_none();
if is_copilot_disabled {
cx.propagate();
@ -7244,11 +7243,11 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
if self.has_active_inline_completion() {
self.cycle_inline_completion(Direction::Prev, window, cx);
if self.has_active_edit_prediction() {
self.cycle_edit_prediction(Direction::Prev, window, cx);
} else {
let is_copilot_disabled = self
.refresh_inline_completion(false, true, window, cx)
.refresh_edit_prediction(false, true, window, cx)
.is_none();
if is_copilot_disabled {
cx.propagate();
@ -7266,18 +7265,14 @@ impl Editor {
self.hide_context_menu(window, cx);
}
let Some(active_inline_completion) = self.active_inline_completion.as_ref() else {
let Some(active_edit_prediction) = self.active_edit_prediction.as_ref() else {
return;
};
self.report_inline_completion_event(
active_inline_completion.completion_id.clone(),
true,
cx,
);
self.report_edit_prediction_event(active_edit_prediction.completion_id.clone(), true, cx);
match &active_inline_completion.completion {
InlineCompletion::Move { target, .. } => {
match &active_edit_prediction.completion {
EditPrediction::Move { target, .. } => {
let target = *target;
if let Some(position_map) = &self.last_position_map {
@ -7319,7 +7314,7 @@ impl Editor {
}
}
}
InlineCompletion::Edit { edits, .. } => {
EditPrediction::Edit { edits, .. } => {
if let Some(provider) = self.edit_prediction_provider() {
provider.accept(cx);
}
@ -7347,9 +7342,9 @@ impl Editor {
}
}
self.update_visible_inline_completion(window, cx);
if self.active_inline_completion.is_none() {
self.refresh_inline_completion(true, true, window, cx);
self.update_visible_edit_prediction(window, cx);
if self.active_edit_prediction.is_none() {
self.refresh_edit_prediction(true, true, window, cx);
}
cx.notify();
@ -7359,27 +7354,23 @@ impl Editor {
self.edit_prediction_requires_modifier_in_indent_conflict = false;
}
pub fn accept_partial_inline_completion(
pub fn accept_partial_edit_prediction(
&mut self,
_: &AcceptPartialEditPrediction,
window: &mut Window,
cx: &mut Context<Self>,
) {
let Some(active_inline_completion) = self.active_inline_completion.as_ref() else {
let Some(active_edit_prediction) = self.active_edit_prediction.as_ref() else {
return;
};
if self.selections.count() != 1 {
return;
}
self.report_inline_completion_event(
active_inline_completion.completion_id.clone(),
true,
cx,
);
self.report_edit_prediction_event(active_edit_prediction.completion_id.clone(), true, cx);
match &active_inline_completion.completion {
InlineCompletion::Move { target, .. } => {
match &active_edit_prediction.completion {
EditPrediction::Move { target, .. } => {
let target = *target;
self.change_selections(
SelectionEffects::scroll(Autoscroll::newest()),
@ -7390,7 +7381,7 @@ impl Editor {
},
);
}
InlineCompletion::Edit { edits, .. } => {
EditPrediction::Edit { edits, .. } => {
// Find an insertion that starts at the cursor position.
let snapshot = self.buffer.read(cx).snapshot(cx);
let cursor_offset = self.selections.newest::<usize>(cx).head();
@ -7424,7 +7415,7 @@ impl Editor {
self.insert_with_autoindent_mode(&partial_completion, None, window, cx);
self.refresh_inline_completion(true, true, window, cx);
self.refresh_edit_prediction(true, true, window, cx);
cx.notify();
} else {
self.accept_edit_prediction(&Default::default(), window, cx);
@ -7433,28 +7424,28 @@ impl Editor {
}
}
fn discard_inline_completion(
fn discard_edit_prediction(
&mut self,
should_report_inline_completion_event: bool,
should_report_edit_prediction_event: bool,
cx: &mut Context<Self>,
) -> bool {
if should_report_inline_completion_event {
if should_report_edit_prediction_event {
let completion_id = self
.active_inline_completion
.active_edit_prediction
.as_ref()
.and_then(|active_completion| active_completion.completion_id.clone());
self.report_inline_completion_event(completion_id, false, cx);
self.report_edit_prediction_event(completion_id, false, cx);
}
if let Some(provider) = self.edit_prediction_provider() {
provider.discard(cx);
}
self.take_active_inline_completion(cx)
self.take_active_edit_prediction(cx)
}
fn report_inline_completion_event(&self, id: Option<SharedString>, accepted: bool, cx: &App) {
fn report_edit_prediction_event(&self, id: Option<SharedString>, accepted: bool, cx: &App) {
let Some(provider) = self.edit_prediction_provider() else {
return;
};
@ -7485,18 +7476,18 @@ impl Editor {
);
}
pub fn has_active_inline_completion(&self) -> bool {
self.active_inline_completion.is_some()
pub fn has_active_edit_prediction(&self) -> bool {
self.active_edit_prediction.is_some()
}
fn take_active_inline_completion(&mut self, cx: &mut Context<Self>) -> bool {
let Some(active_inline_completion) = self.active_inline_completion.take() else {
fn take_active_edit_prediction(&mut self, cx: &mut Context<Self>) -> bool {
let Some(active_edit_prediction) = self.active_edit_prediction.take() else {
return false;
};
self.splice_inlays(&active_inline_completion.inlay_ids, Default::default(), cx);
self.clear_highlights::<InlineCompletionHighlight>(cx);
self.stale_inline_completion_in_menu = Some(active_inline_completion);
self.splice_inlays(&active_edit_prediction.inlay_ids, Default::default(), cx);
self.clear_highlights::<EditPredictionHighlight>(cx);
self.stale_edit_prediction_in_menu = Some(active_edit_prediction);
true
}
@ -7641,7 +7632,7 @@ impl Editor {
since: Instant::now(),
};
self.update_visible_inline_completion(window, cx);
self.update_visible_edit_prediction(window, cx);
cx.notify();
}
} else if let EditPredictionPreview::Active {
@ -7664,12 +7655,12 @@ impl Editor {
released_too_fast: since.elapsed() < Duration::from_millis(200),
};
self.clear_row_highlights::<EditPredictionPreview>();
self.update_visible_inline_completion(window, cx);
self.update_visible_edit_prediction(window, cx);
cx.notify();
}
}
fn update_visible_inline_completion(
fn update_visible_edit_prediction(
&mut self,
_window: &mut Window,
cx: &mut Context<Self>,
@ -7687,12 +7678,12 @@ impl Editor {
let show_in_menu = self.show_edit_predictions_in_menu();
let completions_menu_has_precedence = !show_in_menu
&& (self.context_menu.borrow().is_some()
|| (!self.completion_tasks.is_empty() && !self.has_active_inline_completion()));
|| (!self.completion_tasks.is_empty() && !self.has_active_edit_prediction()));
if completions_menu_has_precedence
|| !offset_selection.is_empty()
|| self
.active_inline_completion
.active_edit_prediction
.as_ref()
.map_or(false, |completion| {
let invalidation_range = completion.invalidation_range.to_offset(&multibuffer);
@ -7700,11 +7691,11 @@ impl Editor {
!invalidation_range.contains(&offset_selection.head())
})
{
self.discard_inline_completion(false, cx);
self.discard_edit_prediction(false, cx);
return None;
}
self.take_active_inline_completion(cx);
self.take_active_edit_prediction(cx);
let Some(provider) = self.edit_prediction_provider() else {
self.edit_prediction_settings = EditPredictionSettings::Disabled;
return None;
@ -7730,8 +7721,8 @@ impl Editor {
}
}
let inline_completion = provider.suggest(&buffer, cursor_buffer_position, cx)?;
let edits = inline_completion
let edit_prediction = provider.suggest(&buffer, cursor_buffer_position, cx)?;
let edits = edit_prediction
.edits
.into_iter()
.flat_map(|(range, new_text)| {
@ -7766,15 +7757,15 @@ impl Editor {
None
};
let is_move =
move_invalidation_row_range.is_some() || self.inline_completions_hidden_for_vim_mode;
move_invalidation_row_range.is_some() || self.edit_predictions_hidden_for_vim_mode;
let completion = if is_move {
invalidation_row_range =
move_invalidation_row_range.unwrap_or(edit_start_row..edit_end_row);
let target = first_edit_start;
InlineCompletion::Move { target, snapshot }
EditPrediction::Move { target, snapshot }
} else {
let show_completions_in_buffer = !self.edit_prediction_visible_in_cursor_popover(true)
&& !self.inline_completions_hidden_for_vim_mode;
&& !self.edit_predictions_hidden_for_vim_mode;
if show_completions_in_buffer {
if edits
@ -7783,7 +7774,7 @@ impl Editor {
{
let mut inlays = Vec::new();
for (range, new_text) in &edits {
let inlay = Inlay::inline_completion(
let inlay = Inlay::edit_prediction(
post_inc(&mut self.next_inlay_id),
range.start,
new_text.as_str(),
@ -7795,7 +7786,7 @@ impl Editor {
self.splice_inlays(&[], inlays, cx);
} else {
let background_color = cx.theme().status().deleted_background;
self.highlight_text::<InlineCompletionHighlight>(
self.highlight_text::<EditPredictionHighlight>(
edits.iter().map(|(range, _)| range.clone()).collect(),
HighlightStyle {
background_color: Some(background_color),
@ -7818,9 +7809,9 @@ impl Editor {
EditDisplayMode::DiffPopover
};
InlineCompletion::Edit {
EditPrediction::Edit {
edits,
edit_preview: inline_completion.edit_preview,
edit_preview: edit_prediction.edit_preview,
display_mode,
snapshot,
}
@ -7833,11 +7824,11 @@ impl Editor {
multibuffer.line_len(MultiBufferRow(invalidation_row_range.end)),
));
self.stale_inline_completion_in_menu = None;
self.active_inline_completion = Some(InlineCompletionState {
self.stale_edit_prediction_in_menu = None;
self.active_edit_prediction = Some(EditPredictionState {
inlay_ids,
completion,
completion_id: inline_completion.id,
completion_id: edit_prediction.id,
invalidation_range,
});
@ -7846,7 +7837,7 @@ impl Editor {
Some(())
}
pub fn edit_prediction_provider(&self) -> Option<Arc<dyn InlineCompletionProviderHandle>> {
pub fn edit_prediction_provider(&self) -> Option<Arc<dyn EditPredictionProviderHandle>> {
Some(self.edit_prediction_provider.as_ref()?.provider.clone())
}
@ -8415,14 +8406,14 @@ impl Editor {
if self.mode().is_minimap() {
return None;
}
let active_inline_completion = self.active_inline_completion.as_ref()?;
let active_edit_prediction = self.active_edit_prediction.as_ref()?;
if self.edit_prediction_visible_in_cursor_popover(true) {
return None;
}
match &active_inline_completion.completion {
InlineCompletion::Move { target, .. } => {
match &active_edit_prediction.completion {
EditPrediction::Move { target, .. } => {
let target_display_point = target.to_display_point(editor_snapshot);
if self.edit_prediction_requires_modifier() {
@ -8459,11 +8450,11 @@ impl Editor {
)
}
}
InlineCompletion::Edit {
EditPrediction::Edit {
display_mode: EditDisplayMode::Inline,
..
} => None,
InlineCompletion::Edit {
EditPrediction::Edit {
display_mode: EditDisplayMode::TabAccept,
edits,
..
@ -8484,7 +8475,7 @@ impl Editor {
cx,
)
}
InlineCompletion::Edit {
EditPrediction::Edit {
edits,
edit_preview,
display_mode: EditDisplayMode::DiffPopover,
@ -8801,7 +8792,7 @@ impl Editor {
}
let highlighted_edits =
crate::inline_completion_edit_text(&snapshot, edits, edit_preview.as_ref()?, false, cx);
crate::edit_prediction_edit_text(&snapshot, edits, edit_preview.as_ref()?, false, cx);
let styled_text = highlighted_edits.to_styled_text(&style.text);
let line_count = highlighted_edits.text.lines().count();
@ -9131,7 +9122,7 @@ impl Editor {
.child(Icon::new(IconName::ZedPredict))
}
let completion = match &self.active_inline_completion {
let completion = match &self.active_edit_prediction {
Some(prediction) => {
if !self.has_visible_completions_menu() {
const RADIUS: Pixels = px(6.);
@ -9149,7 +9140,7 @@ impl Editor {
.rounded_tl(px(0.))
.overflow_hidden()
.child(div().px_1p5().child(match &prediction.completion {
InlineCompletion::Move { target, snapshot } => {
EditPrediction::Move { target, snapshot } => {
use text::ToPoint as _;
if target.text_anchor.to_point(&snapshot).row > cursor_point.row
{
@ -9158,7 +9149,7 @@ impl Editor {
Icon::new(IconName::ZedPredictUp)
}
}
InlineCompletion::Edit { .. } => Icon::new(IconName::ZedPredict),
EditPrediction::Edit { .. } => Icon::new(IconName::ZedPredict),
}))
.child(
h_flex()
@ -9217,7 +9208,7 @@ impl Editor {
)?
}
None if is_refreshing => match &self.stale_inline_completion_in_menu {
None if is_refreshing => match &self.stale_edit_prediction_in_menu {
Some(stale_completion) => self.render_edit_prediction_cursor_popover_preview(
stale_completion,
cursor_point,
@ -9247,7 +9238,7 @@ impl Editor {
completion.into_any_element()
};
let has_completion = self.active_inline_completion.is_some();
let has_completion = self.active_edit_prediction.is_some();
let is_platform_style_mac = PlatformStyle::platform() == PlatformStyle::Mac;
Some(
@ -9306,7 +9297,7 @@ impl Editor {
fn render_edit_prediction_cursor_popover_preview(
&self,
completion: &InlineCompletionState,
completion: &EditPredictionState,
cursor_point: Point,
style: &EditorStyle,
cx: &mut Context<Editor>,
@ -9334,7 +9325,7 @@ impl Editor {
}
match &completion.completion {
InlineCompletion::Move {
EditPrediction::Move {
target, snapshot, ..
} => Some(
h_flex()
@ -9351,7 +9342,7 @@ impl Editor {
.child(Label::new("Jump to Edit")),
),
InlineCompletion::Edit {
EditPrediction::Edit {
edits,
edit_preview,
snapshot,
@ -9359,7 +9350,7 @@ impl Editor {
} => {
let first_edit_row = edits.first()?.0.start.text_anchor.to_point(&snapshot).row;
let (highlighted_edits, has_more_lines) = crate::inline_completion_edit_text(
let (highlighted_edits, has_more_lines) = crate::edit_prediction_edit_text(
&snapshot,
&edits,
edit_preview.as_ref()?,
@ -9437,8 +9428,8 @@ impl Editor {
cx.notify();
self.completion_tasks.clear();
let context_menu = self.context_menu.borrow_mut().take();
self.stale_inline_completion_in_menu.take();
self.update_visible_inline_completion(window, cx);
self.stale_edit_prediction_in_menu.take();
self.update_visible_edit_prediction(window, cx);
if let Some(CodeContextMenu::Completions(_)) = &context_menu {
if let Some(completion_provider) = &self.completion_provider {
completion_provider.selection_changed(None, window, cx);
@ -9796,7 +9787,7 @@ impl Editor {
this.edit(edits, None, cx);
})
}
this.refresh_inline_completion(true, false, window, cx);
this.refresh_edit_prediction(true, false, window, cx);
linked_editing_ranges::refresh_linked_ranges(this, window, cx);
});
}
@ -9815,7 +9806,7 @@ impl Editor {
})
});
this.insert("", window, cx);
this.refresh_inline_completion(true, false, window, cx);
this.refresh_edit_prediction(true, false, window, cx);
});
}
@ -9948,7 +9939,7 @@ impl Editor {
self.transact(window, cx, |this, window, cx| {
this.buffer.update(cx, |b, cx| b.edit(edits, None, cx));
this.change_selections(Default::default(), window, cx, |s| s.select(selections));
this.refresh_inline_completion(true, false, window, cx);
this.refresh_edit_prediction(true, false, window, cx);
});
}
@ -12277,7 +12268,7 @@ impl Editor {
}
self.request_autoscroll(Autoscroll::fit(), cx);
self.unmark_text(window, cx);
self.refresh_inline_completion(true, false, window, cx);
self.refresh_edit_prediction(true, false, window, cx);
cx.emit(EditorEvent::Edited { transaction_id });
cx.emit(EditorEvent::TransactionUndone { transaction_id });
}
@ -12307,7 +12298,7 @@ impl Editor {
}
self.request_autoscroll(Autoscroll::fit(), cx);
self.unmark_text(window, cx);
self.refresh_inline_completion(true, false, window, cx);
self.refresh_edit_prediction(true, false, window, cx);
cx.emit(EditorEvent::Edited { transaction_id });
}
}
@ -15294,7 +15285,7 @@ impl Editor {
])
});
self.activate_diagnostics(buffer_id, next_diagnostic, window, cx);
self.refresh_inline_completion(false, true, window, cx);
self.refresh_edit_prediction(false, true, window, cx);
}
pub fn go_to_next_hunk(&mut self, _: &GoToHunk, window: &mut Window, cx: &mut Context<Self>) {
@ -16258,7 +16249,7 @@ impl Editor {
font_weight: Some(FontWeight::BOLD),
..make_inlay_hints_style(cx.app)
},
inline_completion_styles: make_suggestion_styles(
edit_prediction_styles: make_suggestion_styles(
cx.app,
),
..EditorStyle::default()
@ -19032,7 +19023,7 @@ impl Editor {
(selection.range(), uuid.to_string())
});
this.edit(edits, cx);
this.refresh_inline_completion(true, false, window, cx);
this.refresh_edit_prediction(true, false, window, cx);
});
}
@ -19885,8 +19876,8 @@ impl Editor {
self.refresh_selected_text_highlights(true, window, cx);
self.refresh_single_line_folds(window, cx);
refresh_matching_bracket_highlights(self, window, cx);
if self.has_active_inline_completion() {
self.update_visible_inline_completion(window, cx);
if self.has_active_edit_prediction() {
self.update_visible_edit_prediction(window, cx);
}
if let Some(project) = self.project.as_ref() {
if let Some(edited_buffer) = edited_buffer {
@ -20088,7 +20079,7 @@ impl Editor {
}
self.tasks_update_task = Some(self.refresh_runnables(window, cx));
self.update_edit_prediction_settings(cx);
self.refresh_inline_completion(true, false, window, cx);
self.refresh_edit_prediction(true, false, window, cx);
self.refresh_inline_values(cx);
self.refresh_inlay_hints(
InlayHintRefreshReason::SettingsChange(inlay_hint_settings(
@ -20720,7 +20711,7 @@ impl Editor {
{
self.hide_context_menu(window, cx);
}
self.discard_inline_completion(false, cx);
self.discard_edit_prediction(false, cx);
cx.emit(EditorEvent::Blurred);
cx.notify();
}
@ -22782,7 +22773,7 @@ impl Render for Editor {
syntax: cx.theme().syntax().clone(),
status: cx.theme().status().clone(),
inlay_hints_style: make_inlay_hints_style(cx),
inline_completion_styles: make_suggestion_styles(cx),
edit_prediction_styles: make_suggestion_styles(cx),
unnecessary_code_fade: ThemeSettings::get_global(cx).unnecessary_code_fade,
show_underlines: self.diagnostics_enabled(),
},
@ -23177,7 +23168,7 @@ impl InvalidationRegion for SnippetState {
}
}
fn inline_completion_edit_text(
fn edit_prediction_edit_text(
current_snapshot: &BufferSnapshot,
edits: &[(Range<Anchor>, String)],
edit_preview: &EditPreview,

View file

@ -2,7 +2,7 @@ use super::*;
use crate::{
JoinLines,
code_context_menus::CodeContextMenu,
inline_completion_tests::FakeInlineCompletionProvider,
edit_prediction_tests::FakeEditPredictionProvider,
linked_editing_ranges::LinkedEditingRanges,
scroll::scroll_amount::ScrollAmount,
test::{
@ -7251,12 +7251,12 @@ async fn test_undo_format_scrolls_to_last_edit_pos(cx: &mut TestAppContext) {
}
#[gpui::test]
async fn test_undo_inline_completion_scrolls_to_edit_pos(cx: &mut TestAppContext) {
async fn test_undo_edit_prediction_scrolls_to_edit_pos(cx: &mut TestAppContext) {
init_test(cx, |_| {});
let mut cx = EditorTestContext::new(cx).await;
let provider = cx.new(|_| FakeInlineCompletionProvider::default());
let provider = cx.new(|_| FakeEditPredictionProvider::default());
cx.update_editor(|editor, window, cx| {
editor.set_edit_prediction_provider(Some(provider.clone()), window, cx);
});
@ -7279,7 +7279,7 @@ async fn test_undo_inline_completion_scrolls_to_edit_pos(cx: &mut TestAppContext
cx.update(|_, cx| {
provider.update(cx, |provider, _| {
provider.set_inline_completion(Some(inline_completion::InlineCompletion {
provider.set_edit_prediction(Some(edit_prediction::EditPrediction {
id: None,
edits: vec![(edit_position..edit_position, "X".into())],
edit_preview: None,
@ -7287,7 +7287,7 @@ async fn test_undo_inline_completion_scrolls_to_edit_pos(cx: &mut TestAppContext
})
});
cx.update_editor(|editor, window, cx| editor.update_visible_inline_completion(window, cx));
cx.update_editor(|editor, window, cx| editor.update_visible_edit_prediction(window, cx));
cx.update_editor(|editor, window, cx| {
editor.accept_edit_prediction(&crate::AcceptEditPrediction, window, cx)
});
@ -20552,7 +20552,7 @@ async fn test_multi_buffer_navigation_with_folded_buffers(cx: &mut TestAppContex
}
#[gpui::test]
async fn test_inline_completion_text(cx: &mut TestAppContext) {
async fn test_edit_prediction_text(cx: &mut TestAppContext) {
init_test(cx, |_| {});
// Simple insertion
@ -20651,7 +20651,7 @@ async fn test_inline_completion_text(cx: &mut TestAppContext) {
}
#[gpui::test]
async fn test_inline_completion_text_with_deletions(cx: &mut TestAppContext) {
async fn test_edit_prediction_text_with_deletions(cx: &mut TestAppContext) {
init_test(cx, |_| {});
// Deletion
@ -20741,7 +20741,7 @@ async fn assert_highlighted_edits(
.await;
cx.update(|_window, cx| {
let highlighted_edits = inline_completion_edit_text(
let highlighted_edits = edit_prediction_edit_text(
&snapshot.as_singleton().unwrap().2,
&edits,
&edit_preview,

View file

@ -3,11 +3,11 @@ use crate::{
CodeActionSource, ColumnarMode, ConflictsOurs, ConflictsOursMarker, ConflictsOuter,
ConflictsTheirs, ConflictsTheirsMarker, ContextMenuPlacement, CursorShape, CustomBlockId,
DisplayDiffHunk, DisplayPoint, DisplayRow, DocumentHighlightRead, DocumentHighlightWrite,
EditDisplayMode, Editor, EditorMode, EditorSettings, EditorSnapshot, EditorStyle,
FILE_HEADER_HEIGHT, FocusedBlock, GutterDimensions, HalfPageDown, HalfPageUp, HandleInput,
HoveredCursor, InlayHintRefreshReason, InlineCompletion, JumpData, LineDown, LineHighlight,
LineUp, MAX_LINE_LEN, MINIMAP_FONT_SIZE, MULTI_BUFFER_EXCERPT_HEADER_HEIGHT, OpenExcerpts,
PageDown, PageUp, PhantomBreakpointIndicator, Point, RowExt, RowRangeExt, SelectPhase,
EditDisplayMode, EditPrediction, Editor, EditorMode, EditorSettings, EditorSnapshot,
EditorStyle, FILE_HEADER_HEIGHT, FocusedBlock, GutterDimensions, HalfPageDown, HalfPageUp,
HandleInput, HoveredCursor, InlayHintRefreshReason, JumpData, LineDown, LineHighlight, LineUp,
MAX_LINE_LEN, MINIMAP_FONT_SIZE, MULTI_BUFFER_EXCERPT_HEADER_HEIGHT, OpenExcerpts, PageDown,
PageUp, PhantomBreakpointIndicator, Point, RowExt, RowRangeExt, SelectPhase,
SelectedTextHighlight, Selection, SelectionDragState, SoftWrap, StickyHeaderExcerpt, ToPoint,
ToggleFold, ToggleFoldAll,
code_context_menus::{CodeActionsMenu, MENU_ASIDE_MAX_WIDTH, MENU_ASIDE_MIN_WIDTH, MENU_GAP},
@ -554,7 +554,7 @@ impl EditorElement {
register_action(editor, window, Editor::signature_help_next);
register_action(editor, window, Editor::next_edit_prediction);
register_action(editor, window, Editor::previous_edit_prediction);
register_action(editor, window, Editor::show_inline_completion);
register_action(editor, window, Editor::show_edit_prediction);
register_action(editor, window, Editor::context_menu_first);
register_action(editor, window, Editor::context_menu_prev);
register_action(editor, window, Editor::context_menu_next);
@ -562,7 +562,7 @@ impl EditorElement {
register_action(editor, window, Editor::display_cursor_names);
register_action(editor, window, Editor::unique_lines_case_insensitive);
register_action(editor, window, Editor::unique_lines_case_sensitive);
register_action(editor, window, Editor::accept_partial_inline_completion);
register_action(editor, window, Editor::accept_partial_edit_prediction);
register_action(editor, window, Editor::accept_edit_prediction);
register_action(editor, window, Editor::restore_file);
register_action(editor, window, Editor::git_restore);
@ -2093,7 +2093,7 @@ impl EditorElement {
row_block_types: &HashMap<DisplayRow, bool>,
content_origin: gpui::Point<Pixels>,
scroll_pixel_position: gpui::Point<Pixels>,
inline_completion_popover_origin: Option<gpui::Point<Pixels>>,
edit_prediction_popover_origin: Option<gpui::Point<Pixels>>,
start_row: DisplayRow,
end_row: DisplayRow,
line_height: Pixels,
@ -2210,12 +2210,13 @@ impl EditorElement {
cmp::max(padded_line, min_start)
};
let behind_inline_completion_popover = inline_completion_popover_origin
.as_ref()
.map_or(false, |inline_completion_popover_origin| {
(pos_y..pos_y + line_height).contains(&inline_completion_popover_origin.y)
});
let opacity = if behind_inline_completion_popover {
let behind_edit_prediction_popover = edit_prediction_popover_origin.as_ref().map_or(
false,
|edit_prediction_popover_origin| {
(pos_y..pos_y + line_height).contains(&edit_prediction_popover_origin.y)
},
);
let opacity = if behind_edit_prediction_popover {
0.5
} else {
1.0
@ -2427,9 +2428,9 @@ impl EditorElement {
let mut padding = INLINE_BLAME_PADDING_EM_WIDTHS;
if let Some(inline_completion) = editor.active_inline_completion.as_ref() {
match &inline_completion.completion {
InlineCompletion::Edit {
if let Some(edit_prediction) = editor.active_edit_prediction.as_ref() {
match &edit_prediction.completion {
EditPrediction::Edit {
display_mode: EditDisplayMode::TabAccept,
..
} => padding += INLINE_ACCEPT_SUGGESTION_EM_WIDTHS,
@ -4086,8 +4087,7 @@ impl EditorElement {
{
let editor = self.editor.read(cx);
if editor
.edit_prediction_visible_in_cursor_popover(editor.has_active_inline_completion())
if editor.edit_prediction_visible_in_cursor_popover(editor.has_active_edit_prediction())
{
height_above_menu +=
editor.edit_prediction_cursor_popover_height() + POPOVER_Y_PADDING;
@ -6676,14 +6676,14 @@ impl EditorElement {
}
}
fn paint_inline_completion_popover(
fn paint_edit_prediction_popover(
&mut self,
layout: &mut EditorLayout,
window: &mut Window,
cx: &mut App,
) {
if let Some(inline_completion_popover) = layout.inline_completion_popover.as_mut() {
inline_completion_popover.paint(window, cx);
if let Some(edit_prediction_popover) = layout.edit_prediction_popover.as_mut() {
edit_prediction_popover.paint(window, cx);
}
}
@ -8501,7 +8501,7 @@ impl Element for EditorElement {
)
});
let (inline_completion_popover, inline_completion_popover_origin) = self
let (edit_prediction_popover, edit_prediction_popover_origin) = self
.editor
.update(cx, |editor, cx| {
editor.render_edit_prediction_popover(
@ -8530,7 +8530,7 @@ impl Element for EditorElement {
&row_block_types,
content_origin,
scroll_pixel_position,
inline_completion_popover_origin,
edit_prediction_popover_origin,
start_row,
end_row,
line_height,
@ -8919,7 +8919,7 @@ impl Element for EditorElement {
cursors,
visible_cursors,
selections,
inline_completion_popover,
edit_prediction_popover,
diff_hunk_controls,
mouse_context_menu,
test_indicators,
@ -9001,7 +9001,7 @@ impl Element for EditorElement {
self.paint_minimap(layout, window, cx);
self.paint_scrollbars(layout, window, cx);
self.paint_inline_completion_popover(layout, window, cx);
self.paint_edit_prediction_popover(layout, window, cx);
self.paint_mouse_context_menu(layout, window, cx);
});
})
@ -9102,7 +9102,7 @@ pub struct EditorLayout {
expand_toggles: Vec<Option<(AnyElement, gpui::Point<Pixels>)>>,
diff_hunk_controls: Vec<AnyElement>,
crease_trailers: Vec<Option<CreaseTrailerLayout>>,
inline_completion_popover: Option<AnyElement>,
edit_prediction_popover: Option<AnyElement>,
mouse_context_menu: Option<AnyElement>,
tab_invisible: ShapedLine,
space_invisible: ShapedLine,

View file

@ -907,12 +907,12 @@ mod tests {
let inlays = (0..buffer_snapshot.len())
.flat_map(|offset| {
[
Inlay::inline_completion(
Inlay::edit_prediction(
post_inc(&mut id),
buffer_snapshot.anchor_at(offset, Bias::Left),
"test",
),
Inlay::inline_completion(
Inlay::edit_prediction(
post_inc(&mut id),
buffer_snapshot.anchor_at(offset, Bias::Right),
"test",

View file

@ -253,8 +253,8 @@ impl LogStore {
let copilot_subscription = Copilot::global(cx).map(|copilot| {
let copilot = &copilot;
cx.subscribe(copilot, |this, copilot, inline_completion_event, cx| {
if let copilot::Event::CopilotLanguageServerStarted = inline_completion_event {
cx.subscribe(copilot, |this, copilot, edit_prediction_event, cx| {
if let copilot::Event::CopilotLanguageServerStarted = edit_prediction_event {
if let Some(server) = copilot.read(cx).language_server() {
let server_id = server.server_id();
let weak_this = cx.weak_entity();

View file

@ -242,22 +242,22 @@ static STRING_REPLACE: LazyLock<HashMap<&str, &str>> = LazyLock::new(|| {
"inline_completion::ToggleMenu",
"edit_prediction::ToggleMenu",
),
("editor::NextInlineCompletion", "editor::NextEditPrediction"),
("editor::NextEditPrediction", "editor::NextEditPrediction"),
(
"editor::PreviousInlineCompletion",
"editor::PreviousEditPrediction",
"editor::PreviousEditPrediction",
),
(
"editor::AcceptPartialInlineCompletion",
"editor::AcceptPartialEditPrediction",
"editor::AcceptPartialEditPrediction",
),
("editor::ShowInlineCompletion", "editor::ShowEditPrediction"),
("editor::ShowEditPrediction", "editor::ShowEditPrediction"),
(
"editor::AcceptInlineCompletion",
"editor::AcceptEditPrediction",
"editor::AcceptEditPrediction",
),
(
"editor::ToggleInlineCompletions",
"editor::ToggleEditPredictions",
"editor::ToggleEditPrediction",
),
])

View file

@ -1101,7 +1101,7 @@ impl RulesLibrary {
inlay_hints_style: editor::make_inlay_hints_style(
cx,
),
inline_completion_styles:
edit_prediction_styles:
editor::make_suggestion_styles(cx),
..EditorStyle::default()
},

View file

@ -16,9 +16,9 @@ doctest = false
anyhow.workspace = true
client.workspace = true
collections.workspace = true
edit_prediction.workspace = true
futures.workspace = true
gpui.workspace = true
inline_completion.workspace = true
language.workspace = true
log.workspace = true
postage.workspace = true

View file

@ -1,8 +1,8 @@
use crate::{Supermaven, SupermavenCompletionStateId};
use anyhow::Result;
use edit_prediction::{Direction, EditPrediction, EditPredictionProvider};
use futures::StreamExt as _;
use gpui::{App, Context, Entity, EntityId, Task};
use inline_completion::{Direction, EditPredictionProvider, InlineCompletion};
use language::{Anchor, Buffer, BufferSnapshot};
use project::Project;
use std::{
@ -44,7 +44,7 @@ fn completion_from_diff(
completion_text: &str,
position: Anchor,
delete_range: Range<Anchor>,
) -> InlineCompletion {
) -> EditPrediction {
let buffer_text = snapshot
.text_for_range(delete_range.clone())
.collect::<String>();
@ -91,7 +91,7 @@ fn completion_from_diff(
edits.push((edit_range, edit_text));
}
InlineCompletion {
EditPrediction {
id: None,
edits,
edit_preview: None,
@ -182,7 +182,7 @@ impl EditPredictionProvider for SupermavenCompletionProvider {
buffer: &Entity<Buffer>,
cursor_position: Anchor,
cx: &mut Context<Self>,
) -> Option<InlineCompletion> {
) -> Option<EditPrediction> {
let completion_text = self
.supermaven
.read(cx)

View file

@ -94,8 +94,8 @@ impl Display for AssistantPhase {
pub enum Event {
Flexible(FlexibleEvent),
Editor(EditorEvent),
InlineCompletion(InlineCompletionEvent),
InlineCompletionRating(InlineCompletionRatingEvent),
EditPrediction(EditPredictionEvent),
EditPredictionRating(EditPredictionRatingEvent),
Call(CallEvent),
Assistant(AssistantEventData),
Cpu(CpuEvent),
@ -132,7 +132,7 @@ pub struct EditorEvent {
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct InlineCompletionEvent {
pub struct EditPredictionEvent {
/// Provider of the completion suggestion (e.g. copilot, supermaven)
pub provider: String,
pub suggestion_accepted: bool,
@ -140,14 +140,14 @@ pub struct InlineCompletionEvent {
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum InlineCompletionRating {
pub enum EditPredictionRating {
Positive,
Negative,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct InlineCompletionRatingEvent {
pub rating: InlineCompletionRating,
pub struct EditPredictionRatingEvent {
pub rating: EditPredictionRating,
pub input_events: Arc<str>,
pub input_excerpt: Arc<str>,
pub output_excerpt: Arc<str>,

View file

@ -3808,7 +3808,7 @@ mod test {
cx.update_editor(|editor, _window, cx| {
let range = editor.selections.newest_anchor().range();
let inlay_text = " field: int,\n field2: string\n field3: float";
let inlay = Inlay::inline_completion(1, range.start, inlay_text);
let inlay = Inlay::edit_prediction(1, range.start, inlay_text);
editor.splice_inlays(&[], vec![inlay], cx);
});
@ -3840,7 +3840,7 @@ mod test {
let end_of_line =
snapshot.anchor_after(Point::new(0, snapshot.line_len(MultiBufferRow(0))));
let inlay_text = " hint";
let inlay = Inlay::inline_completion(1, end_of_line, inlay_text);
let inlay = Inlay::edit_prediction(1, end_of_line, inlay_text);
editor.splice_inlays(&[], vec![inlay], cx);
});
cx.simulate_keystrokes("$");

View file

@ -90,7 +90,7 @@ impl Vim {
if let Some(kind) = motion_kind {
vim.copy_selections_content(editor, kind, window, cx);
editor.insert("", window, cx);
editor.refresh_inline_completion(true, false, window, cx);
editor.refresh_edit_prediction(true, false, window, cx);
}
});
});
@ -123,7 +123,7 @@ impl Vim {
if objects_found {
vim.copy_selections_content(editor, MotionKind::Exclusive, window, cx);
editor.insert("", window, cx);
editor.refresh_inline_completion(true, false, window, cx);
editor.refresh_edit_prediction(true, false, window, cx);
}
});
});

View file

@ -82,7 +82,7 @@ impl Vim {
selection.collapse_to(cursor, selection.goal)
});
});
editor.refresh_inline_completion(true, false, window, cx);
editor.refresh_edit_prediction(true, false, window, cx);
});
});
}
@ -169,7 +169,7 @@ impl Vim {
selection.collapse_to(cursor, selection.goal)
});
});
editor.refresh_inline_completion(true, false, window, cx);
editor.refresh_edit_prediction(true, false, window, cx);
});
});
}

View file

@ -1741,11 +1741,11 @@ impl Vim {
editor.set_autoindent(vim.should_autoindent());
editor.selections.line_mode = matches!(vim.mode, Mode::VisualLine);
let hide_inline_completions = match vim.mode {
let hide_edit_predictions = match vim.mode {
Mode::Insert | Mode::Replace => false,
_ => true,
};
editor.set_inline_completions_hidden_for_vim_mode(hide_inline_completions, window, cx);
editor.set_edit_predictions_hidden_for_vim_mode(hide_edit_predictions, window, cx);
});
cx.notify()
}

View file

@ -76,7 +76,7 @@ gpui_tokio.workspace = true
http_client.workspace = true
image_viewer.workspace = true
indoc.workspace = true
inline_completion_button.workspace = true
edit_prediction_button.workspace = true
inspector_ui.workspace = true
install_cli.workspace = true
jj_ui.workspace = true

View file

@ -51,9 +51,9 @@ use workspace::{
};
use zed::{
OpenListener, OpenRequest, RawOpenRequest, app_menus, build_window_options,
derive_paths_with_position, handle_cli_connection, handle_keymap_file_changes,
handle_settings_changed, handle_settings_file_changes, initialize_workspace,
inline_completion_registry, open_paths_with_positions,
derive_paths_with_position, edit_prediction_registry, handle_cli_connection,
handle_keymap_file_changes, handle_settings_changed, handle_settings_file_changes,
initialize_workspace, open_paths_with_positions,
};
use crate::zed::OpenRequestKind;
@ -559,11 +559,7 @@ pub fn main() {
web_search::init(cx);
web_search_providers::init(app_state.client.clone(), cx);
snippet_provider::init(cx);
inline_completion_registry::init(
app_state.client.clone(),
app_state.user_store.clone(),
cx,
);
edit_prediction_registry::init(app_state.client.clone(), app_state.user_store.clone(), cx);
let prompt_builder = PromptBuilder::load(app_state.fs.clone(), stdout_is_a_pty(), cx);
agent_ui::init(
app_state.fs.clone(),

View file

@ -1,6 +1,6 @@
mod app_menus;
pub mod component_preview;
pub mod inline_completion_registry;
pub mod edit_prediction_registry;
#[cfg(target_os = "macos")]
pub(crate) mod mac_only_instance;
mod migrate;
@ -332,18 +332,18 @@ pub fn initialize_workspace(
show_software_emulation_warning_if_needed(specs, window, cx);
}
let inline_completion_menu_handle = PopoverMenuHandle::default();
let edit_prediction_menu_handle = PopoverMenuHandle::default();
let edit_prediction_button = cx.new(|cx| {
inline_completion_button::InlineCompletionButton::new(
edit_prediction_button::EditPredictionButton::new(
app_state.fs.clone(),
app_state.user_store.clone(),
inline_completion_menu_handle.clone(),
edit_prediction_menu_handle.clone(),
cx,
)
});
workspace.register_action({
move |_, _: &inline_completion_button::ToggleMenu, window, cx| {
inline_completion_menu_handle.toggle(window, cx);
move |_, _: &edit_prediction_button::ToggleMenu, window, cx| {
edit_prediction_menu_handle.toggle(window, cx);
}
});

View file

@ -11,7 +11,7 @@ use supermaven::{Supermaven, SupermavenCompletionProvider};
use ui::Window;
use util::ResultExt;
use workspace::Workspace;
use zeta::{ProviderDataCollection, ZetaInlineCompletionProvider};
use zeta::{ProviderDataCollection, ZetaEditPredictionProvider};
pub fn init(client: Arc<Client>, user_store: Entity<UserStore>, cx: &mut App) {
let editors: Rc<RefCell<HashMap<WeakEntity<Editor>, AnyWindowHandle>>> = Rc::default();
@ -171,7 +171,7 @@ fn register_backward_compatible_actions(editor: &mut Editor, cx: &mut Context<Ed
editor
.register_action(cx.listener(
|editor, _: &copilot::Suggest, window: &mut Window, cx: &mut Context<Editor>| {
editor.show_inline_completion(&Default::default(), window, cx);
editor.show_edit_prediction(&Default::default(), window, cx);
},
))
.detach();
@ -207,7 +207,7 @@ fn assign_edit_prediction_provider(
match provider {
EditPredictionProvider::None => {
editor.set_edit_prediction_provider::<ZetaInlineCompletionProvider>(None, window, cx);
editor.set_edit_prediction_provider::<ZetaEditPredictionProvider>(None, window, cx);
}
EditPredictionProvider::Copilot => {
if let Some(copilot) = Copilot::global(cx) {
@ -265,7 +265,7 @@ fn assign_edit_prediction_provider(
ProviderDataCollection::new(zeta.clone(), singleton_buffer, cx);
let provider =
cx.new(|_| zeta::ZetaInlineCompletionProvider::new(zeta, data_collection));
cx.new(|_| zeta::ZetaEditPredictionProvider::new(zeta, data_collection));
editor.set_edit_prediction_provider(Some(provider), window, cx);
}

View file

@ -381,7 +381,7 @@ impl Render for QuickActionBar {
}
if has_edit_prediction_provider {
let mut inline_completion_entry = ContextMenuEntry::new("Edit Predictions")
let mut edit_prediction_entry = ContextMenuEntry::new("Edit Predictions")
.toggleable(IconPosition::Start, edit_predictions_enabled_at_cursor && show_edit_predictions)
.disabled(!edit_predictions_enabled_at_cursor)
.action(
@ -401,12 +401,12 @@ impl Render for QuickActionBar {
}
});
if !edit_predictions_enabled_at_cursor {
inline_completion_entry = inline_completion_entry.documentation_aside(DocumentationSide::Left, |_| {
edit_prediction_entry = edit_prediction_entry.documentation_aside(DocumentationSide::Left, |_| {
Label::new("You can't toggle edit predictions for this file as it is within the excluded files list.").into_any_element()
});
}
menu = menu.item(inline_completion_entry);
menu = menu.item(edit_prediction_entry);
}
menu = menu.separator();

View file

@ -33,7 +33,7 @@ futures.workspace = true
gpui.workspace = true
http_client.workspace = true
indoc.workspace = true
inline_completion.workspace = true
edit_prediction.workspace = true
language.workspace = true
language_model.workspace = true
log.workspace = true

View file

@ -1,6 +1,6 @@
use std::cmp;
use crate::InlineCompletion;
use crate::EditPrediction;
use gpui::{
AnyElement, App, BorderStyle, Bounds, Corners, Edges, HighlightStyle, Hsla, StyledText,
TextLayout, TextStyle, point, prelude::*, quad, size,
@ -17,7 +17,7 @@ pub struct CompletionDiffElement {
}
impl CompletionDiffElement {
pub fn new(completion: &InlineCompletion, cx: &App) -> Self {
pub fn new(completion: &EditPrediction, cx: &App) -> Self {
let mut diff = completion
.snapshot
.text_for_range(completion.excerpt_range.clone())

View file

@ -1,4 +1,4 @@
use crate::{CompletionDiffElement, InlineCompletion, InlineCompletionRating, Zeta};
use crate::{CompletionDiffElement, EditPrediction, EditPredictionRating, Zeta};
use editor::Editor;
use gpui::{App, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, actions, prelude::*};
use language::language_settings;
@ -34,7 +34,7 @@ pub struct RateCompletionModal {
}
struct ActiveCompletion {
completion: InlineCompletion,
completion: EditPrediction,
feedback_editor: Entity<Editor>,
}
@ -157,7 +157,7 @@ impl RateCompletionModal {
if let Some(active) = &self.active_completion {
zeta.rate_completion(
&active.completion,
InlineCompletionRating::Positive,
EditPredictionRating::Positive,
active.feedback_editor.read(cx).text(cx),
cx,
);
@ -189,7 +189,7 @@ impl RateCompletionModal {
self.zeta.update(cx, |zeta, cx| {
zeta.rate_completion(
&active.completion,
InlineCompletionRating::Negative,
EditPredictionRating::Negative,
active.feedback_editor.read(cx).text(cx),
cx,
);
@ -250,7 +250,7 @@ impl RateCompletionModal {
pub fn select_completion(
&mut self,
completion: Option<InlineCompletion>,
completion: Option<EditPrediction>,
focus: bool,
window: &mut Window,
cx: &mut Context<Self>,

View file

@ -8,8 +8,8 @@ mod rate_completion_modal;
pub(crate) use completion_diff_element::*;
use db::kvp::{Dismissable, KEY_VALUE_STORE};
use edit_prediction::DataCollectionState;
pub use init::*;
use inline_completion::DataCollectionState;
use license_detection::LICENSE_FILES_TO_CHECK;
pub use license_detection::is_license_eligible_for_data_collection;
pub use rate_completion_modal::*;
@ -50,7 +50,7 @@ use std::{
sync::Arc,
time::{Duration, Instant},
};
use telemetry_events::InlineCompletionRating;
use telemetry_events::EditPredictionRating;
use thiserror::Error;
use util::ResultExt;
use uuid::Uuid;
@ -81,15 +81,15 @@ actions!(
);
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Hash)]
pub struct InlineCompletionId(Uuid);
pub struct EditPredictionId(Uuid);
impl From<InlineCompletionId> for gpui::ElementId {
fn from(value: InlineCompletionId) -> Self {
impl From<EditPredictionId> for gpui::ElementId {
fn from(value: EditPredictionId) -> Self {
gpui::ElementId::Uuid(value.0)
}
}
impl std::fmt::Display for InlineCompletionId {
impl std::fmt::Display for EditPredictionId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
@ -134,8 +134,8 @@ struct ZetaGlobal(Entity<Zeta>);
impl Global for ZetaGlobal {}
#[derive(Clone)]
pub struct InlineCompletion {
id: InlineCompletionId,
pub struct EditPrediction {
id: EditPredictionId,
path: Arc<Path>,
excerpt_range: Range<usize>,
cursor_offset: usize,
@ -150,7 +150,7 @@ pub struct InlineCompletion {
response_received_at: Instant,
}
impl InlineCompletion {
impl EditPrediction {
fn latency(&self) -> Duration {
self.response_received_at
.duration_since(self.buffer_snapshotted_at)
@ -207,9 +207,9 @@ fn interpolate(
if edits.is_empty() { None } else { Some(edits) }
}
impl std::fmt::Debug for InlineCompletion {
impl std::fmt::Debug for EditPrediction {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("InlineCompletion")
f.debug_struct("EditPrediction")
.field("id", &self.id)
.field("path", &self.path)
.field("edits", &self.edits)
@ -222,8 +222,8 @@ pub struct Zeta {
client: Arc<Client>,
events: VecDeque<Event>,
registered_buffers: HashMap<gpui::EntityId, RegisteredBuffer>,
shown_completions: VecDeque<InlineCompletion>,
rated_completions: HashSet<InlineCompletionId>,
shown_completions: VecDeque<EditPrediction>,
rated_completions: HashSet<EditPredictionId>,
data_collection_choice: Entity<DataCollectionChoice>,
llm_token: LlmApiToken,
_llm_token_subscription: Subscription,
@ -384,7 +384,7 @@ impl Zeta {
can_collect_data: bool,
cx: &mut Context<Self>,
perform_predict_edits: F,
) -> Task<Result<Option<InlineCompletion>>>
) -> Task<Result<Option<EditPrediction>>>
where
F: FnOnce(PerformPredictEditsParams) -> R + 'static,
R: Future<Output = Result<(PredictEditsResponse, Option<EditPredictionUsage>)>>
@ -664,7 +664,7 @@ and then another
position: language::Anchor,
response: PredictEditsResponse,
cx: &mut Context<Self>,
) -> Task<Result<Option<InlineCompletion>>> {
) -> Task<Result<Option<EditPrediction>>> {
use std::future::ready;
self.request_completion_impl(None, project, buffer, position, false, cx, |_params| {
@ -679,7 +679,7 @@ and then another
position: language::Anchor,
can_collect_data: bool,
cx: &mut Context<Self>,
) -> Task<Result<Option<InlineCompletion>>> {
) -> Task<Result<Option<EditPrediction>>> {
let workspace = self
.workspace
.as_ref()
@ -773,7 +773,7 @@ and then another
fn accept_edit_prediction(
&mut self,
request_id: InlineCompletionId,
request_id: EditPredictionId,
cx: &mut Context<Self>,
) -> Task<Result<()>> {
let client = self.client.clone();
@ -852,7 +852,7 @@ and then another
input_excerpt: String,
buffer_snapshotted_at: Instant,
cx: &AsyncApp,
) -> Task<Result<Option<InlineCompletion>>> {
) -> Task<Result<Option<EditPrediction>>> {
let snapshot = snapshot.clone();
let request_id = prediction_response.request_id;
let output_excerpt = prediction_response.output_excerpt;
@ -884,8 +884,8 @@ and then another
let edit_preview = edit_preview.await;
Ok(Some(InlineCompletion {
id: InlineCompletionId(request_id),
Ok(Some(EditPrediction {
id: EditPredictionId(request_id),
path,
excerpt_range: editable_range,
cursor_offset,
@ -995,11 +995,11 @@ and then another
.collect()
}
pub fn is_completion_rated(&self, completion_id: InlineCompletionId) -> bool {
pub fn is_completion_rated(&self, completion_id: EditPredictionId) -> bool {
self.rated_completions.contains(&completion_id)
}
pub fn completion_shown(&mut self, completion: &InlineCompletion, cx: &mut Context<Self>) {
pub fn completion_shown(&mut self, completion: &EditPrediction, cx: &mut Context<Self>) {
self.shown_completions.push_front(completion.clone());
if self.shown_completions.len() > 50 {
let completion = self.shown_completions.pop_back().unwrap();
@ -1010,8 +1010,8 @@ and then another
pub fn rate_completion(
&mut self,
completion: &InlineCompletion,
rating: InlineCompletionRating,
completion: &EditPrediction,
rating: EditPredictionRating,
feedback: String,
cx: &mut Context<Self>,
) {
@ -1029,7 +1029,7 @@ and then another
cx.notify();
}
pub fn shown_completions(&self) -> impl DoubleEndedIterator<Item = &InlineCompletion> {
pub fn shown_completions(&self) -> impl DoubleEndedIterator<Item = &EditPrediction> {
self.shown_completions.iter()
}
@ -1323,12 +1323,12 @@ impl Event {
}
#[derive(Debug, Clone)]
struct CurrentInlineCompletion {
struct CurrentEditPrediction {
buffer_id: EntityId,
completion: InlineCompletion,
completion: EditPrediction,
}
impl CurrentInlineCompletion {
impl CurrentEditPrediction {
fn should_replace_completion(&self, old_completion: &Self, snapshot: &BufferSnapshot) -> bool {
if self.buffer_id != old_completion.buffer_id {
return true;
@ -1497,17 +1497,17 @@ async fn llm_token_retry(
}
}
pub struct ZetaInlineCompletionProvider {
pub struct ZetaEditPredictionProvider {
zeta: Entity<Zeta>,
pending_completions: ArrayVec<PendingCompletion, 2>,
next_pending_completion_id: usize,
current_completion: Option<CurrentInlineCompletion>,
current_completion: Option<CurrentEditPrediction>,
/// None if this is entirely disabled for this provider
provider_data_collection: ProviderDataCollection,
last_request_timestamp: Instant,
}
impl ZetaInlineCompletionProvider {
impl ZetaEditPredictionProvider {
pub const THROTTLE_TIMEOUT: Duration = Duration::from_millis(300);
pub fn new(zeta: Entity<Zeta>, provider_data_collection: ProviderDataCollection) -> Self {
@ -1522,7 +1522,7 @@ impl ZetaInlineCompletionProvider {
}
}
impl inline_completion::EditPredictionProvider for ZetaInlineCompletionProvider {
impl edit_prediction::EditPredictionProvider for ZetaEditPredictionProvider {
fn name() -> &'static str {
"zed-predict"
}
@ -1650,7 +1650,7 @@ impl inline_completion::EditPredictionProvider for ZetaInlineCompletionProvider
Ok(completion_request) => {
let completion_request = completion_request.await;
completion_request.map(|c| {
c.map(|completion| CurrentInlineCompletion {
c.map(|completion| CurrentEditPrediction {
buffer_id: buffer.entity_id(),
completion,
})
@ -1723,7 +1723,7 @@ impl inline_completion::EditPredictionProvider for ZetaInlineCompletionProvider
&mut self,
_buffer: Entity<Buffer>,
_cursor_position: language::Anchor,
_direction: inline_completion::Direction,
_direction: edit_prediction::Direction,
_cx: &mut Context<Self>,
) {
// Right now we don't support cycling.
@ -1754,8 +1754,8 @@ impl inline_completion::EditPredictionProvider for ZetaInlineCompletionProvider
buffer: &Entity<Buffer>,
cursor_position: language::Anchor,
cx: &mut Context<Self>,
) -> Option<inline_completion::InlineCompletion> {
let CurrentInlineCompletion {
) -> Option<edit_prediction::EditPrediction> {
let CurrentEditPrediction {
buffer_id,
completion,
..
@ -1803,7 +1803,7 @@ impl inline_completion::EditPredictionProvider for ZetaInlineCompletionProvider
}
}
Some(inline_completion::InlineCompletion {
Some(edit_prediction::EditPrediction {
id: Some(completion.id.to_string().into()),
edits: edits[edit_start_ix..edit_end_ix].to_vec(),
edit_preview: Some(completion.edit_preview.clone()),
@ -1833,7 +1833,7 @@ mod tests {
use super::*;
#[gpui::test]
async fn test_inline_completion_basic_interpolation(cx: &mut TestAppContext) {
async fn test_edit_prediction_basic_interpolation(cx: &mut TestAppContext) {
let buffer = cx.new(|cx| Buffer::local("Lorem ipsum dolor", cx));
let edits: Arc<[(Range<Anchor>, String)]> = cx.update(|cx| {
to_completion_edits(
@ -1848,12 +1848,12 @@ mod tests {
.read(|cx| buffer.read(cx).preview_edits(edits.clone(), cx))
.await;
let completion = InlineCompletion {
let completion = EditPrediction {
edits,
edit_preview,
path: Path::new("").into(),
snapshot: cx.read(|cx| buffer.read(cx).snapshot()),
id: InlineCompletionId(Uuid::new_v4()),
id: EditPredictionId(Uuid::new_v4()),
excerpt_range: 0..0,
cursor_offset: 0,
input_outline: "".into(),
@ -2014,7 +2014,7 @@ mod tests {
}
#[gpui::test]
async fn test_inline_completion_end_of_buffer(cx: &mut TestAppContext) {
async fn test_edit_prediction_end_of_buffer(cx: &mut TestAppContext) {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);

View file

@ -220,7 +220,7 @@ Alternatively, you can provide an OAuth token via the `GH_COPILOT_TOKEN` environ
> **Note**: If you don't see specific models in the dropdown, you may need to enable them in your [GitHub Copilot settings](https://github.com/settings/copilot/features).
To use Copilot Enterprise with Zed (for both agent and inline completions), you must configure your enterprise endpoint as described in [Configuring GitHub Copilot Enterprise](./edit-prediction.md#github-copilot-enterprise).
To use Copilot Enterprise with Zed (for both agent and completions), you must configure your enterprise endpoint as described in [Configuring GitHub Copilot Enterprise](./edit-prediction.md#github-copilot-enterprise).
### Google AI {#google-ai}

View file

@ -93,7 +93,7 @@ For example:
# in an editor, it might look like this:
Workspace os=macos keyboard_layout=com.apple.keylayout.QWERTY
Pane
Editor mode=full extension=md inline_completion vim_mode=insert
Editor mode=full extension=md vim_mode=insert
# in the project panel
Workspace os=macos