Rename remaining mentions of "inline completion" to "edit prediction" (#35512)
Release Notes: - N/A
This commit is contained in:
parent
85885723a9
commit
65018c28c0
43 changed files with 480 additions and 498 deletions
96
Cargo.lock
generated
96
Cargo.lock
generated
|
@ -3542,13 +3542,13 @@ dependencies = [
|
||||||
"command_palette_hooks",
|
"command_palette_hooks",
|
||||||
"ctor",
|
"ctor",
|
||||||
"dirs 4.0.0",
|
"dirs 4.0.0",
|
||||||
|
"edit_prediction",
|
||||||
"editor",
|
"editor",
|
||||||
"fs",
|
"fs",
|
||||||
"futures 0.3.31",
|
"futures 0.3.31",
|
||||||
"gpui",
|
"gpui",
|
||||||
"http_client",
|
"http_client",
|
||||||
"indoc",
|
"indoc",
|
||||||
"inline_completion",
|
|
||||||
"itertools 0.14.0",
|
"itertools 0.14.0",
|
||||||
"language",
|
"language",
|
||||||
"log",
|
"log",
|
||||||
|
@ -4855,6 +4855,49 @@ dependencies = [
|
||||||
"signature 1.6.4",
|
"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]]
|
[[package]]
|
||||||
name = "editor"
|
name = "editor"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -4870,6 +4913,7 @@ dependencies = [
|
||||||
"ctor",
|
"ctor",
|
||||||
"dap",
|
"dap",
|
||||||
"db",
|
"db",
|
||||||
|
"edit_prediction",
|
||||||
"emojis",
|
"emojis",
|
||||||
"file_icons",
|
"file_icons",
|
||||||
"fs",
|
"fs",
|
||||||
|
@ -4879,7 +4923,6 @@ dependencies = [
|
||||||
"gpui",
|
"gpui",
|
||||||
"http_client",
|
"http_client",
|
||||||
"indoc",
|
"indoc",
|
||||||
"inline_completion",
|
|
||||||
"itertools 0.14.0",
|
"itertools 0.14.0",
|
||||||
"language",
|
"language",
|
||||||
"languages",
|
"languages",
|
||||||
|
@ -8287,49 +8330,6 @@ dependencies = [
|
||||||
"syn 2.0.101",
|
"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]]
|
[[package]]
|
||||||
name = "inotify"
|
name = "inotify"
|
||||||
version = "0.9.6"
|
version = "0.9.6"
|
||||||
|
@ -15584,12 +15584,12 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"client",
|
"client",
|
||||||
"collections",
|
"collections",
|
||||||
|
"edit_prediction",
|
||||||
"editor",
|
"editor",
|
||||||
"env_logger 0.11.8",
|
"env_logger 0.11.8",
|
||||||
"futures 0.3.31",
|
"futures 0.3.31",
|
||||||
"gpui",
|
"gpui",
|
||||||
"http_client",
|
"http_client",
|
||||||
"inline_completion",
|
|
||||||
"language",
|
"language",
|
||||||
"log",
|
"log",
|
||||||
"postage",
|
"postage",
|
||||||
|
@ -20221,6 +20221,7 @@ dependencies = [
|
||||||
"debugger_tools",
|
"debugger_tools",
|
||||||
"debugger_ui",
|
"debugger_ui",
|
||||||
"diagnostics",
|
"diagnostics",
|
||||||
|
"edit_prediction_button",
|
||||||
"editor",
|
"editor",
|
||||||
"env_logger 0.11.8",
|
"env_logger 0.11.8",
|
||||||
"extension",
|
"extension",
|
||||||
|
@ -20240,7 +20241,6 @@ dependencies = [
|
||||||
"http_client",
|
"http_client",
|
||||||
"image_viewer",
|
"image_viewer",
|
||||||
"indoc",
|
"indoc",
|
||||||
"inline_completion_button",
|
|
||||||
"inspector_ui",
|
"inspector_ui",
|
||||||
"install_cli",
|
"install_cli",
|
||||||
"itertools 0.14.0",
|
"itertools 0.14.0",
|
||||||
|
@ -20572,6 +20572,7 @@ dependencies = [
|
||||||
"copilot",
|
"copilot",
|
||||||
"ctor",
|
"ctor",
|
||||||
"db",
|
"db",
|
||||||
|
"edit_prediction",
|
||||||
"editor",
|
"editor",
|
||||||
"feature_flags",
|
"feature_flags",
|
||||||
"fs",
|
"fs",
|
||||||
|
@ -20579,7 +20580,6 @@ dependencies = [
|
||||||
"gpui",
|
"gpui",
|
||||||
"http_client",
|
"http_client",
|
||||||
"indoc",
|
"indoc",
|
||||||
"inline_completion",
|
|
||||||
"language",
|
"language",
|
||||||
"language_model",
|
"language_model",
|
||||||
"log",
|
"log",
|
||||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -79,8 +79,8 @@ members = [
|
||||||
"crates/icons",
|
"crates/icons",
|
||||||
"crates/image_viewer",
|
"crates/image_viewer",
|
||||||
"crates/indexed_docs",
|
"crates/indexed_docs",
|
||||||
"crates/inline_completion",
|
"crates/edit_prediction",
|
||||||
"crates/inline_completion_button",
|
"crates/edit_prediction_button",
|
||||||
"crates/inspector_ui",
|
"crates/inspector_ui",
|
||||||
"crates/install_cli",
|
"crates/install_cli",
|
||||||
"crates/jj",
|
"crates/jj",
|
||||||
|
@ -302,8 +302,8 @@ http_client_tls = { path = "crates/http_client_tls" }
|
||||||
icons = { path = "crates/icons" }
|
icons = { path = "crates/icons" }
|
||||||
image_viewer = { path = "crates/image_viewer" }
|
image_viewer = { path = "crates/image_viewer" }
|
||||||
indexed_docs = { path = "crates/indexed_docs" }
|
indexed_docs = { path = "crates/indexed_docs" }
|
||||||
inline_completion = { path = "crates/inline_completion" }
|
edit_prediction = { path = "crates/edit_prediction" }
|
||||||
inline_completion_button = { path = "crates/inline_completion_button" }
|
edit_prediction_button = { path = "crates/edit_prediction_button" }
|
||||||
inspector_ui = { path = "crates/inspector_ui" }
|
inspector_ui = { path = "crates/inspector_ui" }
|
||||||
install_cli = { path = "crates/install_cli" }
|
install_cli = { path = "crates/install_cli" }
|
||||||
jj = { path = "crates/jj" }
|
jj = { path = "crates/jj" }
|
||||||
|
@ -756,7 +756,7 @@ feature_flags = { codegen-units = 1 }
|
||||||
file_icons = { codegen-units = 1 }
|
file_icons = { codegen-units = 1 }
|
||||||
fsevent = { codegen-units = 1 }
|
fsevent = { codegen-units = 1 }
|
||||||
image_viewer = { 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 }
|
install_cli = { codegen-units = 1 }
|
||||||
journal = { codegen-units = 1 }
|
journal = { codegen-units = 1 }
|
||||||
lmstudio = { codegen-units = 1 }
|
lmstudio = { codegen-units = 1 }
|
||||||
|
|
|
@ -162,7 +162,7 @@ impl InlineAssistant {
|
||||||
let window = windows[0];
|
let window = windows[0];
|
||||||
let _ = window.update(cx, |_, window, cx| {
|
let _ = window.update(cx, |_, window, cx| {
|
||||||
editor.update(cx, |editor, cx| {
|
editor.update(cx, |editor, cx| {
|
||||||
if editor.has_active_inline_completion() {
|
if editor.has_active_edit_prediction() {
|
||||||
editor.cancel(&Default::default(), window, cx);
|
editor.cancel(&Default::default(), window, cx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -231,8 +231,8 @@ impl InlineAssistant {
|
||||||
);
|
);
|
||||||
|
|
||||||
if DisableAiSettings::get_global(cx).disable_ai {
|
if DisableAiSettings::get_global(cx).disable_ai {
|
||||||
// Cancel any active completions
|
// Cancel any active edit predictions
|
||||||
if editor.has_active_inline_completion() {
|
if editor.has_active_edit_prediction() {
|
||||||
editor.cancel(&Default::default(), window, cx);
|
editor.cancel(&Default::default(), window, cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use assistant_slash_commands::{
|
||||||
use client::{proto, zed_urls};
|
use client::{proto, zed_urls};
|
||||||
use collections::{BTreeSet, HashMap, HashSet, hash_map};
|
use collections::{BTreeSet, HashMap, HashSet, hash_map};
|
||||||
use editor::{
|
use editor::{
|
||||||
Anchor, Editor, EditorEvent, MenuInlineCompletionsPolicy, MultiBuffer, MultiBufferSnapshot,
|
Anchor, Editor, EditorEvent, MenuEditPredictionsPolicy, MultiBuffer, MultiBufferSnapshot,
|
||||||
RowExt, ToOffset as _, ToPoint,
|
RowExt, ToOffset as _, ToPoint,
|
||||||
actions::{MoveToEndOfLine, Newline, ShowCompletions},
|
actions::{MoveToEndOfLine, Newline, ShowCompletions},
|
||||||
display_map::{
|
display_map::{
|
||||||
|
@ -254,7 +254,7 @@ impl TextThreadEditor {
|
||||||
editor.set_show_wrap_guides(false, cx);
|
editor.set_show_wrap_guides(false, cx);
|
||||||
editor.set_show_indent_guides(false, cx);
|
editor.set_show_indent_guides(false, cx);
|
||||||
editor.set_completion_provider(Some(Rc::new(completion_provider)));
|
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()));
|
editor.set_collaboration_hub(Box::new(project.clone()));
|
||||||
|
|
||||||
let show_edit_predictions = all_language_settings(None, cx)
|
let show_edit_predictions = all_language_settings(None, cx)
|
||||||
|
|
|
@ -580,7 +580,7 @@ fn for_snowflake(
|
||||||
},
|
},
|
||||||
serde_json::to_value(e).unwrap(),
|
serde_json::to_value(e).unwrap(),
|
||||||
),
|
),
|
||||||
Event::InlineCompletion(e) => (
|
Event::EditPrediction(e) => (
|
||||||
format!(
|
format!(
|
||||||
"Edit Prediction {}",
|
"Edit Prediction {}",
|
||||||
if e.suggestion_accepted {
|
if e.suggestion_accepted {
|
||||||
|
@ -591,7 +591,7 @@ fn for_snowflake(
|
||||||
),
|
),
|
||||||
serde_json::to_value(e).unwrap(),
|
serde_json::to_value(e).unwrap(),
|
||||||
),
|
),
|
||||||
Event::InlineCompletionRating(e) => (
|
Event::EditPredictionRating(e) => (
|
||||||
"Edit Prediction Rated".to_string(),
|
"Edit Prediction Rated".to_string(),
|
||||||
serde_json::to_value(e).unwrap(),
|
serde_json::to_value(e).unwrap(),
|
||||||
),
|
),
|
||||||
|
|
|
@ -34,7 +34,7 @@ fs.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
http_client.workspace = true
|
http_client.workspace = true
|
||||||
inline_completion.workspace = true
|
edit_prediction.workspace = true
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
lsp.workspace = true
|
lsp.workspace = true
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{Completion, Copilot};
|
use crate::{Completion, Copilot};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use edit_prediction::{Direction, EditPrediction, EditPredictionProvider};
|
||||||
use gpui::{App, Context, Entity, EntityId, Task};
|
use gpui::{App, Context, Entity, EntityId, Task};
|
||||||
use inline_completion::{Direction, EditPredictionProvider, InlineCompletion};
|
|
||||||
use language::{Buffer, OffsetRangeExt, ToOffset, language_settings::AllLanguageSettings};
|
use language::{Buffer, OffsetRangeExt, ToOffset, language_settings::AllLanguageSettings};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
|
@ -210,7 +210,7 @@ impl EditPredictionProvider for CopilotCompletionProvider {
|
||||||
buffer: &Entity<Buffer>,
|
buffer: &Entity<Buffer>,
|
||||||
cursor_position: language::Anchor,
|
cursor_position: language::Anchor,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Option<InlineCompletion> {
|
) -> Option<EditPrediction> {
|
||||||
let buffer_id = buffer.entity_id();
|
let buffer_id = buffer.entity_id();
|
||||||
let buffer = buffer.read(cx);
|
let buffer = buffer.read(cx);
|
||||||
let completion = self.active_completion()?;
|
let completion = self.active_completion()?;
|
||||||
|
@ -241,7 +241,7 @@ impl EditPredictionProvider for CopilotCompletionProvider {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let position = cursor_position.bias_right(buffer);
|
let position = cursor_position.bias_right(buffer);
|
||||||
Some(InlineCompletion {
|
Some(EditPrediction {
|
||||||
id: None,
|
id: None,
|
||||||
edits: vec![(position..position, completion_text.into())],
|
edits: vec![(position..position, completion_text.into())],
|
||||||
edit_preview: None,
|
edit_preview: None,
|
||||||
|
@ -343,7 +343,7 @@ mod tests {
|
||||||
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
||||||
cx.update_editor(|editor, window, cx| {
|
cx.update_editor(|editor, window, cx| {
|
||||||
assert!(editor.context_menu_visible());
|
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
|
// Since we have both, the copilot suggestion is not shown inline
|
||||||
assert_eq!(editor.text(cx), "one.\ntwo\nthree\n");
|
assert_eq!(editor.text(cx), "one.\ntwo\nthree\n");
|
||||||
assert_eq!(editor.display_text(cx), "one.\ntwo\nthree\n");
|
assert_eq!(editor.display_text(cx), "one.\ntwo\nthree\n");
|
||||||
|
@ -355,7 +355,7 @@ mod tests {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.detach();
|
.detach();
|
||||||
assert!(!editor.context_menu_visible());
|
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.text(cx), "one.completion_a\ntwo\nthree\n");
|
||||||
assert_eq!(editor.display_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);
|
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
||||||
cx.update_editor(|editor, _, cx| {
|
cx.update_editor(|editor, _, cx| {
|
||||||
assert!(!editor.context_menu_visible());
|
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
|
// Since only the copilot is available, it's shown inline
|
||||||
assert_eq!(editor.display_text(cx), "one.copilot1\ntwo\nthree\n");
|
assert_eq!(editor.display_text(cx), "one.copilot1\ntwo\nthree\n");
|
||||||
assert_eq!(editor.text(cx), "one.\ntwo\nthree\n");
|
assert_eq!(editor.text(cx), "one.\ntwo\nthree\n");
|
||||||
|
@ -400,7 +400,7 @@ mod tests {
|
||||||
executor.run_until_parked();
|
executor.run_until_parked();
|
||||||
cx.update_editor(|editor, _, cx| {
|
cx.update_editor(|editor, _, cx| {
|
||||||
assert!(!editor.context_menu_visible());
|
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.display_text(cx), "one.copilot1\ntwo\nthree\n");
|
||||||
assert_eq!(editor.text(cx), "one.c\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);
|
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
||||||
cx.update_editor(|editor, window, cx| {
|
cx.update_editor(|editor, window, cx| {
|
||||||
assert!(!editor.context_menu_visible());
|
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.display_text(cx), "one.copilot2\ntwo\nthree\n");
|
||||||
assert_eq!(editor.text(cx), "one.c\ntwo\nthree\n");
|
assert_eq!(editor.text(cx), "one.c\ntwo\nthree\n");
|
||||||
|
|
||||||
// Canceling should remove the active Copilot suggestion.
|
// Canceling should remove the active Copilot suggestion.
|
||||||
editor.cancel(&Default::default(), window, cx);
|
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.display_text(cx), "one.c\ntwo\nthree\n");
|
||||||
assert_eq!(editor.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.
|
// After canceling, tabbing shouldn't insert the previously shown suggestion.
|
||||||
editor.tab(&Default::default(), window, cx);
|
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.display_text(cx), "one.c \ntwo\nthree\n");
|
||||||
assert_eq!(editor.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.
|
// When undoing the previously active suggestion is shown again.
|
||||||
editor.undo(&Default::default(), window, cx);
|
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.display_text(cx), "one.copilot2\ntwo\nthree\n");
|
||||||
assert_eq!(editor.text(cx), "one.c\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.
|
// 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_buffer(|buffer, cx| buffer.edit([(5..5, "o")], None, cx));
|
||||||
cx.update_editor(|editor, window, 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.display_text(cx), "one.copilot2\ntwo\nthree\n");
|
||||||
assert_eq!(editor.text(cx), "one.co\ntwo\nthree\n");
|
assert_eq!(editor.text(cx), "one.co\ntwo\nthree\n");
|
||||||
|
|
||||||
// AcceptEditPrediction when there is an active suggestion inserts it.
|
// AcceptEditPrediction when there is an active suggestion inserts it.
|
||||||
editor.accept_edit_prediction(&Default::default(), window, cx);
|
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.display_text(cx), "one.copilot2\ntwo\nthree\n");
|
||||||
assert_eq!(editor.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.
|
// When undoing the previously active suggestion is shown again.
|
||||||
editor.undo(&Default::default(), window, cx);
|
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.display_text(cx), "one.copilot2\ntwo\nthree\n");
|
||||||
assert_eq!(editor.text(cx), "one.co\ntwo\nthree\n");
|
assert_eq!(editor.text(cx), "one.co\ntwo\nthree\n");
|
||||||
|
|
||||||
// Hide suggestion.
|
// Hide suggestion.
|
||||||
editor.cancel(&Default::default(), window, cx);
|
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.display_text(cx), "one.co\ntwo\nthree\n");
|
||||||
assert_eq!(editor.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.
|
// we won't make it visible.
|
||||||
cx.update_buffer(|buffer, cx| buffer.edit([(6..6, "p")], None, cx));
|
cx.update_buffer(|buffer, cx| buffer.edit([(6..6, "p")], None, cx));
|
||||||
cx.update_editor(|editor, _, 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.display_text(cx), "one.cop\ntwo\nthree\n");
|
||||||
assert_eq!(editor.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);
|
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
||||||
cx.update_editor(|editor, window, 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), "fn foo() {\n let x = 4;\n}");
|
assert_eq!(editor.display_text(cx), "fn foo() {\n let x = 4;\n}");
|
||||||
assert_eq!(editor.text(cx), "fn foo() {\n \n}");
|
assert_eq!(editor.text(cx), "fn foo() {\n \n}");
|
||||||
|
|
||||||
// Tabbing inside of leading whitespace inserts indentation without accepting the suggestion.
|
// Tabbing inside of leading whitespace inserts indentation without accepting the suggestion.
|
||||||
editor.tab(&Default::default(), window, cx);
|
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.text(cx), "fn foo() {\n \n}");
|
||||||
assert_eq!(editor.display_text(cx), "fn foo() {\n let x = 4;\n}");
|
assert_eq!(editor.display_text(cx), "fn foo() {\n let x = 4;\n}");
|
||||||
|
|
||||||
// Using AcceptEditPrediction again accepts the suggestion.
|
// Using AcceptEditPrediction again accepts the suggestion.
|
||||||
editor.accept_edit_prediction(&Default::default(), window, cx);
|
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.text(cx), "fn foo() {\n let x = 4;\n}");
|
||||||
assert_eq!(editor.display_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);
|
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
||||||
cx.update_editor(|editor, window, cx| {
|
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.
|
// 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);
|
editor.accept_partial_edit_prediction(&Default::default(), window, cx);
|
||||||
assert!(editor.has_active_inline_completion());
|
assert!(editor.has_active_edit_prediction());
|
||||||
assert_eq!(editor.text(cx), "one.copilot\ntwo\nthree\n");
|
assert_eq!(editor.text(cx), "one.copilot\ntwo\nthree\n");
|
||||||
assert_eq!(editor.display_text(cx), "one.copilot1\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
|
// Accepting next word should accept the non-word and copilot suggestion should be gone
|
||||||
editor.accept_partial_inline_completion(&Default::default(), window, cx);
|
editor.accept_partial_edit_prediction(&Default::default(), window, cx);
|
||||||
assert!(!editor.has_active_inline_completion());
|
assert!(!editor.has_active_edit_prediction());
|
||||||
assert_eq!(editor.text(cx), "one.copilot1\ntwo\nthree\n");
|
assert_eq!(editor.text(cx), "one.copilot1\ntwo\nthree\n");
|
||||||
assert_eq!(editor.display_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);
|
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
||||||
cx.update_editor(|editor, window, cx| {
|
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.
|
// 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);
|
editor.accept_partial_edit_prediction(&Default::default(), window, cx);
|
||||||
assert!(editor.has_active_inline_completion());
|
assert!(editor.has_active_edit_prediction());
|
||||||
assert_eq!(editor.text(cx), "one.123. \ntwo\nthree\n");
|
assert_eq!(editor.text(cx), "one.123. \ntwo\nthree\n");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.display_text(cx),
|
editor.display_text(cx),
|
||||||
|
@ -629,8 +629,8 @@ mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Accepting next word should accept the next word and copilot suggestion should still exist
|
// Accepting next word should accept the next word and copilot suggestion should still exist
|
||||||
editor.accept_partial_inline_completion(&Default::default(), window, cx);
|
editor.accept_partial_edit_prediction(&Default::default(), window, cx);
|
||||||
assert!(editor.has_active_inline_completion());
|
assert!(editor.has_active_edit_prediction());
|
||||||
assert_eq!(editor.text(cx), "one.123. copilot\ntwo\nthree\n");
|
assert_eq!(editor.text(cx), "one.123. copilot\ntwo\nthree\n");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.display_text(cx),
|
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
|
// 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);
|
editor.accept_partial_edit_prediction(&Default::default(), window, cx);
|
||||||
assert!(!editor.has_active_inline_completion());
|
assert!(!editor.has_active_edit_prediction());
|
||||||
assert_eq!(editor.text(cx), "one.123. copilot\n 456\ntwo\nthree\n");
|
assert_eq!(editor.text(cx), "one.123. copilot\n 456\ntwo\nthree\n");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.display_text(cx),
|
editor.display_text(cx),
|
||||||
|
@ -692,29 +692,29 @@ mod tests {
|
||||||
});
|
});
|
||||||
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
||||||
cx.update_editor(|editor, window, 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\ntwo.foo()\nthree\n");
|
assert_eq!(editor.display_text(cx), "one\ntwo.foo()\nthree\n");
|
||||||
assert_eq!(editor.text(cx), "one\ntw\nthree\n");
|
assert_eq!(editor.text(cx), "one\ntw\nthree\n");
|
||||||
|
|
||||||
editor.backspace(&Default::default(), window, cx);
|
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.display_text(cx), "one\ntwo.foo()\nthree\n");
|
||||||
assert_eq!(editor.text(cx), "one\nt\nthree\n");
|
assert_eq!(editor.text(cx), "one\nt\nthree\n");
|
||||||
|
|
||||||
editor.backspace(&Default::default(), window, cx);
|
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.display_text(cx), "one\ntwo.foo()\nthree\n");
|
||||||
assert_eq!(editor.text(cx), "one\n\nthree\n");
|
assert_eq!(editor.text(cx), "one\n\nthree\n");
|
||||||
|
|
||||||
// Deleting across the original suggestion range invalidates it.
|
// Deleting across the original suggestion range invalidates it.
|
||||||
editor.backspace(&Default::default(), window, cx);
|
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.display_text(cx), "one\nthree\n");
|
||||||
assert_eq!(editor.text(cx), "one\nthree\n");
|
assert_eq!(editor.text(cx), "one\nthree\n");
|
||||||
|
|
||||||
// Undoing the deletion restores the suggestion.
|
// Undoing the deletion restores the suggestion.
|
||||||
editor.undo(&Default::default(), window, cx);
|
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.display_text(cx), "one\ntwo.foo()\nthree\n");
|
||||||
assert_eq!(editor.text(cx), "one\n\nthree\n");
|
assert_eq!(editor.text(cx), "one\n\nthree\n");
|
||||||
});
|
});
|
||||||
|
@ -775,7 +775,7 @@ mod tests {
|
||||||
});
|
});
|
||||||
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
||||||
_ = editor.update(cx, |editor, _, cx| {
|
_ = editor.update(cx, |editor, _, cx| {
|
||||||
assert!(editor.has_active_inline_completion());
|
assert!(editor.has_active_edit_prediction());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.display_text(cx),
|
editor.display_text(cx),
|
||||||
"\n\na = 1\nb = 2 + a\n\n\n\nc = 3\nd = 4\n"
|
"\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| {
|
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||||
s.select_ranges([Point::new(4, 5)..Point::new(4, 5)])
|
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!(
|
assert_eq!(
|
||||||
editor.display_text(cx),
|
editor.display_text(cx),
|
||||||
"\n\na = 1\nb = 2\n\n\n\nc = 3\nd = 4\n"
|
"\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.
|
// Type a character, ensuring we don't even try to interpolate the previous suggestion.
|
||||||
editor.handle_input(" ", window, cx);
|
editor.handle_input(" ", window, cx);
|
||||||
assert!(!editor.has_active_inline_completion());
|
assert!(!editor.has_active_edit_prediction());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.display_text(cx),
|
editor.display_text(cx),
|
||||||
"\n\na = 1\nb = 2\n\n\n\nc = 3\nd = 4 \n"
|
"\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.
|
// Ensure the new suggestion is displayed when the debounce timeout expires.
|
||||||
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
||||||
_ = editor.update(cx, |editor, _, cx| {
|
_ = editor.update(cx, |editor, _, cx| {
|
||||||
assert!(editor.has_active_inline_completion());
|
assert!(editor.has_active_edit_prediction());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.display_text(cx),
|
editor.display_text(cx),
|
||||||
"\n\na = 1\nb = 2\n\n\n\nc = 3\nd = 4 + c\n"
|
"\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);
|
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
||||||
cx.update_editor(|editor, _, cx| {
|
cx.update_editor(|editor, _, cx| {
|
||||||
assert!(!editor.context_menu_visible());
|
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.display_text(cx), "one\ntwo.foo()\nthree\n");
|
||||||
assert_eq!(editor.text(cx), "one\ntw\nthree\n");
|
assert_eq!(editor.text(cx), "one\ntw\nthree\n");
|
||||||
});
|
});
|
||||||
|
@ -907,7 +907,7 @@ mod tests {
|
||||||
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
||||||
cx.update_editor(|editor, _, cx| {
|
cx.update_editor(|editor, _, cx| {
|
||||||
assert!(!editor.context_menu_visible());
|
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.display_text(cx), "one\ntwo.foo()\nthree\n");
|
||||||
assert_eq!(editor.text(cx), "one\ntwo\nthree\n");
|
assert_eq!(editor.text(cx), "one\ntwo\nthree\n");
|
||||||
});
|
});
|
||||||
|
@ -934,7 +934,7 @@ mod tests {
|
||||||
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
||||||
cx.update_editor(|editor, _, cx| {
|
cx.update_editor(|editor, _, cx| {
|
||||||
assert!(editor.context_menu_visible());
|
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");
|
assert_eq!(editor.text(cx), "one\ntwo.\nthree\n");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1023,7 +1023,7 @@ mod tests {
|
||||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |selections| {
|
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |selections| {
|
||||||
selections.select_ranges([Point::new(0, 0)..Point::new(0, 0)])
|
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);
|
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
||||||
|
@ -1033,7 +1033,7 @@ mod tests {
|
||||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||||
s.select_ranges([Point::new(5, 0)..Point::new(5, 0)])
|
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);
|
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
|
||||||
|
|
|
@ -873,7 +873,7 @@ async fn test_random_diagnostics_with_inlays(cx: &mut TestAppContext, mut rng: S
|
||||||
|
|
||||||
editor.splice_inlays(
|
editor.splice_inlays(
|
||||||
&[],
|
&[],
|
||||||
vec![Inlay::inline_completion(
|
vec![Inlay::edit_prediction(
|
||||||
post_inc(&mut next_inlay_id),
|
post_inc(&mut next_inlay_id),
|
||||||
snapshot.buffer_snapshot.anchor_before(position),
|
snapshot.buffer_snapshot.anchor_before(position),
|
||||||
format!("Test inlay {next_inlay_id}"),
|
format!("Test inlay {next_inlay_id}"),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "inline_completion"
|
name = "edit_prediction"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
publish.workspace = true
|
publish.workspace = true
|
||||||
|
@ -9,7 +9,7 @@ license = "GPL-3.0-or-later"
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "src/inline_completion.rs"
|
path = "src/edit_prediction.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
client.workspace = true
|
client.workspace = true
|
|
@ -7,7 +7,7 @@ use project::Project;
|
||||||
|
|
||||||
// TODO: Find a better home for `Direction`.
|
// 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.
|
// but at time of writing there isn't an obvious spot.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
pub enum Direction {
|
pub enum Direction {
|
||||||
|
@ -16,7 +16,7 @@ pub enum Direction {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct InlineCompletion {
|
pub struct EditPrediction {
|
||||||
/// The ID of the completion, if it has one.
|
/// The ID of the completion, if it has one.
|
||||||
pub id: Option<SharedString>,
|
pub id: Option<SharedString>,
|
||||||
pub edits: Vec<(Range<language::Anchor>, String)>,
|
pub edits: Vec<(Range<language::Anchor>, String)>,
|
||||||
|
@ -102,10 +102,10 @@ pub trait EditPredictionProvider: 'static + Sized {
|
||||||
buffer: &Entity<Buffer>,
|
buffer: &Entity<Buffer>,
|
||||||
cursor_position: language::Anchor,
|
cursor_position: language::Anchor,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Option<InlineCompletion>;
|
) -> Option<EditPrediction>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait InlineCompletionProviderHandle {
|
pub trait EditPredictionProviderHandle {
|
||||||
fn name(&self) -> &'static str;
|
fn name(&self) -> &'static str;
|
||||||
fn display_name(&self) -> &'static str;
|
fn display_name(&self) -> &'static str;
|
||||||
fn is_enabled(
|
fn is_enabled(
|
||||||
|
@ -143,10 +143,10 @@ pub trait InlineCompletionProviderHandle {
|
||||||
buffer: &Entity<Buffer>,
|
buffer: &Entity<Buffer>,
|
||||||
cursor_position: language::Anchor,
|
cursor_position: language::Anchor,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Option<InlineCompletion>;
|
) -> Option<EditPrediction>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> InlineCompletionProviderHandle for Entity<T>
|
impl<T> EditPredictionProviderHandle for Entity<T>
|
||||||
where
|
where
|
||||||
T: EditPredictionProvider,
|
T: EditPredictionProvider,
|
||||||
{
|
{
|
||||||
|
@ -233,7 +233,7 @@ where
|
||||||
buffer: &Entity<Buffer>,
|
buffer: &Entity<Buffer>,
|
||||||
cursor_position: language::Anchor,
|
cursor_position: language::Anchor,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Option<InlineCompletion> {
|
) -> Option<EditPrediction> {
|
||||||
self.update(cx, |this, cx| this.suggest(buffer, cursor_position, cx))
|
self.update(cx, |this, cx| this.suggest(buffer, cursor_position, cx))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "inline_completion_button"
|
name = "edit_prediction_button"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
publish.workspace = true
|
publish.workspace = true
|
||||||
|
@ -9,7 +9,7 @@ license = "GPL-3.0-or-later"
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "src/inline_completion_button.rs"
|
path = "src/edit_prediction_button.rs"
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -22,7 +22,7 @@ feature_flags.workspace = true
|
||||||
fs.workspace = true
|
fs.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
indoc.workspace = true
|
indoc.workspace = true
|
||||||
inline_completion.workspace = true
|
edit_prediction.workspace = true
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
paths.workspace = true
|
paths.workspace = true
|
||||||
project.workspace = true
|
project.workspace = true
|
|
@ -41,7 +41,7 @@ use zeta::RateCompletions;
|
||||||
actions!(
|
actions!(
|
||||||
edit_prediction,
|
edit_prediction,
|
||||||
[
|
[
|
||||||
/// Toggles the inline completion menu.
|
/// Toggles the edit prediction menu.
|
||||||
ToggleMenu
|
ToggleMenu
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -51,14 +51,14 @@ const PRIVACY_DOCS: &str = "https://zed.dev/docs/ai/privacy-and-security";
|
||||||
|
|
||||||
struct CopilotErrorToast;
|
struct CopilotErrorToast;
|
||||||
|
|
||||||
pub struct InlineCompletionButton {
|
pub struct EditPredictionButton {
|
||||||
editor_subscription: Option<(Subscription, usize)>,
|
editor_subscription: Option<(Subscription, usize)>,
|
||||||
editor_enabled: Option<bool>,
|
editor_enabled: Option<bool>,
|
||||||
editor_show_predictions: bool,
|
editor_show_predictions: bool,
|
||||||
editor_focus_handle: Option<FocusHandle>,
|
editor_focus_handle: Option<FocusHandle>,
|
||||||
language: Option<Arc<Language>>,
|
language: Option<Arc<Language>>,
|
||||||
file: Option<Arc<dyn File>>,
|
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>,
|
fs: Arc<dyn Fs>,
|
||||||
user_store: Entity<UserStore>,
|
user_store: Entity<UserStore>,
|
||||||
popover_menu_handle: PopoverMenuHandle<ContextMenu>,
|
popover_menu_handle: PopoverMenuHandle<ContextMenu>,
|
||||||
|
@ -71,7 +71,7 @@ enum SupermavenButtonStatus {
|
||||||
Initializing,
|
Initializing,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for InlineCompletionButton {
|
impl Render for EditPredictionButton {
|
||||||
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
// Return empty div if AI is disabled
|
// Return empty div if AI is disabled
|
||||||
if DisableAiSettings::get_global(cx).disable_ai {
|
if DisableAiSettings::get_global(cx).disable_ai {
|
||||||
|
@ -369,7 +369,7 @@ impl Render for InlineCompletionButton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InlineCompletionButton {
|
impl EditPredictionButton {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
user_store: Entity<UserStore>,
|
user_store: Entity<UserStore>,
|
||||||
|
@ -470,7 +470,7 @@ impl InlineCompletionButton {
|
||||||
IconPosition::Start,
|
IconPosition::Start,
|
||||||
None,
|
None,
|
||||||
move |_, cx| {
|
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);
|
let globally_enabled = settings.show_edit_predictions(None, cx);
|
||||||
menu = menu.toggleable_entry("All Files", globally_enabled, IconPosition::Start, None, {
|
menu = menu.toggleable_entry("All Files", globally_enabled, IconPosition::Start, None, {
|
||||||
let fs = fs.clone();
|
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;
|
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(
|
fn set_active_pane_item(
|
||||||
&mut self,
|
&mut self,
|
||||||
item: Option<&dyn ItemHandle>,
|
item: Option<&dyn ItemHandle>,
|
||||||
|
@ -905,7 +905,7 @@ async fn open_disabled_globs_setting_in_editor(
|
||||||
|
|
||||||
let settings = cx.global::<SettingsStore>();
|
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| {
|
let edits = settings.edits_for_update::<AllLanguageSettings>(&text, |file| {
|
||||||
file.edit_predictions
|
file.edit_predictions
|
||||||
.get_or_insert_with(Default::default)
|
.get_or_insert_with(Default::default)
|
||||||
|
@ -943,7 +943,7 @@ async fn open_disabled_globs_setting_in_editor(
|
||||||
anyhow::Ok(())
|
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);
|
let show_edit_predictions = all_language_settings(None, cx).show_edit_predictions(None, cx);
|
||||||
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
|
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
|
||||||
file.defaults.show_edit_predictions = Some(!show_edit_predictions)
|
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>,
|
language: Arc<Language>,
|
||||||
fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
|
@ -48,7 +48,7 @@ fs.workspace = true
|
||||||
git.workspace = true
|
git.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
indoc.workspace = true
|
indoc.workspace = true
|
||||||
inline_completion.workspace = true
|
edit_prediction.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
linkify.workspace = true
|
linkify.workspace = true
|
||||||
|
|
|
@ -635,7 +635,7 @@ pub(crate) struct Highlights<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct InlineCompletionStyles {
|
pub struct EditPredictionStyles {
|
||||||
pub insertion: HighlightStyle,
|
pub insertion: HighlightStyle,
|
||||||
pub whitespace: HighlightStyle,
|
pub whitespace: HighlightStyle,
|
||||||
}
|
}
|
||||||
|
@ -643,7 +643,7 @@ pub struct InlineCompletionStyles {
|
||||||
#[derive(Default, Debug, Clone, Copy)]
|
#[derive(Default, Debug, Clone, Copy)]
|
||||||
pub struct HighlightStyles {
|
pub struct HighlightStyles {
|
||||||
pub inlay_hint: Option<HighlightStyle>,
|
pub inlay_hint: Option<HighlightStyle>,
|
||||||
pub inline_completion: Option<InlineCompletionStyles>,
|
pub edit_prediction: Option<EditPredictionStyles>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -958,7 +958,7 @@ impl DisplaySnapshot {
|
||||||
language_aware,
|
language_aware,
|
||||||
HighlightStyles {
|
HighlightStyles {
|
||||||
inlay_hint: Some(editor_style.inlay_hints_style),
|
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| {
|
.flat_map(|chunk| {
|
||||||
|
@ -2036,7 +2036,7 @@ pub mod tests {
|
||||||
map.update(cx, |map, cx| {
|
map.update(cx, |map, cx| {
|
||||||
map.splice_inlays(
|
map.splice_inlays(
|
||||||
&[],
|
&[],
|
||||||
vec![Inlay::inline_completion(
|
vec![Inlay::edit_prediction(
|
||||||
0,
|
0,
|
||||||
buffer_snapshot.anchor_after(0),
|
buffer_snapshot.anchor_after(0),
|
||||||
"\n",
|
"\n",
|
||||||
|
|
|
@ -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 {
|
Self {
|
||||||
id: InlayId::InlineCompletion(id),
|
id: InlayId::EditPrediction(id),
|
||||||
position,
|
position,
|
||||||
text: text.into(),
|
text: text.into(),
|
||||||
color: None,
|
color: None,
|
||||||
|
@ -340,15 +340,13 @@ impl<'a> Iterator for InlayChunks<'a> {
|
||||||
|
|
||||||
let mut renderer = None;
|
let mut renderer = None;
|
||||||
let mut highlight_style = match inlay.id {
|
let mut highlight_style = match inlay.id {
|
||||||
InlayId::InlineCompletion(_) => {
|
InlayId::EditPrediction(_) => self.highlight_styles.edit_prediction.map(|s| {
|
||||||
self.highlight_styles.inline_completion.map(|s| {
|
if inlay.text.chars().all(|c| c.is_whitespace()) {
|
||||||
if inlay.text.chars().all(|c| c.is_whitespace()) {
|
s.whitespace
|
||||||
s.whitespace
|
} else {
|
||||||
} else {
|
s.insertion
|
||||||
s.insertion
|
}
|
||||||
}
|
}),
|
||||||
})
|
|
||||||
}
|
|
||||||
InlayId::Hint(_) => self.highlight_styles.inlay_hint,
|
InlayId::Hint(_) => self.highlight_styles.inlay_hint,
|
||||||
InlayId::DebuggerValue(_) => self.highlight_styles.inlay_hint,
|
InlayId::DebuggerValue(_) => self.highlight_styles.inlay_hint,
|
||||||
InlayId::Color(_) => {
|
InlayId::Color(_) => {
|
||||||
|
@ -740,7 +738,7 @@ impl InlayMap {
|
||||||
text.clone(),
|
text.clone(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Inlay::inline_completion(
|
Inlay::edit_prediction(
|
||||||
post_inc(next_inlay_id),
|
post_inc(next_inlay_id),
|
||||||
snapshot.buffer.anchor_at(position, bias),
|
snapshot.buffer.anchor_at(position, bias),
|
||||||
text.clone(),
|
text.clone(),
|
||||||
|
@ -1389,7 +1387,7 @@ mod tests {
|
||||||
buffer.read(cx).snapshot(cx).anchor_before(3),
|
buffer.read(cx).snapshot(cx).anchor_before(3),
|
||||||
"|123|",
|
"|123|",
|
||||||
),
|
),
|
||||||
Inlay::inline_completion(
|
Inlay::edit_prediction(
|
||||||
post_inc(&mut next_inlay_id),
|
post_inc(&mut next_inlay_id),
|
||||||
buffer.read(cx).snapshot(cx).anchor_after(3),
|
buffer.read(cx).snapshot(cx).anchor_after(3),
|
||||||
"|456|",
|
"|456|",
|
||||||
|
@ -1609,7 +1607,7 @@ mod tests {
|
||||||
buffer.read(cx).snapshot(cx).anchor_before(4),
|
buffer.read(cx).snapshot(cx).anchor_before(4),
|
||||||
"|456|",
|
"|456|",
|
||||||
),
|
),
|
||||||
Inlay::inline_completion(
|
Inlay::edit_prediction(
|
||||||
post_inc(&mut next_inlay_id),
|
post_inc(&mut next_inlay_id),
|
||||||
buffer.read(cx).snapshot(cx).anchor_before(7),
|
buffer.read(cx).snapshot(cx).anchor_before(7),
|
||||||
"\n|567|\n",
|
"\n|567|\n",
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
|
use edit_prediction::EditPredictionProvider;
|
||||||
use gpui::{Entity, prelude::*};
|
use gpui::{Entity, prelude::*};
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
use inline_completion::EditPredictionProvider;
|
|
||||||
use multi_buffer::{Anchor, MultiBufferSnapshot, ToPoint};
|
use multi_buffer::{Anchor, MultiBufferSnapshot, ToPoint};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use text::{Point, ToOffset};
|
use text::{Point, ToOffset};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
InlineCompletion, editor_tests::init_test, test::editor_test_context::EditorTestContext,
|
EditPrediction, editor_tests::init_test, test::editor_test_context::EditorTestContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[gpui::test]
|
#[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, |_| {});
|
init_test(cx, |_| {});
|
||||||
|
|
||||||
let mut cx = EditorTestContext::new(cx).await;
|
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);
|
assign_editor_completion_provider(provider.clone(), &mut cx);
|
||||||
cx.set_state("let absolute_zero_celsius = ˇ;");
|
cx.set_state("let absolute_zero_celsius = ˇ;");
|
||||||
|
|
||||||
propose_edits(&provider, vec![(28..28, "-273.15")], &mut cx);
|
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_editor_active_edit_completion(&mut cx, |_, edits| {
|
||||||
assert_eq!(edits.len(), 1);
|
assert_eq!(edits.len(), 1);
|
||||||
|
@ -33,16 +33,16 @@ async fn test_inline_completion_insert(cx: &mut gpui::TestAppContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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, |_| {});
|
init_test(cx, |_| {});
|
||||||
|
|
||||||
let mut cx = EditorTestContext::new(cx).await;
|
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);
|
assign_editor_completion_provider(provider.clone(), &mut cx);
|
||||||
cx.set_state("let pi = ˇ\"foo\";");
|
cx.set_state("let pi = ˇ\"foo\";");
|
||||||
|
|
||||||
propose_edits(&provider, vec![(9..14, "3.14159")], &mut cx);
|
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_editor_active_edit_completion(&mut cx, |_, edits| {
|
||||||
assert_eq!(edits.len(), 1);
|
assert_eq!(edits.len(), 1);
|
||||||
|
@ -55,11 +55,11 @@ async fn test_inline_completion_modification(cx: &mut gpui::TestAppContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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, |_| {});
|
init_test(cx, |_| {});
|
||||||
|
|
||||||
let mut cx = EditorTestContext::new(cx).await;
|
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);
|
assign_editor_completion_provider(provider.clone(), &mut cx);
|
||||||
|
|
||||||
// Cursor is 2+ lines above the proposed edit
|
// 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,
|
&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_editor_active_move_completion(&mut cx, |snapshot, move_target| {
|
||||||
assert_eq!(move_target.to_point(&snapshot), Point::new(4, 3));
|
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,
|
&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_editor_active_move_completion(&mut cx, |snapshot, move_target| {
|
||||||
assert_eq!(move_target.to_point(&snapshot), Point::new(1, 3));
|
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]
|
#[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, |_| {});
|
init_test(cx, |_| {});
|
||||||
|
|
||||||
let mut cx = EditorTestContext::new(cx).await;
|
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);
|
assign_editor_completion_provider(provider.clone(), &mut cx);
|
||||||
|
|
||||||
// Cursor is 3+ lines above the proposed edit
|
// 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,
|
&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_editor_active_move_completion(&mut cx, |snapshot, move_target| {
|
||||||
assert_eq!(move_target.to_point(&snapshot), edit_location);
|
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
|
line
|
||||||
"});
|
"});
|
||||||
cx.editor(|editor, _, _| {
|
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
|
// 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,
|
&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_editor_active_move_completion(&mut cx, |snapshot, move_target| {
|
||||||
assert_eq!(move_target.to_point(&snapshot), edit_location);
|
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
|
line ˇ5
|
||||||
"});
|
"});
|
||||||
cx.editor(|editor, _, _| {
|
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| {
|
cx.editor(|editor, _, cx| {
|
||||||
let completion_state = editor
|
let completion_state = editor
|
||||||
.active_inline_completion
|
.active_edit_prediction
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("editor has no active completion");
|
.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);
|
assert(editor.buffer().read(cx).snapshot(cx), edits);
|
||||||
} else {
|
} else {
|
||||||
panic!("expected edit completion");
|
panic!("expected edit completion");
|
||||||
|
@ -252,11 +252,11 @@ fn assert_editor_active_move_completion(
|
||||||
) {
|
) {
|
||||||
cx.editor(|editor, _, cx| {
|
cx.editor(|editor, _, cx| {
|
||||||
let completion_state = editor
|
let completion_state = editor
|
||||||
.active_inline_completion
|
.active_edit_prediction
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("editor has no active completion");
|
.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);
|
assert(editor.buffer().read(cx).snapshot(cx), *target);
|
||||||
} else {
|
} else {
|
||||||
panic!("expected move completion");
|
panic!("expected move completion");
|
||||||
|
@ -271,7 +271,7 @@ fn accept_completion(cx: &mut EditorTestContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn propose_edits<T: ToOffset>(
|
fn propose_edits<T: ToOffset>(
|
||||||
provider: &Entity<FakeInlineCompletionProvider>,
|
provider: &Entity<FakeEditPredictionProvider>,
|
||||||
edits: Vec<(Range<T>, &str)>,
|
edits: Vec<(Range<T>, &str)>,
|
||||||
cx: &mut EditorTestContext,
|
cx: &mut EditorTestContext,
|
||||||
) {
|
) {
|
||||||
|
@ -283,7 +283,7 @@ fn propose_edits<T: ToOffset>(
|
||||||
|
|
||||||
cx.update(|_, cx| {
|
cx.update(|_, cx| {
|
||||||
provider.update(cx, |provider, _| {
|
provider.update(cx, |provider, _| {
|
||||||
provider.set_inline_completion(Some(inline_completion::InlineCompletion {
|
provider.set_edit_prediction(Some(edit_prediction::EditPrediction {
|
||||||
id: None,
|
id: None,
|
||||||
edits: edits.collect(),
|
edits: edits.collect(),
|
||||||
edit_preview: None,
|
edit_preview: None,
|
||||||
|
@ -293,7 +293,7 @@ fn propose_edits<T: ToOffset>(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assign_editor_completion_provider(
|
fn assign_editor_completion_provider(
|
||||||
provider: Entity<FakeInlineCompletionProvider>,
|
provider: Entity<FakeEditPredictionProvider>,
|
||||||
cx: &mut EditorTestContext,
|
cx: &mut EditorTestContext,
|
||||||
) {
|
) {
|
||||||
cx.update_editor(|editor, window, cx| {
|
cx.update_editor(|editor, window, cx| {
|
||||||
|
@ -302,20 +302,17 @@ fn assign_editor_completion_provider(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Clone)]
|
#[derive(Default, Clone)]
|
||||||
pub struct FakeInlineCompletionProvider {
|
pub struct FakeEditPredictionProvider {
|
||||||
pub completion: Option<inline_completion::InlineCompletion>,
|
pub completion: Option<edit_prediction::EditPrediction>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FakeInlineCompletionProvider {
|
impl FakeEditPredictionProvider {
|
||||||
pub fn set_inline_completion(
|
pub fn set_edit_prediction(&mut self, completion: Option<edit_prediction::EditPrediction>) {
|
||||||
&mut self,
|
|
||||||
completion: Option<inline_completion::InlineCompletion>,
|
|
||||||
) {
|
|
||||||
self.completion = completion;
|
self.completion = completion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EditPredictionProvider for FakeInlineCompletionProvider {
|
impl EditPredictionProvider for FakeEditPredictionProvider {
|
||||||
fn name() -> &'static str {
|
fn name() -> &'static str {
|
||||||
"fake-completion-provider"
|
"fake-completion-provider"
|
||||||
}
|
}
|
||||||
|
@ -355,7 +352,7 @@ impl EditPredictionProvider for FakeInlineCompletionProvider {
|
||||||
&mut self,
|
&mut self,
|
||||||
_buffer: gpui::Entity<language::Buffer>,
|
_buffer: gpui::Entity<language::Buffer>,
|
||||||
_cursor_position: language::Anchor,
|
_cursor_position: language::Anchor,
|
||||||
_direction: inline_completion::Direction,
|
_direction: edit_prediction::Direction,
|
||||||
_cx: &mut gpui::Context<Self>,
|
_cx: &mut gpui::Context<Self>,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
@ -369,7 +366,7 @@ impl EditPredictionProvider for FakeInlineCompletionProvider {
|
||||||
_buffer: &gpui::Entity<language::Buffer>,
|
_buffer: &gpui::Entity<language::Buffer>,
|
||||||
_cursor_position: language::Anchor,
|
_cursor_position: language::Anchor,
|
||||||
_cx: &mut gpui::Context<Self>,
|
_cx: &mut gpui::Context<Self>,
|
||||||
) -> Option<inline_completion::InlineCompletion> {
|
) -> Option<edit_prediction::EditPrediction> {
|
||||||
self.completion.clone()
|
self.completion.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -43,15 +43,16 @@ pub mod tasks;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod code_completion_tests;
|
mod code_completion_tests;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod editor_tests;
|
mod edit_prediction_tests;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod inline_completion_tests;
|
mod editor_tests;
|
||||||
mod signature_help;
|
mod signature_help;
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub mod test;
|
pub mod test;
|
||||||
|
|
||||||
pub(crate) use actions::*;
|
pub(crate) use actions::*;
|
||||||
pub use display_map::{ChunkRenderer, ChunkRendererContext, DisplayPoint, FoldPlaceholder};
|
pub use display_map::{ChunkRenderer, ChunkRendererContext, DisplayPoint, FoldPlaceholder};
|
||||||
|
pub use edit_prediction::Direction;
|
||||||
pub use editor_settings::{
|
pub use editor_settings::{
|
||||||
CurrentLineHighlight, DocumentColorsRenderMode, EditorSettings, HideMouseMode,
|
CurrentLineHighlight, DocumentColorsRenderMode, EditorSettings, HideMouseMode,
|
||||||
ScrollBeyondLastLine, ScrollbarAxes, SearchSettings, ShowMinimap, ShowScrollbar,
|
ScrollBeyondLastLine, ScrollbarAxes, SearchSettings, ShowMinimap, ShowScrollbar,
|
||||||
|
@ -62,7 +63,6 @@ pub use element::{
|
||||||
};
|
};
|
||||||
pub use git::blame::BlameRenderer;
|
pub use git::blame::BlameRenderer;
|
||||||
pub use hover_popover::hover_markdown_style;
|
pub use hover_popover::hover_markdown_style;
|
||||||
pub use inline_completion::Direction;
|
|
||||||
pub use items::MAX_TAB_TITLE_LEN;
|
pub use items::MAX_TAB_TITLE_LEN;
|
||||||
pub use lsp::CompletionContext;
|
pub use lsp::CompletionContext;
|
||||||
pub use lsp_ext::lsp_tasks;
|
pub use lsp_ext::lsp_tasks;
|
||||||
|
@ -93,6 +93,7 @@ use collections::{BTreeMap, HashMap, HashSet, VecDeque};
|
||||||
use convert_case::{Case, Casing};
|
use convert_case::{Case, Casing};
|
||||||
use dap::TelemetrySpawnLocation;
|
use dap::TelemetrySpawnLocation;
|
||||||
use display_map::*;
|
use display_map::*;
|
||||||
|
use edit_prediction::{EditPredictionProvider, EditPredictionProviderHandle};
|
||||||
use editor_settings::{GoToDefinitionFallback, Minimap as MinimapSettings};
|
use editor_settings::{GoToDefinitionFallback, Minimap as MinimapSettings};
|
||||||
use element::{AcceptEditPredictionBinding, LineWithInvisibles, PositionMap, layout_line};
|
use element::{AcceptEditPredictionBinding, LineWithInvisibles, PositionMap, layout_line};
|
||||||
use futures::{
|
use futures::{
|
||||||
|
@ -117,7 +118,6 @@ use hover_links::{HoverLink, HoveredLinkState, InlayHighlight, find_file};
|
||||||
use hover_popover::{HoverState, hide_hover};
|
use hover_popover::{HoverState, hide_hover};
|
||||||
use indent_guides::ActiveIndentGuidesState;
|
use indent_guides::ActiveIndentGuidesState;
|
||||||
use inlay_hint_cache::{InlayHintCache, InlaySplice, InvalidationStrategy};
|
use inlay_hint_cache::{InlayHintCache, InlaySplice, InvalidationStrategy};
|
||||||
use inline_completion::{EditPredictionProvider, InlineCompletionProviderHandle};
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use language::{
|
use language::{
|
||||||
AutoindentMode, BlockCommentConfig, BracketMatch, BracketPair, Buffer, BufferRow,
|
AutoindentMode, BlockCommentConfig, BracketMatch, BracketPair, Buffer, BufferRow,
|
||||||
|
@ -268,7 +268,7 @@ impl InlineValueCache {
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub enum InlayId {
|
pub enum InlayId {
|
||||||
InlineCompletion(usize),
|
EditPrediction(usize),
|
||||||
DebuggerValue(usize),
|
DebuggerValue(usize),
|
||||||
// LSP
|
// LSP
|
||||||
Hint(usize),
|
Hint(usize),
|
||||||
|
@ -278,7 +278,7 @@ pub enum InlayId {
|
||||||
impl InlayId {
|
impl InlayId {
|
||||||
fn id(&self) -> usize {
|
fn id(&self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
Self::InlineCompletion(id) => *id,
|
Self::EditPrediction(id) => *id,
|
||||||
Self::DebuggerValue(id) => *id,
|
Self::DebuggerValue(id) => *id,
|
||||||
Self::Hint(id) => *id,
|
Self::Hint(id) => *id,
|
||||||
Self::Color(id) => *id,
|
Self::Color(id) => *id,
|
||||||
|
@ -547,7 +547,7 @@ pub struct EditorStyle {
|
||||||
pub syntax: Arc<SyntaxTheme>,
|
pub syntax: Arc<SyntaxTheme>,
|
||||||
pub status: StatusColors,
|
pub status: StatusColors,
|
||||||
pub inlay_hints_style: HighlightStyle,
|
pub inlay_hints_style: HighlightStyle,
|
||||||
pub inline_completion_styles: InlineCompletionStyles,
|
pub edit_prediction_styles: EditPredictionStyles,
|
||||||
pub unnecessary_code_fade: f32,
|
pub unnecessary_code_fade: f32,
|
||||||
pub show_underlines: bool,
|
pub show_underlines: bool,
|
||||||
}
|
}
|
||||||
|
@ -566,7 +566,7 @@ impl Default for EditorStyle {
|
||||||
// style and retrieve them directly from the theme.
|
// style and retrieve them directly from the theme.
|
||||||
status: StatusColors::dark(),
|
status: StatusColors::dark(),
|
||||||
inlay_hints_style: HighlightStyle::default(),
|
inlay_hints_style: HighlightStyle::default(),
|
||||||
inline_completion_styles: InlineCompletionStyles {
|
edit_prediction_styles: EditPredictionStyles {
|
||||||
insertion: HighlightStyle::default(),
|
insertion: HighlightStyle::default(),
|
||||||
whitespace: 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 {
|
pub fn make_suggestion_styles(cx: &mut App) -> EditPredictionStyles {
|
||||||
InlineCompletionStyles {
|
EditPredictionStyles {
|
||||||
insertion: HighlightStyle {
|
insertion: HighlightStyle {
|
||||||
color: Some(cx.theme().status().predictive),
|
color: Some(cx.theme().status().predictive),
|
||||||
..HighlightStyle::default()
|
..HighlightStyle::default()
|
||||||
|
@ -609,7 +609,7 @@ pub(crate) enum EditDisplayMode {
|
||||||
Inline,
|
Inline,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum InlineCompletion {
|
enum EditPrediction {
|
||||||
Edit {
|
Edit {
|
||||||
edits: Vec<(Range<Anchor>, String)>,
|
edits: Vec<(Range<Anchor>, String)>,
|
||||||
edit_preview: Option<EditPreview>,
|
edit_preview: Option<EditPreview>,
|
||||||
|
@ -622,9 +622,9 @@ enum InlineCompletion {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
struct InlineCompletionState {
|
struct EditPredictionState {
|
||||||
inlay_ids: Vec<InlayId>,
|
inlay_ids: Vec<InlayId>,
|
||||||
completion: InlineCompletion,
|
completion: EditPrediction,
|
||||||
completion_id: Option<SharedString>,
|
completion_id: Option<SharedString>,
|
||||||
invalidation_range: Range<Anchor>,
|
invalidation_range: Range<Anchor>,
|
||||||
}
|
}
|
||||||
|
@ -637,7 +637,7 @@ enum EditPredictionSettings {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
enum InlineCompletionHighlight {}
|
enum EditPredictionHighlight {}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct InlineDiagnostic {
|
struct InlineDiagnostic {
|
||||||
|
@ -648,7 +648,7 @@ struct InlineDiagnostic {
|
||||||
severity: lsp::DiagnosticSeverity,
|
severity: lsp::DiagnosticSeverity,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum MenuInlineCompletionsPolicy {
|
pub enum MenuEditPredictionsPolicy {
|
||||||
Never,
|
Never,
|
||||||
ByProvider,
|
ByProvider,
|
||||||
}
|
}
|
||||||
|
@ -1087,15 +1087,15 @@ pub struct Editor {
|
||||||
pending_mouse_down: Option<Rc<RefCell<Option<MouseDownEvent>>>>,
|
pending_mouse_down: Option<Rc<RefCell<Option<MouseDownEvent>>>>,
|
||||||
gutter_hovered: bool,
|
gutter_hovered: bool,
|
||||||
hovered_link_state: Option<HoveredLinkState>,
|
hovered_link_state: Option<HoveredLinkState>,
|
||||||
edit_prediction_provider: Option<RegisteredInlineCompletionProvider>,
|
edit_prediction_provider: Option<RegisteredEditPredictionProvider>,
|
||||||
code_action_providers: Vec<Rc<dyn CodeActionProvider>>,
|
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
|
/// 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,
|
edit_prediction_settings: EditPredictionSettings,
|
||||||
inline_completions_hidden_for_vim_mode: bool,
|
edit_predictions_hidden_for_vim_mode: bool,
|
||||||
show_inline_completions_override: Option<bool>,
|
show_edit_predictions_override: Option<bool>,
|
||||||
menu_inline_completions_policy: MenuInlineCompletionsPolicy,
|
menu_edit_predictions_policy: MenuEditPredictionsPolicy,
|
||||||
edit_prediction_preview: EditPredictionPreview,
|
edit_prediction_preview: EditPredictionPreview,
|
||||||
edit_prediction_indent_conflict: bool,
|
edit_prediction_indent_conflict: bool,
|
||||||
edit_prediction_requires_modifier_in_indent_conflict: bool,
|
edit_prediction_requires_modifier_in_indent_conflict: bool,
|
||||||
|
@ -1510,8 +1510,8 @@ pub struct RenameState {
|
||||||
|
|
||||||
struct InvalidationStack<T>(Vec<T>);
|
struct InvalidationStack<T>(Vec<T>);
|
||||||
|
|
||||||
struct RegisteredInlineCompletionProvider {
|
struct RegisteredEditPredictionProvider {
|
||||||
provider: Arc<dyn InlineCompletionProviderHandle>,
|
provider: Arc<dyn EditPredictionProviderHandle>,
|
||||||
_subscription: Subscription,
|
_subscription: Subscription,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2096,8 +2096,8 @@ impl Editor {
|
||||||
pending_mouse_down: None,
|
pending_mouse_down: None,
|
||||||
hovered_link_state: None,
|
hovered_link_state: None,
|
||||||
edit_prediction_provider: None,
|
edit_prediction_provider: None,
|
||||||
active_inline_completion: None,
|
active_edit_prediction: None,
|
||||||
stale_inline_completion_in_menu: None,
|
stale_edit_prediction_in_menu: None,
|
||||||
edit_prediction_preview: EditPredictionPreview::Inactive {
|
edit_prediction_preview: EditPredictionPreview::Inactive {
|
||||||
released_too_fast: false,
|
released_too_fast: false,
|
||||||
},
|
},
|
||||||
|
@ -2116,9 +2116,9 @@ impl Editor {
|
||||||
hovered_cursors: HashMap::default(),
|
hovered_cursors: HashMap::default(),
|
||||||
next_editor_action_id: EditorActionId::default(),
|
next_editor_action_id: EditorActionId::default(),
|
||||||
editor_actions: Rc::default(),
|
editor_actions: Rc::default(),
|
||||||
inline_completions_hidden_for_vim_mode: false,
|
edit_predictions_hidden_for_vim_mode: false,
|
||||||
show_inline_completions_override: None,
|
show_edit_predictions_override: None,
|
||||||
menu_inline_completions_policy: MenuInlineCompletionsPolicy::ByProvider,
|
menu_edit_predictions_policy: MenuEditPredictionsPolicy::ByProvider,
|
||||||
edit_prediction_settings: EditPredictionSettings::Disabled,
|
edit_prediction_settings: EditPredictionSettings::Disabled,
|
||||||
edit_prediction_indent_conflict: false,
|
edit_prediction_indent_conflict: false,
|
||||||
edit_prediction_requires_modifier_in_indent_conflict: true,
|
edit_prediction_requires_modifier_in_indent_conflict: true,
|
||||||
|
@ -2350,7 +2350,7 @@ impl Editor {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn key_context(&self, window: &Window, cx: &App) -> KeyContext {
|
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(
|
fn key_context_internal(
|
||||||
|
@ -2717,17 +2717,16 @@ impl Editor {
|
||||||
) where
|
) where
|
||||||
T: EditPredictionProvider,
|
T: EditPredictionProvider,
|
||||||
{
|
{
|
||||||
self.edit_prediction_provider =
|
self.edit_prediction_provider = provider.map(|provider| RegisteredEditPredictionProvider {
|
||||||
provider.map(|provider| RegisteredInlineCompletionProvider {
|
_subscription: cx.observe_in(&provider, window, |this, _, window, cx| {
|
||||||
_subscription: cx.observe_in(&provider, window, |this, _, window, cx| {
|
if this.focus_handle.is_focused(window) {
|
||||||
if this.focus_handle.is_focused(window) {
|
this.update_visible_edit_prediction(window, cx);
|
||||||
this.update_visible_inline_completion(window, cx);
|
}
|
||||||
}
|
}),
|
||||||
}),
|
provider: Arc::new(provider),
|
||||||
provider: Arc::new(provider),
|
});
|
||||||
});
|
|
||||||
self.update_edit_prediction_settings(cx);
|
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> {
|
pub fn placeholder_text(&self) -> Option<&str> {
|
||||||
|
@ -2798,24 +2797,24 @@ impl Editor {
|
||||||
self.input_enabled = input_enabled;
|
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,
|
&mut self,
|
||||||
hidden: bool,
|
hidden: bool,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
if hidden != self.inline_completions_hidden_for_vim_mode {
|
if hidden != self.edit_predictions_hidden_for_vim_mode {
|
||||||
self.inline_completions_hidden_for_vim_mode = hidden;
|
self.edit_predictions_hidden_for_vim_mode = hidden;
|
||||||
if hidden {
|
if hidden {
|
||||||
self.update_visible_inline_completion(window, cx);
|
self.update_visible_edit_prediction(window, cx);
|
||||||
} else {
|
} 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) {
|
pub fn set_menu_edit_predictions_policy(&mut self, value: MenuEditPredictionsPolicy) {
|
||||||
self.menu_inline_completions_policy = value;
|
self.menu_edit_predictions_policy = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_autoindent(&mut self, autoindent: bool) {
|
pub fn set_autoindent(&mut self, autoindent: bool) {
|
||||||
|
@ -2852,7 +2851,7 @@ impl Editor {
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
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);
|
self.set_show_edit_predictions(None, window, cx);
|
||||||
} else {
|
} else {
|
||||||
let show_edit_predictions = !self.edit_predictions_enabled();
|
let show_edit_predictions = !self.edit_predictions_enabled();
|
||||||
|
@ -2866,17 +2865,17 @@ impl Editor {
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
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);
|
self.update_edit_prediction_settings(cx);
|
||||||
|
|
||||||
if let Some(false) = show_edit_predictions {
|
if let Some(false) = show_edit_predictions {
|
||||||
self.discard_inline_completion(false, cx);
|
self.discard_edit_prediction(false, cx);
|
||||||
} else {
|
} 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,
|
&self,
|
||||||
buffer: &Entity<Buffer>,
|
buffer: &Entity<Buffer>,
|
||||||
buffer_position: language::Anchor,
|
buffer_position: language::Anchor,
|
||||||
|
@ -3043,7 +3042,7 @@ impl Editor {
|
||||||
self.refresh_document_highlights(cx);
|
self.refresh_document_highlights(cx);
|
||||||
self.refresh_selected_text_highlights(false, window, cx);
|
self.refresh_selected_text_highlights(false, window, cx);
|
||||||
refresh_matching_bracket_highlights(self, 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;
|
self.edit_prediction_requires_modifier_in_indent_conflict = true;
|
||||||
linked_editing_ranges::refresh_linked_ranges(self, window, cx);
|
linked_editing_ranges::refresh_linked_ranges(self, window, cx);
|
||||||
self.inline_blame_popover.take();
|
self.inline_blame_popover.take();
|
||||||
|
@ -3833,7 +3832,7 @@ impl Editor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_user_requested && self.discard_inline_completion(true, cx) {
|
if is_user_requested && self.discard_edit_prediction(true, cx) {
|
||||||
return true;
|
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(
|
this.change_selections(
|
||||||
SelectionEffects::scroll(Autoscroll::fit()).completions(false),
|
SelectionEffects::scroll(Autoscroll::fit()).completions(false),
|
||||||
window,
|
window,
|
||||||
|
@ -4264,7 +4263,7 @@ impl Editor {
|
||||||
}
|
}
|
||||||
|
|
||||||
let trigger_in_words =
|
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() {
|
if this.hard_wrap.is_some() {
|
||||||
let latest: Range<Point> = this.selections.newest(cx).range();
|
let latest: Range<Point> = this.selections.newest(cx).range();
|
||||||
if latest.is_empty()
|
if latest.is_empty()
|
||||||
|
@ -4286,7 +4285,7 @@ impl Editor {
|
||||||
}
|
}
|
||||||
this.trigger_completion_on_input(&text, trigger_in_words, window, cx);
|
this.trigger_completion_on_input(&text, trigger_in_words, window, cx);
|
||||||
linked_editing_ranges::refresh_linked_ranges(this, 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);
|
jsx_tag_auto_close::handle_from(this, initial_buffer_versions, window, cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -4621,7 +4620,7 @@ impl Editor {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
this.change_selections(Default::default(), window, cx, |s| s.select(new_selections));
|
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);
|
crate::hover_popover::hide_hover(editor, cx);
|
||||||
if editor.show_edit_predictions_in_menu() {
|
if editor.show_edit_predictions_in_menu() {
|
||||||
editor.update_visible_inline_completion(window, cx);
|
editor.update_visible_edit_prediction(window, cx);
|
||||||
} else {
|
} else {
|
||||||
editor.discard_inline_completion(false, cx);
|
editor.discard_edit_prediction(false, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
@ -5682,10 +5681,10 @@ impl Editor {
|
||||||
if editor.completion_tasks.len() <= 1 {
|
if editor.completion_tasks.len() <= 1 {
|
||||||
// If there are no more completion tasks and the last menu was empty, we should hide it.
|
// 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();
|
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
|
// If it was already hidden and we don't show edit predictions in the menu,
|
||||||
// also show the inline-completion when available.
|
// we should also show the edit prediction when available.
|
||||||
if was_hidden && editor.show_edit_predictions_in_menu() {
|
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 entries = completions_menu.entries.borrow();
|
||||||
let mat = entries.get(item_ix.unwrap_or(completions_menu.selected_item))?;
|
let mat = entries.get(item_ix.unwrap_or(completions_menu.selected_item))?;
|
||||||
if self.show_edit_predictions_in_menu() {
|
if self.show_edit_predictions_in_menu() {
|
||||||
self.discard_inline_completion(true, cx);
|
self.discard_edit_prediction(true, cx);
|
||||||
}
|
}
|
||||||
mat.candidate_id
|
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);
|
self.invalidate_autoclose_regions(&self.selections.disjoint_anchors(), &snapshot);
|
||||||
|
|
||||||
|
@ -5983,7 +5982,7 @@ impl Editor {
|
||||||
let deployed_from = action.deployed_from.clone();
|
let deployed_from = action.deployed_from.clone();
|
||||||
let action = action.clone();
|
let action = action.clone();
|
||||||
self.completion_tasks.clear();
|
self.completion_tasks.clear();
|
||||||
self.discard_inline_completion(false, cx);
|
self.discard_edit_prediction(false, cx);
|
||||||
|
|
||||||
let multibuffer_point = match &action.deployed_from {
|
let multibuffer_point = match &action.deployed_from {
|
||||||
Some(CodeActionSource::Indicator(row)) | Some(CodeActionSource::RunMenu(row)) => {
|
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,
|
&mut self,
|
||||||
debounce: bool,
|
debounce: bool,
|
||||||
user_requested: bool,
|
user_requested: bool,
|
||||||
|
@ -7005,7 +7004,7 @@ impl Editor {
|
||||||
self.buffer.read(cx).text_anchor_for_position(cursor, cx)?;
|
self.buffer.read(cx).text_anchor_for_position(cursor, cx)?;
|
||||||
|
|
||||||
if !self.edit_predictions_enabled_in_buffer(&buffer, cursor_buffer_position, 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;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7014,11 +7013,11 @@ impl Editor {
|
||||||
|| !self.is_focused(window)
|
|| !self.is_focused(window)
|
||||||
|| buffer.read(cx).is_empty())
|
|| buffer.read(cx).is_empty())
|
||||||
{
|
{
|
||||||
self.discard_inline_completion(false, cx);
|
self.discard_edit_prediction(false, cx);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.update_visible_inline_completion(window, cx);
|
self.update_visible_edit_prediction(window, cx);
|
||||||
provider.refresh(
|
provider.refresh(
|
||||||
self.project.clone(),
|
self.project.clone(),
|
||||||
buffer,
|
buffer,
|
||||||
|
@ -7056,7 +7055,7 @@ impl Editor {
|
||||||
pub fn update_edit_prediction_settings(&mut self, cx: &mut Context<Self>) {
|
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 {
|
if self.edit_prediction_provider.is_none() || DisableAiSettings::get_global(cx).disable_ai {
|
||||||
self.edit_prediction_settings = EditPredictionSettings::Disabled;
|
self.edit_prediction_settings = EditPredictionSettings::Disabled;
|
||||||
self.discard_inline_completion(false, cx);
|
self.discard_edit_prediction(false, cx);
|
||||||
} else {
|
} else {
|
||||||
let selection = self.selections.newest_anchor();
|
let selection = self.selections.newest_anchor();
|
||||||
let cursor = selection.head();
|
let cursor = selection.head();
|
||||||
|
@ -7077,8 +7076,8 @@ impl Editor {
|
||||||
cx: &App,
|
cx: &App,
|
||||||
) -> EditPredictionSettings {
|
) -> EditPredictionSettings {
|
||||||
if !self.mode.is_full()
|
if !self.mode.is_full()
|
||||||
|| !self.show_inline_completions_override.unwrap_or(true)
|
|| !self.show_edit_predictions_override.unwrap_or(true)
|
||||||
|| self.inline_completions_disabled_in_scope(buffer, buffer_position, cx)
|
|| self.edit_predictions_disabled_in_scope(buffer, buffer_position, cx)
|
||||||
{
|
{
|
||||||
return EditPredictionSettings::Disabled;
|
return EditPredictionSettings::Disabled;
|
||||||
}
|
}
|
||||||
|
@ -7092,8 +7091,8 @@ impl Editor {
|
||||||
};
|
};
|
||||||
|
|
||||||
let by_provider = matches!(
|
let by_provider = matches!(
|
||||||
self.menu_inline_completions_policy,
|
self.menu_edit_predictions_policy,
|
||||||
MenuInlineCompletionsPolicy::ByProvider
|
MenuEditPredictionsPolicy::ByProvider
|
||||||
);
|
);
|
||||||
|
|
||||||
let show_in_menu = by_provider
|
let show_in_menu = by_provider
|
||||||
|
@ -7163,7 +7162,7 @@ impl Editor {
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cycle_inline_completion(
|
fn cycle_edit_prediction(
|
||||||
&mut self,
|
&mut self,
|
||||||
direction: Direction,
|
direction: Direction,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
|
@ -7173,28 +7172,28 @@ impl Editor {
|
||||||
let cursor = self.selections.newest_anchor().head();
|
let cursor = self.selections.newest_anchor().head();
|
||||||
let (buffer, cursor_buffer_position) =
|
let (buffer, cursor_buffer_position) =
|
||||||
self.buffer.read(cx).text_anchor_for_position(cursor, cx)?;
|
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;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
provider.cycle(buffer, cursor_buffer_position, direction, cx);
|
provider.cycle(buffer, cursor_buffer_position, direction, cx);
|
||||||
self.update_visible_inline_completion(window, cx);
|
self.update_visible_edit_prediction(window, cx);
|
||||||
|
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn show_inline_completion(
|
pub fn show_edit_prediction(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: &ShowEditPrediction,
|
_: &ShowEditPrediction,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
if !self.has_active_inline_completion() {
|
if !self.has_active_edit_prediction() {
|
||||||
self.refresh_inline_completion(false, true, window, cx);
|
self.refresh_edit_prediction(false, true, window, cx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.update_visible_inline_completion(window, cx);
|
self.update_visible_edit_prediction(window, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn display_cursor_names(
|
pub fn display_cursor_names(
|
||||||
|
@ -7226,11 +7225,11 @@ impl Editor {
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
if self.has_active_inline_completion() {
|
if self.has_active_edit_prediction() {
|
||||||
self.cycle_inline_completion(Direction::Next, window, cx);
|
self.cycle_edit_prediction(Direction::Next, window, cx);
|
||||||
} else {
|
} else {
|
||||||
let is_copilot_disabled = self
|
let is_copilot_disabled = self
|
||||||
.refresh_inline_completion(false, true, window, cx)
|
.refresh_edit_prediction(false, true, window, cx)
|
||||||
.is_none();
|
.is_none();
|
||||||
if is_copilot_disabled {
|
if is_copilot_disabled {
|
||||||
cx.propagate();
|
cx.propagate();
|
||||||
|
@ -7244,11 +7243,11 @@ impl Editor {
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
if self.has_active_inline_completion() {
|
if self.has_active_edit_prediction() {
|
||||||
self.cycle_inline_completion(Direction::Prev, window, cx);
|
self.cycle_edit_prediction(Direction::Prev, window, cx);
|
||||||
} else {
|
} else {
|
||||||
let is_copilot_disabled = self
|
let is_copilot_disabled = self
|
||||||
.refresh_inline_completion(false, true, window, cx)
|
.refresh_edit_prediction(false, true, window, cx)
|
||||||
.is_none();
|
.is_none();
|
||||||
if is_copilot_disabled {
|
if is_copilot_disabled {
|
||||||
cx.propagate();
|
cx.propagate();
|
||||||
|
@ -7266,18 +7265,14 @@ impl Editor {
|
||||||
self.hide_context_menu(window, cx);
|
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;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report_inline_completion_event(
|
self.report_edit_prediction_event(active_edit_prediction.completion_id.clone(), true, cx);
|
||||||
active_inline_completion.completion_id.clone(),
|
|
||||||
true,
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
|
|
||||||
match &active_inline_completion.completion {
|
match &active_edit_prediction.completion {
|
||||||
InlineCompletion::Move { target, .. } => {
|
EditPrediction::Move { target, .. } => {
|
||||||
let target = *target;
|
let target = *target;
|
||||||
|
|
||||||
if let Some(position_map) = &self.last_position_map {
|
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() {
|
if let Some(provider) = self.edit_prediction_provider() {
|
||||||
provider.accept(cx);
|
provider.accept(cx);
|
||||||
}
|
}
|
||||||
|
@ -7347,9 +7342,9 @@ impl Editor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.update_visible_inline_completion(window, cx);
|
self.update_visible_edit_prediction(window, cx);
|
||||||
if self.active_inline_completion.is_none() {
|
if self.active_edit_prediction.is_none() {
|
||||||
self.refresh_inline_completion(true, true, window, cx);
|
self.refresh_edit_prediction(true, true, window, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
@ -7359,27 +7354,23 @@ impl Editor {
|
||||||
self.edit_prediction_requires_modifier_in_indent_conflict = false;
|
self.edit_prediction_requires_modifier_in_indent_conflict = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn accept_partial_inline_completion(
|
pub fn accept_partial_edit_prediction(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: &AcceptPartialEditPrediction,
|
_: &AcceptPartialEditPrediction,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
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;
|
return;
|
||||||
};
|
};
|
||||||
if self.selections.count() != 1 {
|
if self.selections.count() != 1 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.report_inline_completion_event(
|
self.report_edit_prediction_event(active_edit_prediction.completion_id.clone(), true, cx);
|
||||||
active_inline_completion.completion_id.clone(),
|
|
||||||
true,
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
|
|
||||||
match &active_inline_completion.completion {
|
match &active_edit_prediction.completion {
|
||||||
InlineCompletion::Move { target, .. } => {
|
EditPrediction::Move { target, .. } => {
|
||||||
let target = *target;
|
let target = *target;
|
||||||
self.change_selections(
|
self.change_selections(
|
||||||
SelectionEffects::scroll(Autoscroll::newest()),
|
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.
|
// Find an insertion that starts at the cursor position.
|
||||||
let snapshot = self.buffer.read(cx).snapshot(cx);
|
let snapshot = self.buffer.read(cx).snapshot(cx);
|
||||||
let cursor_offset = self.selections.newest::<usize>(cx).head();
|
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.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();
|
cx.notify();
|
||||||
} else {
|
} else {
|
||||||
self.accept_edit_prediction(&Default::default(), window, cx);
|
self.accept_edit_prediction(&Default::default(), window, cx);
|
||||||
|
@ -7433,28 +7424,28 @@ impl Editor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn discard_inline_completion(
|
fn discard_edit_prediction(
|
||||||
&mut self,
|
&mut self,
|
||||||
should_report_inline_completion_event: bool,
|
should_report_edit_prediction_event: bool,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if should_report_inline_completion_event {
|
if should_report_edit_prediction_event {
|
||||||
let completion_id = self
|
let completion_id = self
|
||||||
.active_inline_completion
|
.active_edit_prediction
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|active_completion| active_completion.completion_id.clone());
|
.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() {
|
if let Some(provider) = self.edit_prediction_provider() {
|
||||||
provider.discard(cx);
|
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 {
|
let Some(provider) = self.edit_prediction_provider() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -7485,18 +7476,18 @@ impl Editor {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_active_inline_completion(&self) -> bool {
|
pub fn has_active_edit_prediction(&self) -> bool {
|
||||||
self.active_inline_completion.is_some()
|
self.active_edit_prediction.is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn take_active_inline_completion(&mut self, cx: &mut Context<Self>) -> bool {
|
fn take_active_edit_prediction(&mut self, cx: &mut Context<Self>) -> bool {
|
||||||
let Some(active_inline_completion) = self.active_inline_completion.take() else {
|
let Some(active_edit_prediction) = self.active_edit_prediction.take() else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.splice_inlays(&active_inline_completion.inlay_ids, Default::default(), cx);
|
self.splice_inlays(&active_edit_prediction.inlay_ids, Default::default(), cx);
|
||||||
self.clear_highlights::<InlineCompletionHighlight>(cx);
|
self.clear_highlights::<EditPredictionHighlight>(cx);
|
||||||
self.stale_inline_completion_in_menu = Some(active_inline_completion);
|
self.stale_edit_prediction_in_menu = Some(active_edit_prediction);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7641,7 +7632,7 @@ impl Editor {
|
||||||
since: Instant::now(),
|
since: Instant::now(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.update_visible_inline_completion(window, cx);
|
self.update_visible_edit_prediction(window, cx);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
} else if let EditPredictionPreview::Active {
|
} else if let EditPredictionPreview::Active {
|
||||||
|
@ -7664,12 +7655,12 @@ impl Editor {
|
||||||
released_too_fast: since.elapsed() < Duration::from_millis(200),
|
released_too_fast: since.elapsed() < Duration::from_millis(200),
|
||||||
};
|
};
|
||||||
self.clear_row_highlights::<EditPredictionPreview>();
|
self.clear_row_highlights::<EditPredictionPreview>();
|
||||||
self.update_visible_inline_completion(window, cx);
|
self.update_visible_edit_prediction(window, cx);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_visible_inline_completion(
|
fn update_visible_edit_prediction(
|
||||||
&mut self,
|
&mut self,
|
||||||
_window: &mut Window,
|
_window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
|
@ -7687,12 +7678,12 @@ impl Editor {
|
||||||
let show_in_menu = self.show_edit_predictions_in_menu();
|
let show_in_menu = self.show_edit_predictions_in_menu();
|
||||||
let completions_menu_has_precedence = !show_in_menu
|
let completions_menu_has_precedence = !show_in_menu
|
||||||
&& (self.context_menu.borrow().is_some()
|
&& (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
|
if completions_menu_has_precedence
|
||||||
|| !offset_selection.is_empty()
|
|| !offset_selection.is_empty()
|
||||||
|| self
|
|| self
|
||||||
.active_inline_completion
|
.active_edit_prediction
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |completion| {
|
.map_or(false, |completion| {
|
||||||
let invalidation_range = completion.invalidation_range.to_offset(&multibuffer);
|
let invalidation_range = completion.invalidation_range.to_offset(&multibuffer);
|
||||||
|
@ -7700,11 +7691,11 @@ impl Editor {
|
||||||
!invalidation_range.contains(&offset_selection.head())
|
!invalidation_range.contains(&offset_selection.head())
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
self.discard_inline_completion(false, cx);
|
self.discard_edit_prediction(false, cx);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.take_active_inline_completion(cx);
|
self.take_active_edit_prediction(cx);
|
||||||
let Some(provider) = self.edit_prediction_provider() else {
|
let Some(provider) = self.edit_prediction_provider() else {
|
||||||
self.edit_prediction_settings = EditPredictionSettings::Disabled;
|
self.edit_prediction_settings = EditPredictionSettings::Disabled;
|
||||||
return None;
|
return None;
|
||||||
|
@ -7730,8 +7721,8 @@ impl Editor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let inline_completion = provider.suggest(&buffer, cursor_buffer_position, cx)?;
|
let edit_prediction = provider.suggest(&buffer, cursor_buffer_position, cx)?;
|
||||||
let edits = inline_completion
|
let edits = edit_prediction
|
||||||
.edits
|
.edits
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flat_map(|(range, new_text)| {
|
.flat_map(|(range, new_text)| {
|
||||||
|
@ -7766,15 +7757,15 @@ impl Editor {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let is_move =
|
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 {
|
let completion = if is_move {
|
||||||
invalidation_row_range =
|
invalidation_row_range =
|
||||||
move_invalidation_row_range.unwrap_or(edit_start_row..edit_end_row);
|
move_invalidation_row_range.unwrap_or(edit_start_row..edit_end_row);
|
||||||
let target = first_edit_start;
|
let target = first_edit_start;
|
||||||
InlineCompletion::Move { target, snapshot }
|
EditPrediction::Move { target, snapshot }
|
||||||
} else {
|
} else {
|
||||||
let show_completions_in_buffer = !self.edit_prediction_visible_in_cursor_popover(true)
|
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 show_completions_in_buffer {
|
||||||
if edits
|
if edits
|
||||||
|
@ -7783,7 +7774,7 @@ impl Editor {
|
||||||
{
|
{
|
||||||
let mut inlays = Vec::new();
|
let mut inlays = Vec::new();
|
||||||
for (range, new_text) in &edits {
|
for (range, new_text) in &edits {
|
||||||
let inlay = Inlay::inline_completion(
|
let inlay = Inlay::edit_prediction(
|
||||||
post_inc(&mut self.next_inlay_id),
|
post_inc(&mut self.next_inlay_id),
|
||||||
range.start,
|
range.start,
|
||||||
new_text.as_str(),
|
new_text.as_str(),
|
||||||
|
@ -7795,7 +7786,7 @@ impl Editor {
|
||||||
self.splice_inlays(&[], inlays, cx);
|
self.splice_inlays(&[], inlays, cx);
|
||||||
} else {
|
} else {
|
||||||
let background_color = cx.theme().status().deleted_background;
|
let background_color = cx.theme().status().deleted_background;
|
||||||
self.highlight_text::<InlineCompletionHighlight>(
|
self.highlight_text::<EditPredictionHighlight>(
|
||||||
edits.iter().map(|(range, _)| range.clone()).collect(),
|
edits.iter().map(|(range, _)| range.clone()).collect(),
|
||||||
HighlightStyle {
|
HighlightStyle {
|
||||||
background_color: Some(background_color),
|
background_color: Some(background_color),
|
||||||
|
@ -7818,9 +7809,9 @@ impl Editor {
|
||||||
EditDisplayMode::DiffPopover
|
EditDisplayMode::DiffPopover
|
||||||
};
|
};
|
||||||
|
|
||||||
InlineCompletion::Edit {
|
EditPrediction::Edit {
|
||||||
edits,
|
edits,
|
||||||
edit_preview: inline_completion.edit_preview,
|
edit_preview: edit_prediction.edit_preview,
|
||||||
display_mode,
|
display_mode,
|
||||||
snapshot,
|
snapshot,
|
||||||
}
|
}
|
||||||
|
@ -7833,11 +7824,11 @@ impl Editor {
|
||||||
multibuffer.line_len(MultiBufferRow(invalidation_row_range.end)),
|
multibuffer.line_len(MultiBufferRow(invalidation_row_range.end)),
|
||||||
));
|
));
|
||||||
|
|
||||||
self.stale_inline_completion_in_menu = None;
|
self.stale_edit_prediction_in_menu = None;
|
||||||
self.active_inline_completion = Some(InlineCompletionState {
|
self.active_edit_prediction = Some(EditPredictionState {
|
||||||
inlay_ids,
|
inlay_ids,
|
||||||
completion,
|
completion,
|
||||||
completion_id: inline_completion.id,
|
completion_id: edit_prediction.id,
|
||||||
invalidation_range,
|
invalidation_range,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -7846,7 +7837,7 @@ impl Editor {
|
||||||
Some(())
|
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())
|
Some(self.edit_prediction_provider.as_ref()?.provider.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8415,14 +8406,14 @@ impl Editor {
|
||||||
if self.mode().is_minimap() {
|
if self.mode().is_minimap() {
|
||||||
return None;
|
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) {
|
if self.edit_prediction_visible_in_cursor_popover(true) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
match &active_inline_completion.completion {
|
match &active_edit_prediction.completion {
|
||||||
InlineCompletion::Move { target, .. } => {
|
EditPrediction::Move { target, .. } => {
|
||||||
let target_display_point = target.to_display_point(editor_snapshot);
|
let target_display_point = target.to_display_point(editor_snapshot);
|
||||||
|
|
||||||
if self.edit_prediction_requires_modifier() {
|
if self.edit_prediction_requires_modifier() {
|
||||||
|
@ -8459,11 +8450,11 @@ impl Editor {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InlineCompletion::Edit {
|
EditPrediction::Edit {
|
||||||
display_mode: EditDisplayMode::Inline,
|
display_mode: EditDisplayMode::Inline,
|
||||||
..
|
..
|
||||||
} => None,
|
} => None,
|
||||||
InlineCompletion::Edit {
|
EditPrediction::Edit {
|
||||||
display_mode: EditDisplayMode::TabAccept,
|
display_mode: EditDisplayMode::TabAccept,
|
||||||
edits,
|
edits,
|
||||||
..
|
..
|
||||||
|
@ -8484,7 +8475,7 @@ impl Editor {
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
InlineCompletion::Edit {
|
EditPrediction::Edit {
|
||||||
edits,
|
edits,
|
||||||
edit_preview,
|
edit_preview,
|
||||||
display_mode: EditDisplayMode::DiffPopover,
|
display_mode: EditDisplayMode::DiffPopover,
|
||||||
|
@ -8801,7 +8792,7 @@ impl Editor {
|
||||||
}
|
}
|
||||||
|
|
||||||
let highlighted_edits =
|
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 styled_text = highlighted_edits.to_styled_text(&style.text);
|
||||||
let line_count = highlighted_edits.text.lines().count();
|
let line_count = highlighted_edits.text.lines().count();
|
||||||
|
@ -9131,7 +9122,7 @@ impl Editor {
|
||||||
.child(Icon::new(IconName::ZedPredict))
|
.child(Icon::new(IconName::ZedPredict))
|
||||||
}
|
}
|
||||||
|
|
||||||
let completion = match &self.active_inline_completion {
|
let completion = match &self.active_edit_prediction {
|
||||||
Some(prediction) => {
|
Some(prediction) => {
|
||||||
if !self.has_visible_completions_menu() {
|
if !self.has_visible_completions_menu() {
|
||||||
const RADIUS: Pixels = px(6.);
|
const RADIUS: Pixels = px(6.);
|
||||||
|
@ -9149,7 +9140,7 @@ impl Editor {
|
||||||
.rounded_tl(px(0.))
|
.rounded_tl(px(0.))
|
||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
.child(div().px_1p5().child(match &prediction.completion {
|
.child(div().px_1p5().child(match &prediction.completion {
|
||||||
InlineCompletion::Move { target, snapshot } => {
|
EditPrediction::Move { target, snapshot } => {
|
||||||
use text::ToPoint as _;
|
use text::ToPoint as _;
|
||||||
if target.text_anchor.to_point(&snapshot).row > cursor_point.row
|
if target.text_anchor.to_point(&snapshot).row > cursor_point.row
|
||||||
{
|
{
|
||||||
|
@ -9158,7 +9149,7 @@ impl Editor {
|
||||||
Icon::new(IconName::ZedPredictUp)
|
Icon::new(IconName::ZedPredictUp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InlineCompletion::Edit { .. } => Icon::new(IconName::ZedPredict),
|
EditPrediction::Edit { .. } => Icon::new(IconName::ZedPredict),
|
||||||
}))
|
}))
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
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(
|
Some(stale_completion) => self.render_edit_prediction_cursor_popover_preview(
|
||||||
stale_completion,
|
stale_completion,
|
||||||
cursor_point,
|
cursor_point,
|
||||||
|
@ -9247,7 +9238,7 @@ impl Editor {
|
||||||
completion.into_any_element()
|
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;
|
let is_platform_style_mac = PlatformStyle::platform() == PlatformStyle::Mac;
|
||||||
Some(
|
Some(
|
||||||
|
@ -9306,7 +9297,7 @@ impl Editor {
|
||||||
|
|
||||||
fn render_edit_prediction_cursor_popover_preview(
|
fn render_edit_prediction_cursor_popover_preview(
|
||||||
&self,
|
&self,
|
||||||
completion: &InlineCompletionState,
|
completion: &EditPredictionState,
|
||||||
cursor_point: Point,
|
cursor_point: Point,
|
||||||
style: &EditorStyle,
|
style: &EditorStyle,
|
||||||
cx: &mut Context<Editor>,
|
cx: &mut Context<Editor>,
|
||||||
|
@ -9334,7 +9325,7 @@ impl Editor {
|
||||||
}
|
}
|
||||||
|
|
||||||
match &completion.completion {
|
match &completion.completion {
|
||||||
InlineCompletion::Move {
|
EditPrediction::Move {
|
||||||
target, snapshot, ..
|
target, snapshot, ..
|
||||||
} => Some(
|
} => Some(
|
||||||
h_flex()
|
h_flex()
|
||||||
|
@ -9351,7 +9342,7 @@ impl Editor {
|
||||||
.child(Label::new("Jump to Edit")),
|
.child(Label::new("Jump to Edit")),
|
||||||
),
|
),
|
||||||
|
|
||||||
InlineCompletion::Edit {
|
EditPrediction::Edit {
|
||||||
edits,
|
edits,
|
||||||
edit_preview,
|
edit_preview,
|
||||||
snapshot,
|
snapshot,
|
||||||
|
@ -9359,7 +9350,7 @@ impl Editor {
|
||||||
} => {
|
} => {
|
||||||
let first_edit_row = edits.first()?.0.start.text_anchor.to_point(&snapshot).row;
|
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,
|
&snapshot,
|
||||||
&edits,
|
&edits,
|
||||||
edit_preview.as_ref()?,
|
edit_preview.as_ref()?,
|
||||||
|
@ -9437,8 +9428,8 @@ impl Editor {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
self.completion_tasks.clear();
|
self.completion_tasks.clear();
|
||||||
let context_menu = self.context_menu.borrow_mut().take();
|
let context_menu = self.context_menu.borrow_mut().take();
|
||||||
self.stale_inline_completion_in_menu.take();
|
self.stale_edit_prediction_in_menu.take();
|
||||||
self.update_visible_inline_completion(window, cx);
|
self.update_visible_edit_prediction(window, cx);
|
||||||
if let Some(CodeContextMenu::Completions(_)) = &context_menu {
|
if let Some(CodeContextMenu::Completions(_)) = &context_menu {
|
||||||
if let Some(completion_provider) = &self.completion_provider {
|
if let Some(completion_provider) = &self.completion_provider {
|
||||||
completion_provider.selection_changed(None, window, cx);
|
completion_provider.selection_changed(None, window, cx);
|
||||||
|
@ -9796,7 +9787,7 @@ impl Editor {
|
||||||
this.edit(edits, None, cx);
|
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);
|
linked_editing_ranges::refresh_linked_ranges(this, window, cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -9815,7 +9806,7 @@ impl Editor {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
this.insert("", window, cx);
|
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| {
|
self.transact(window, cx, |this, window, cx| {
|
||||||
this.buffer.update(cx, |b, cx| b.edit(edits, None, cx));
|
this.buffer.update(cx, |b, cx| b.edit(edits, None, cx));
|
||||||
this.change_selections(Default::default(), window, cx, |s| s.select(selections));
|
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.request_autoscroll(Autoscroll::fit(), cx);
|
||||||
self.unmark_text(window, 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::Edited { transaction_id });
|
||||||
cx.emit(EditorEvent::TransactionUndone { transaction_id });
|
cx.emit(EditorEvent::TransactionUndone { transaction_id });
|
||||||
}
|
}
|
||||||
|
@ -12307,7 +12298,7 @@ impl Editor {
|
||||||
}
|
}
|
||||||
self.request_autoscroll(Autoscroll::fit(), cx);
|
self.request_autoscroll(Autoscroll::fit(), cx);
|
||||||
self.unmark_text(window, 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::Edited { transaction_id });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15294,7 +15285,7 @@ impl Editor {
|
||||||
])
|
])
|
||||||
});
|
});
|
||||||
self.activate_diagnostics(buffer_id, next_diagnostic, window, cx);
|
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>) {
|
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),
|
font_weight: Some(FontWeight::BOLD),
|
||||||
..make_inlay_hints_style(cx.app)
|
..make_inlay_hints_style(cx.app)
|
||||||
},
|
},
|
||||||
inline_completion_styles: make_suggestion_styles(
|
edit_prediction_styles: make_suggestion_styles(
|
||||||
cx.app,
|
cx.app,
|
||||||
),
|
),
|
||||||
..EditorStyle::default()
|
..EditorStyle::default()
|
||||||
|
@ -19032,7 +19023,7 @@ impl Editor {
|
||||||
(selection.range(), uuid.to_string())
|
(selection.range(), uuid.to_string())
|
||||||
});
|
});
|
||||||
this.edit(edits, cx);
|
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_selected_text_highlights(true, window, cx);
|
||||||
self.refresh_single_line_folds(window, cx);
|
self.refresh_single_line_folds(window, cx);
|
||||||
refresh_matching_bracket_highlights(self, window, cx);
|
refresh_matching_bracket_highlights(self, window, cx);
|
||||||
if self.has_active_inline_completion() {
|
if self.has_active_edit_prediction() {
|
||||||
self.update_visible_inline_completion(window, cx);
|
self.update_visible_edit_prediction(window, cx);
|
||||||
}
|
}
|
||||||
if let Some(project) = self.project.as_ref() {
|
if let Some(project) = self.project.as_ref() {
|
||||||
if let Some(edited_buffer) = edited_buffer {
|
if let Some(edited_buffer) = edited_buffer {
|
||||||
|
@ -20088,7 +20079,7 @@ impl Editor {
|
||||||
}
|
}
|
||||||
self.tasks_update_task = Some(self.refresh_runnables(window, cx));
|
self.tasks_update_task = Some(self.refresh_runnables(window, cx));
|
||||||
self.update_edit_prediction_settings(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_inline_values(cx);
|
||||||
self.refresh_inlay_hints(
|
self.refresh_inlay_hints(
|
||||||
InlayHintRefreshReason::SettingsChange(inlay_hint_settings(
|
InlayHintRefreshReason::SettingsChange(inlay_hint_settings(
|
||||||
|
@ -20720,7 +20711,7 @@ impl Editor {
|
||||||
{
|
{
|
||||||
self.hide_context_menu(window, cx);
|
self.hide_context_menu(window, cx);
|
||||||
}
|
}
|
||||||
self.discard_inline_completion(false, cx);
|
self.discard_edit_prediction(false, cx);
|
||||||
cx.emit(EditorEvent::Blurred);
|
cx.emit(EditorEvent::Blurred);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
@ -22782,7 +22773,7 @@ impl Render for Editor {
|
||||||
syntax: cx.theme().syntax().clone(),
|
syntax: cx.theme().syntax().clone(),
|
||||||
status: cx.theme().status().clone(),
|
status: cx.theme().status().clone(),
|
||||||
inlay_hints_style: make_inlay_hints_style(cx),
|
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,
|
unnecessary_code_fade: ThemeSettings::get_global(cx).unnecessary_code_fade,
|
||||||
show_underlines: self.diagnostics_enabled(),
|
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,
|
current_snapshot: &BufferSnapshot,
|
||||||
edits: &[(Range<Anchor>, String)],
|
edits: &[(Range<Anchor>, String)],
|
||||||
edit_preview: &EditPreview,
|
edit_preview: &EditPreview,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
JoinLines,
|
JoinLines,
|
||||||
code_context_menus::CodeContextMenu,
|
code_context_menus::CodeContextMenu,
|
||||||
inline_completion_tests::FakeInlineCompletionProvider,
|
edit_prediction_tests::FakeEditPredictionProvider,
|
||||||
linked_editing_ranges::LinkedEditingRanges,
|
linked_editing_ranges::LinkedEditingRanges,
|
||||||
scroll::scroll_amount::ScrollAmount,
|
scroll::scroll_amount::ScrollAmount,
|
||||||
test::{
|
test::{
|
||||||
|
@ -7251,12 +7251,12 @@ async fn test_undo_format_scrolls_to_last_edit_pos(cx: &mut TestAppContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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, |_| {});
|
init_test(cx, |_| {});
|
||||||
|
|
||||||
let mut cx = EditorTestContext::new(cx).await;
|
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| {
|
cx.update_editor(|editor, window, cx| {
|
||||||
editor.set_edit_prediction_provider(Some(provider.clone()), 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| {
|
cx.update(|_, cx| {
|
||||||
provider.update(cx, |provider, _| {
|
provider.update(cx, |provider, _| {
|
||||||
provider.set_inline_completion(Some(inline_completion::InlineCompletion {
|
provider.set_edit_prediction(Some(edit_prediction::EditPrediction {
|
||||||
id: None,
|
id: None,
|
||||||
edits: vec![(edit_position..edit_position, "X".into())],
|
edits: vec![(edit_position..edit_position, "X".into())],
|
||||||
edit_preview: None,
|
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| {
|
cx.update_editor(|editor, window, cx| {
|
||||||
editor.accept_edit_prediction(&crate::AcceptEditPrediction, 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]
|
#[gpui::test]
|
||||||
async fn test_inline_completion_text(cx: &mut TestAppContext) {
|
async fn test_edit_prediction_text(cx: &mut TestAppContext) {
|
||||||
init_test(cx, |_| {});
|
init_test(cx, |_| {});
|
||||||
|
|
||||||
// Simple insertion
|
// Simple insertion
|
||||||
|
@ -20651,7 +20651,7 @@ async fn test_inline_completion_text(cx: &mut TestAppContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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, |_| {});
|
init_test(cx, |_| {});
|
||||||
|
|
||||||
// Deletion
|
// Deletion
|
||||||
|
@ -20741,7 +20741,7 @@ async fn assert_highlighted_edits(
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
cx.update(|_window, cx| {
|
cx.update(|_window, cx| {
|
||||||
let highlighted_edits = inline_completion_edit_text(
|
let highlighted_edits = edit_prediction_edit_text(
|
||||||
&snapshot.as_singleton().unwrap().2,
|
&snapshot.as_singleton().unwrap().2,
|
||||||
&edits,
|
&edits,
|
||||||
&edit_preview,
|
&edit_preview,
|
||||||
|
|
|
@ -3,11 +3,11 @@ use crate::{
|
||||||
CodeActionSource, ColumnarMode, ConflictsOurs, ConflictsOursMarker, ConflictsOuter,
|
CodeActionSource, ColumnarMode, ConflictsOurs, ConflictsOursMarker, ConflictsOuter,
|
||||||
ConflictsTheirs, ConflictsTheirsMarker, ContextMenuPlacement, CursorShape, CustomBlockId,
|
ConflictsTheirs, ConflictsTheirsMarker, ContextMenuPlacement, CursorShape, CustomBlockId,
|
||||||
DisplayDiffHunk, DisplayPoint, DisplayRow, DocumentHighlightRead, DocumentHighlightWrite,
|
DisplayDiffHunk, DisplayPoint, DisplayRow, DocumentHighlightRead, DocumentHighlightWrite,
|
||||||
EditDisplayMode, Editor, EditorMode, EditorSettings, EditorSnapshot, EditorStyle,
|
EditDisplayMode, EditPrediction, Editor, EditorMode, EditorSettings, EditorSnapshot,
|
||||||
FILE_HEADER_HEIGHT, FocusedBlock, GutterDimensions, HalfPageDown, HalfPageUp, HandleInput,
|
EditorStyle, FILE_HEADER_HEIGHT, FocusedBlock, GutterDimensions, HalfPageDown, HalfPageUp,
|
||||||
HoveredCursor, InlayHintRefreshReason, InlineCompletion, JumpData, LineDown, LineHighlight,
|
HandleInput, HoveredCursor, InlayHintRefreshReason, JumpData, LineDown, LineHighlight, LineUp,
|
||||||
LineUp, MAX_LINE_LEN, MINIMAP_FONT_SIZE, MULTI_BUFFER_EXCERPT_HEADER_HEIGHT, OpenExcerpts,
|
MAX_LINE_LEN, MINIMAP_FONT_SIZE, MULTI_BUFFER_EXCERPT_HEADER_HEIGHT, OpenExcerpts, PageDown,
|
||||||
PageDown, PageUp, PhantomBreakpointIndicator, Point, RowExt, RowRangeExt, SelectPhase,
|
PageUp, PhantomBreakpointIndicator, Point, RowExt, RowRangeExt, SelectPhase,
|
||||||
SelectedTextHighlight, Selection, SelectionDragState, SoftWrap, StickyHeaderExcerpt, ToPoint,
|
SelectedTextHighlight, Selection, SelectionDragState, SoftWrap, StickyHeaderExcerpt, ToPoint,
|
||||||
ToggleFold, ToggleFoldAll,
|
ToggleFold, ToggleFoldAll,
|
||||||
code_context_menus::{CodeActionsMenu, MENU_ASIDE_MAX_WIDTH, MENU_ASIDE_MIN_WIDTH, MENU_GAP},
|
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::signature_help_next);
|
||||||
register_action(editor, window, Editor::next_edit_prediction);
|
register_action(editor, window, Editor::next_edit_prediction);
|
||||||
register_action(editor, window, Editor::previous_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_first);
|
||||||
register_action(editor, window, Editor::context_menu_prev);
|
register_action(editor, window, Editor::context_menu_prev);
|
||||||
register_action(editor, window, Editor::context_menu_next);
|
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::display_cursor_names);
|
||||||
register_action(editor, window, Editor::unique_lines_case_insensitive);
|
register_action(editor, window, Editor::unique_lines_case_insensitive);
|
||||||
register_action(editor, window, Editor::unique_lines_case_sensitive);
|
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::accept_edit_prediction);
|
||||||
register_action(editor, window, Editor::restore_file);
|
register_action(editor, window, Editor::restore_file);
|
||||||
register_action(editor, window, Editor::git_restore);
|
register_action(editor, window, Editor::git_restore);
|
||||||
|
@ -2093,7 +2093,7 @@ impl EditorElement {
|
||||||
row_block_types: &HashMap<DisplayRow, bool>,
|
row_block_types: &HashMap<DisplayRow, bool>,
|
||||||
content_origin: gpui::Point<Pixels>,
|
content_origin: gpui::Point<Pixels>,
|
||||||
scroll_pixel_position: 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,
|
start_row: DisplayRow,
|
||||||
end_row: DisplayRow,
|
end_row: DisplayRow,
|
||||||
line_height: Pixels,
|
line_height: Pixels,
|
||||||
|
@ -2210,12 +2210,13 @@ impl EditorElement {
|
||||||
cmp::max(padded_line, min_start)
|
cmp::max(padded_line, min_start)
|
||||||
};
|
};
|
||||||
|
|
||||||
let behind_inline_completion_popover = inline_completion_popover_origin
|
let behind_edit_prediction_popover = edit_prediction_popover_origin.as_ref().map_or(
|
||||||
.as_ref()
|
false,
|
||||||
.map_or(false, |inline_completion_popover_origin| {
|
|edit_prediction_popover_origin| {
|
||||||
(pos_y..pos_y + line_height).contains(&inline_completion_popover_origin.y)
|
(pos_y..pos_y + line_height).contains(&edit_prediction_popover_origin.y)
|
||||||
});
|
},
|
||||||
let opacity = if behind_inline_completion_popover {
|
);
|
||||||
|
let opacity = if behind_edit_prediction_popover {
|
||||||
0.5
|
0.5
|
||||||
} else {
|
} else {
|
||||||
1.0
|
1.0
|
||||||
|
@ -2427,9 +2428,9 @@ impl EditorElement {
|
||||||
|
|
||||||
let mut padding = INLINE_BLAME_PADDING_EM_WIDTHS;
|
let mut padding = INLINE_BLAME_PADDING_EM_WIDTHS;
|
||||||
|
|
||||||
if let Some(inline_completion) = editor.active_inline_completion.as_ref() {
|
if let Some(edit_prediction) = editor.active_edit_prediction.as_ref() {
|
||||||
match &inline_completion.completion {
|
match &edit_prediction.completion {
|
||||||
InlineCompletion::Edit {
|
EditPrediction::Edit {
|
||||||
display_mode: EditDisplayMode::TabAccept,
|
display_mode: EditDisplayMode::TabAccept,
|
||||||
..
|
..
|
||||||
} => padding += INLINE_ACCEPT_SUGGESTION_EM_WIDTHS,
|
} => padding += INLINE_ACCEPT_SUGGESTION_EM_WIDTHS,
|
||||||
|
@ -4086,8 +4087,7 @@ impl EditorElement {
|
||||||
|
|
||||||
{
|
{
|
||||||
let editor = self.editor.read(cx);
|
let editor = self.editor.read(cx);
|
||||||
if editor
|
if editor.edit_prediction_visible_in_cursor_popover(editor.has_active_edit_prediction())
|
||||||
.edit_prediction_visible_in_cursor_popover(editor.has_active_inline_completion())
|
|
||||||
{
|
{
|
||||||
height_above_menu +=
|
height_above_menu +=
|
||||||
editor.edit_prediction_cursor_popover_height() + POPOVER_Y_PADDING;
|
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,
|
&mut self,
|
||||||
layout: &mut EditorLayout,
|
layout: &mut EditorLayout,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) {
|
) {
|
||||||
if let Some(inline_completion_popover) = layout.inline_completion_popover.as_mut() {
|
if let Some(edit_prediction_popover) = layout.edit_prediction_popover.as_mut() {
|
||||||
inline_completion_popover.paint(window, cx);
|
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
|
.editor
|
||||||
.update(cx, |editor, cx| {
|
.update(cx, |editor, cx| {
|
||||||
editor.render_edit_prediction_popover(
|
editor.render_edit_prediction_popover(
|
||||||
|
@ -8530,7 +8530,7 @@ impl Element for EditorElement {
|
||||||
&row_block_types,
|
&row_block_types,
|
||||||
content_origin,
|
content_origin,
|
||||||
scroll_pixel_position,
|
scroll_pixel_position,
|
||||||
inline_completion_popover_origin,
|
edit_prediction_popover_origin,
|
||||||
start_row,
|
start_row,
|
||||||
end_row,
|
end_row,
|
||||||
line_height,
|
line_height,
|
||||||
|
@ -8919,7 +8919,7 @@ impl Element for EditorElement {
|
||||||
cursors,
|
cursors,
|
||||||
visible_cursors,
|
visible_cursors,
|
||||||
selections,
|
selections,
|
||||||
inline_completion_popover,
|
edit_prediction_popover,
|
||||||
diff_hunk_controls,
|
diff_hunk_controls,
|
||||||
mouse_context_menu,
|
mouse_context_menu,
|
||||||
test_indicators,
|
test_indicators,
|
||||||
|
@ -9001,7 +9001,7 @@ impl Element for EditorElement {
|
||||||
|
|
||||||
self.paint_minimap(layout, window, cx);
|
self.paint_minimap(layout, window, cx);
|
||||||
self.paint_scrollbars(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);
|
self.paint_mouse_context_menu(layout, window, cx);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -9102,7 +9102,7 @@ pub struct EditorLayout {
|
||||||
expand_toggles: Vec<Option<(AnyElement, gpui::Point<Pixels>)>>,
|
expand_toggles: Vec<Option<(AnyElement, gpui::Point<Pixels>)>>,
|
||||||
diff_hunk_controls: Vec<AnyElement>,
|
diff_hunk_controls: Vec<AnyElement>,
|
||||||
crease_trailers: Vec<Option<CreaseTrailerLayout>>,
|
crease_trailers: Vec<Option<CreaseTrailerLayout>>,
|
||||||
inline_completion_popover: Option<AnyElement>,
|
edit_prediction_popover: Option<AnyElement>,
|
||||||
mouse_context_menu: Option<AnyElement>,
|
mouse_context_menu: Option<AnyElement>,
|
||||||
tab_invisible: ShapedLine,
|
tab_invisible: ShapedLine,
|
||||||
space_invisible: ShapedLine,
|
space_invisible: ShapedLine,
|
||||||
|
|
|
@ -907,12 +907,12 @@ mod tests {
|
||||||
let inlays = (0..buffer_snapshot.len())
|
let inlays = (0..buffer_snapshot.len())
|
||||||
.flat_map(|offset| {
|
.flat_map(|offset| {
|
||||||
[
|
[
|
||||||
Inlay::inline_completion(
|
Inlay::edit_prediction(
|
||||||
post_inc(&mut id),
|
post_inc(&mut id),
|
||||||
buffer_snapshot.anchor_at(offset, Bias::Left),
|
buffer_snapshot.anchor_at(offset, Bias::Left),
|
||||||
"test",
|
"test",
|
||||||
),
|
),
|
||||||
Inlay::inline_completion(
|
Inlay::edit_prediction(
|
||||||
post_inc(&mut id),
|
post_inc(&mut id),
|
||||||
buffer_snapshot.anchor_at(offset, Bias::Right),
|
buffer_snapshot.anchor_at(offset, Bias::Right),
|
||||||
"test",
|
"test",
|
||||||
|
|
|
@ -253,8 +253,8 @@ impl LogStore {
|
||||||
|
|
||||||
let copilot_subscription = Copilot::global(cx).map(|copilot| {
|
let copilot_subscription = Copilot::global(cx).map(|copilot| {
|
||||||
let copilot = &copilot;
|
let copilot = &copilot;
|
||||||
cx.subscribe(copilot, |this, copilot, inline_completion_event, cx| {
|
cx.subscribe(copilot, |this, copilot, edit_prediction_event, cx| {
|
||||||
if let copilot::Event::CopilotLanguageServerStarted = inline_completion_event {
|
if let copilot::Event::CopilotLanguageServerStarted = edit_prediction_event {
|
||||||
if let Some(server) = copilot.read(cx).language_server() {
|
if let Some(server) = copilot.read(cx).language_server() {
|
||||||
let server_id = server.server_id();
|
let server_id = server.server_id();
|
||||||
let weak_this = cx.weak_entity();
|
let weak_this = cx.weak_entity();
|
||||||
|
|
|
@ -242,22 +242,22 @@ static STRING_REPLACE: LazyLock<HashMap<&str, &str>> = LazyLock::new(|| {
|
||||||
"inline_completion::ToggleMenu",
|
"inline_completion::ToggleMenu",
|
||||||
"edit_prediction::ToggleMenu",
|
"edit_prediction::ToggleMenu",
|
||||||
),
|
),
|
||||||
("editor::NextInlineCompletion", "editor::NextEditPrediction"),
|
("editor::NextEditPrediction", "editor::NextEditPrediction"),
|
||||||
(
|
(
|
||||||
"editor::PreviousInlineCompletion",
|
"editor::PreviousEditPrediction",
|
||||||
"editor::PreviousEditPrediction",
|
"editor::PreviousEditPrediction",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"editor::AcceptPartialInlineCompletion",
|
"editor::AcceptPartialEditPrediction",
|
||||||
"editor::AcceptPartialEditPrediction",
|
"editor::AcceptPartialEditPrediction",
|
||||||
),
|
),
|
||||||
("editor::ShowInlineCompletion", "editor::ShowEditPrediction"),
|
("editor::ShowEditPrediction", "editor::ShowEditPrediction"),
|
||||||
(
|
(
|
||||||
"editor::AcceptInlineCompletion",
|
"editor::AcceptEditPrediction",
|
||||||
"editor::AcceptEditPrediction",
|
"editor::AcceptEditPrediction",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"editor::ToggleInlineCompletions",
|
"editor::ToggleEditPredictions",
|
||||||
"editor::ToggleEditPrediction",
|
"editor::ToggleEditPrediction",
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
|
|
|
@ -1101,7 +1101,7 @@ impl RulesLibrary {
|
||||||
inlay_hints_style: editor::make_inlay_hints_style(
|
inlay_hints_style: editor::make_inlay_hints_style(
|
||||||
cx,
|
cx,
|
||||||
),
|
),
|
||||||
inline_completion_styles:
|
edit_prediction_styles:
|
||||||
editor::make_suggestion_styles(cx),
|
editor::make_suggestion_styles(cx),
|
||||||
..EditorStyle::default()
|
..EditorStyle::default()
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,9 +16,9 @@ doctest = false
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
client.workspace = true
|
client.workspace = true
|
||||||
collections.workspace = true
|
collections.workspace = true
|
||||||
|
edit_prediction.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
inline_completion.workspace = true
|
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
postage.workspace = true
|
postage.workspace = true
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::{Supermaven, SupermavenCompletionStateId};
|
use crate::{Supermaven, SupermavenCompletionStateId};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use edit_prediction::{Direction, EditPrediction, EditPredictionProvider};
|
||||||
use futures::StreamExt as _;
|
use futures::StreamExt as _;
|
||||||
use gpui::{App, Context, Entity, EntityId, Task};
|
use gpui::{App, Context, Entity, EntityId, Task};
|
||||||
use inline_completion::{Direction, EditPredictionProvider, InlineCompletion};
|
|
||||||
use language::{Anchor, Buffer, BufferSnapshot};
|
use language::{Anchor, Buffer, BufferSnapshot};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -44,7 +44,7 @@ fn completion_from_diff(
|
||||||
completion_text: &str,
|
completion_text: &str,
|
||||||
position: Anchor,
|
position: Anchor,
|
||||||
delete_range: Range<Anchor>,
|
delete_range: Range<Anchor>,
|
||||||
) -> InlineCompletion {
|
) -> EditPrediction {
|
||||||
let buffer_text = snapshot
|
let buffer_text = snapshot
|
||||||
.text_for_range(delete_range.clone())
|
.text_for_range(delete_range.clone())
|
||||||
.collect::<String>();
|
.collect::<String>();
|
||||||
|
@ -91,7 +91,7 @@ fn completion_from_diff(
|
||||||
edits.push((edit_range, edit_text));
|
edits.push((edit_range, edit_text));
|
||||||
}
|
}
|
||||||
|
|
||||||
InlineCompletion {
|
EditPrediction {
|
||||||
id: None,
|
id: None,
|
||||||
edits,
|
edits,
|
||||||
edit_preview: None,
|
edit_preview: None,
|
||||||
|
@ -182,7 +182,7 @@ impl EditPredictionProvider for SupermavenCompletionProvider {
|
||||||
buffer: &Entity<Buffer>,
|
buffer: &Entity<Buffer>,
|
||||||
cursor_position: Anchor,
|
cursor_position: Anchor,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Option<InlineCompletion> {
|
) -> Option<EditPrediction> {
|
||||||
let completion_text = self
|
let completion_text = self
|
||||||
.supermaven
|
.supermaven
|
||||||
.read(cx)
|
.read(cx)
|
||||||
|
|
|
@ -94,8 +94,8 @@ impl Display for AssistantPhase {
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
Flexible(FlexibleEvent),
|
Flexible(FlexibleEvent),
|
||||||
Editor(EditorEvent),
|
Editor(EditorEvent),
|
||||||
InlineCompletion(InlineCompletionEvent),
|
EditPrediction(EditPredictionEvent),
|
||||||
InlineCompletionRating(InlineCompletionRatingEvent),
|
EditPredictionRating(EditPredictionRatingEvent),
|
||||||
Call(CallEvent),
|
Call(CallEvent),
|
||||||
Assistant(AssistantEventData),
|
Assistant(AssistantEventData),
|
||||||
Cpu(CpuEvent),
|
Cpu(CpuEvent),
|
||||||
|
@ -132,7 +132,7 @@ pub struct EditorEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct InlineCompletionEvent {
|
pub struct EditPredictionEvent {
|
||||||
/// Provider of the completion suggestion (e.g. copilot, supermaven)
|
/// Provider of the completion suggestion (e.g. copilot, supermaven)
|
||||||
pub provider: String,
|
pub provider: String,
|
||||||
pub suggestion_accepted: bool,
|
pub suggestion_accepted: bool,
|
||||||
|
@ -140,14 +140,14 @@ pub struct InlineCompletionEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum InlineCompletionRating {
|
pub enum EditPredictionRating {
|
||||||
Positive,
|
Positive,
|
||||||
Negative,
|
Negative,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct InlineCompletionRatingEvent {
|
pub struct EditPredictionRatingEvent {
|
||||||
pub rating: InlineCompletionRating,
|
pub rating: EditPredictionRating,
|
||||||
pub input_events: Arc<str>,
|
pub input_events: Arc<str>,
|
||||||
pub input_excerpt: Arc<str>,
|
pub input_excerpt: Arc<str>,
|
||||||
pub output_excerpt: Arc<str>,
|
pub output_excerpt: Arc<str>,
|
||||||
|
|
|
@ -3808,7 +3808,7 @@ mod test {
|
||||||
cx.update_editor(|editor, _window, cx| {
|
cx.update_editor(|editor, _window, cx| {
|
||||||
let range = editor.selections.newest_anchor().range();
|
let range = editor.selections.newest_anchor().range();
|
||||||
let inlay_text = " field: int,\n field2: string\n field3: float";
|
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);
|
editor.splice_inlays(&[], vec![inlay], cx);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3840,7 +3840,7 @@ mod test {
|
||||||
let end_of_line =
|
let end_of_line =
|
||||||
snapshot.anchor_after(Point::new(0, snapshot.line_len(MultiBufferRow(0))));
|
snapshot.anchor_after(Point::new(0, snapshot.line_len(MultiBufferRow(0))));
|
||||||
let inlay_text = " hint";
|
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);
|
editor.splice_inlays(&[], vec![inlay], cx);
|
||||||
});
|
});
|
||||||
cx.simulate_keystrokes("$");
|
cx.simulate_keystrokes("$");
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl Vim {
|
||||||
if let Some(kind) = motion_kind {
|
if let Some(kind) = motion_kind {
|
||||||
vim.copy_selections_content(editor, kind, window, cx);
|
vim.copy_selections_content(editor, kind, window, cx);
|
||||||
editor.insert("", 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 {
|
if objects_found {
|
||||||
vim.copy_selections_content(editor, MotionKind::Exclusive, window, cx);
|
vim.copy_selections_content(editor, MotionKind::Exclusive, window, cx);
|
||||||
editor.insert("", window, cx);
|
editor.insert("", window, cx);
|
||||||
editor.refresh_inline_completion(true, false, window, cx);
|
editor.refresh_edit_prediction(true, false, window, cx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -82,7 +82,7 @@ impl Vim {
|
||||||
selection.collapse_to(cursor, selection.goal)
|
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)
|
selection.collapse_to(cursor, selection.goal)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
editor.refresh_inline_completion(true, false, window, cx);
|
editor.refresh_edit_prediction(true, false, window, cx);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1741,11 +1741,11 @@ impl Vim {
|
||||||
editor.set_autoindent(vim.should_autoindent());
|
editor.set_autoindent(vim.should_autoindent());
|
||||||
editor.selections.line_mode = matches!(vim.mode, Mode::VisualLine);
|
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,
|
Mode::Insert | Mode::Replace => false,
|
||||||
_ => true,
|
_ => 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()
|
cx.notify()
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ gpui_tokio.workspace = true
|
||||||
http_client.workspace = true
|
http_client.workspace = true
|
||||||
image_viewer.workspace = true
|
image_viewer.workspace = true
|
||||||
indoc.workspace = true
|
indoc.workspace = true
|
||||||
inline_completion_button.workspace = true
|
edit_prediction_button.workspace = true
|
||||||
inspector_ui.workspace = true
|
inspector_ui.workspace = true
|
||||||
install_cli.workspace = true
|
install_cli.workspace = true
|
||||||
jj_ui.workspace = true
|
jj_ui.workspace = true
|
||||||
|
|
|
@ -51,9 +51,9 @@ use workspace::{
|
||||||
};
|
};
|
||||||
use zed::{
|
use zed::{
|
||||||
OpenListener, OpenRequest, RawOpenRequest, app_menus, build_window_options,
|
OpenListener, OpenRequest, RawOpenRequest, app_menus, build_window_options,
|
||||||
derive_paths_with_position, handle_cli_connection, handle_keymap_file_changes,
|
derive_paths_with_position, edit_prediction_registry, handle_cli_connection,
|
||||||
handle_settings_changed, handle_settings_file_changes, initialize_workspace,
|
handle_keymap_file_changes, handle_settings_changed, handle_settings_file_changes,
|
||||||
inline_completion_registry, open_paths_with_positions,
|
initialize_workspace, open_paths_with_positions,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::zed::OpenRequestKind;
|
use crate::zed::OpenRequestKind;
|
||||||
|
@ -559,11 +559,7 @@ pub fn main() {
|
||||||
web_search::init(cx);
|
web_search::init(cx);
|
||||||
web_search_providers::init(app_state.client.clone(), cx);
|
web_search_providers::init(app_state.client.clone(), cx);
|
||||||
snippet_provider::init(cx);
|
snippet_provider::init(cx);
|
||||||
inline_completion_registry::init(
|
edit_prediction_registry::init(app_state.client.clone(), app_state.user_store.clone(), cx);
|
||||||
app_state.client.clone(),
|
|
||||||
app_state.user_store.clone(),
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
let prompt_builder = PromptBuilder::load(app_state.fs.clone(), stdout_is_a_pty(), cx);
|
let prompt_builder = PromptBuilder::load(app_state.fs.clone(), stdout_is_a_pty(), cx);
|
||||||
agent_ui::init(
|
agent_ui::init(
|
||||||
app_state.fs.clone(),
|
app_state.fs.clone(),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
mod app_menus;
|
mod app_menus;
|
||||||
pub mod component_preview;
|
pub mod component_preview;
|
||||||
pub mod inline_completion_registry;
|
pub mod edit_prediction_registry;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
pub(crate) mod mac_only_instance;
|
pub(crate) mod mac_only_instance;
|
||||||
mod migrate;
|
mod migrate;
|
||||||
|
@ -332,18 +332,18 @@ pub fn initialize_workspace(
|
||||||
show_software_emulation_warning_if_needed(specs, window, cx);
|
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| {
|
let edit_prediction_button = cx.new(|cx| {
|
||||||
inline_completion_button::InlineCompletionButton::new(
|
edit_prediction_button::EditPredictionButton::new(
|
||||||
app_state.fs.clone(),
|
app_state.fs.clone(),
|
||||||
app_state.user_store.clone(),
|
app_state.user_store.clone(),
|
||||||
inline_completion_menu_handle.clone(),
|
edit_prediction_menu_handle.clone(),
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
workspace.register_action({
|
workspace.register_action({
|
||||||
move |_, _: &inline_completion_button::ToggleMenu, window, cx| {
|
move |_, _: &edit_prediction_button::ToggleMenu, window, cx| {
|
||||||
inline_completion_menu_handle.toggle(window, cx);
|
edit_prediction_menu_handle.toggle(window, cx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ use supermaven::{Supermaven, SupermavenCompletionProvider};
|
||||||
use ui::Window;
|
use ui::Window;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
use zeta::{ProviderDataCollection, ZetaInlineCompletionProvider};
|
use zeta::{ProviderDataCollection, ZetaEditPredictionProvider};
|
||||||
|
|
||||||
pub fn init(client: Arc<Client>, user_store: Entity<UserStore>, cx: &mut App) {
|
pub fn init(client: Arc<Client>, user_store: Entity<UserStore>, cx: &mut App) {
|
||||||
let editors: Rc<RefCell<HashMap<WeakEntity<Editor>, AnyWindowHandle>>> = Rc::default();
|
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
|
editor
|
||||||
.register_action(cx.listener(
|
.register_action(cx.listener(
|
||||||
|editor, _: &copilot::Suggest, window: &mut Window, cx: &mut Context<Editor>| {
|
|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();
|
.detach();
|
||||||
|
@ -207,7 +207,7 @@ fn assign_edit_prediction_provider(
|
||||||
|
|
||||||
match provider {
|
match provider {
|
||||||
EditPredictionProvider::None => {
|
EditPredictionProvider::None => {
|
||||||
editor.set_edit_prediction_provider::<ZetaInlineCompletionProvider>(None, window, cx);
|
editor.set_edit_prediction_provider::<ZetaEditPredictionProvider>(None, window, cx);
|
||||||
}
|
}
|
||||||
EditPredictionProvider::Copilot => {
|
EditPredictionProvider::Copilot => {
|
||||||
if let Some(copilot) = Copilot::global(cx) {
|
if let Some(copilot) = Copilot::global(cx) {
|
||||||
|
@ -265,7 +265,7 @@ fn assign_edit_prediction_provider(
|
||||||
ProviderDataCollection::new(zeta.clone(), singleton_buffer, cx);
|
ProviderDataCollection::new(zeta.clone(), singleton_buffer, cx);
|
||||||
|
|
||||||
let provider =
|
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);
|
editor.set_edit_prediction_provider(Some(provider), window, cx);
|
||||||
}
|
}
|
|
@ -381,7 +381,7 @@ impl Render for QuickActionBar {
|
||||||
}
|
}
|
||||||
|
|
||||||
if has_edit_prediction_provider {
|
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)
|
.toggleable(IconPosition::Start, edit_predictions_enabled_at_cursor && show_edit_predictions)
|
||||||
.disabled(!edit_predictions_enabled_at_cursor)
|
.disabled(!edit_predictions_enabled_at_cursor)
|
||||||
.action(
|
.action(
|
||||||
|
@ -401,12 +401,12 @@ impl Render for QuickActionBar {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if !edit_predictions_enabled_at_cursor {
|
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()
|
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();
|
menu = menu.separator();
|
||||||
|
|
|
@ -33,7 +33,7 @@ futures.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
http_client.workspace = true
|
http_client.workspace = true
|
||||||
indoc.workspace = true
|
indoc.workspace = true
|
||||||
inline_completion.workspace = true
|
edit_prediction.workspace = true
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
language_model.workspace = true
|
language_model.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
|
||||||
use crate::InlineCompletion;
|
use crate::EditPrediction;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AnyElement, App, BorderStyle, Bounds, Corners, Edges, HighlightStyle, Hsla, StyledText,
|
AnyElement, App, BorderStyle, Bounds, Corners, Edges, HighlightStyle, Hsla, StyledText,
|
||||||
TextLayout, TextStyle, point, prelude::*, quad, size,
|
TextLayout, TextStyle, point, prelude::*, quad, size,
|
||||||
|
@ -17,7 +17,7 @@ pub struct CompletionDiffElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompletionDiffElement {
|
impl CompletionDiffElement {
|
||||||
pub fn new(completion: &InlineCompletion, cx: &App) -> Self {
|
pub fn new(completion: &EditPrediction, cx: &App) -> Self {
|
||||||
let mut diff = completion
|
let mut diff = completion
|
||||||
.snapshot
|
.snapshot
|
||||||
.text_for_range(completion.excerpt_range.clone())
|
.text_for_range(completion.excerpt_range.clone())
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{CompletionDiffElement, InlineCompletion, InlineCompletionRating, Zeta};
|
use crate::{CompletionDiffElement, EditPrediction, EditPredictionRating, Zeta};
|
||||||
use editor::Editor;
|
use editor::Editor;
|
||||||
use gpui::{App, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, actions, prelude::*};
|
use gpui::{App, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, actions, prelude::*};
|
||||||
use language::language_settings;
|
use language::language_settings;
|
||||||
|
@ -34,7 +34,7 @@ pub struct RateCompletionModal {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ActiveCompletion {
|
struct ActiveCompletion {
|
||||||
completion: InlineCompletion,
|
completion: EditPrediction,
|
||||||
feedback_editor: Entity<Editor>,
|
feedback_editor: Entity<Editor>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ impl RateCompletionModal {
|
||||||
if let Some(active) = &self.active_completion {
|
if let Some(active) = &self.active_completion {
|
||||||
zeta.rate_completion(
|
zeta.rate_completion(
|
||||||
&active.completion,
|
&active.completion,
|
||||||
InlineCompletionRating::Positive,
|
EditPredictionRating::Positive,
|
||||||
active.feedback_editor.read(cx).text(cx),
|
active.feedback_editor.read(cx).text(cx),
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
@ -189,7 +189,7 @@ impl RateCompletionModal {
|
||||||
self.zeta.update(cx, |zeta, cx| {
|
self.zeta.update(cx, |zeta, cx| {
|
||||||
zeta.rate_completion(
|
zeta.rate_completion(
|
||||||
&active.completion,
|
&active.completion,
|
||||||
InlineCompletionRating::Negative,
|
EditPredictionRating::Negative,
|
||||||
active.feedback_editor.read(cx).text(cx),
|
active.feedback_editor.read(cx).text(cx),
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
@ -250,7 +250,7 @@ impl RateCompletionModal {
|
||||||
|
|
||||||
pub fn select_completion(
|
pub fn select_completion(
|
||||||
&mut self,
|
&mut self,
|
||||||
completion: Option<InlineCompletion>,
|
completion: Option<EditPrediction>,
|
||||||
focus: bool,
|
focus: bool,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
|
|
|
@ -8,8 +8,8 @@ mod rate_completion_modal;
|
||||||
|
|
||||||
pub(crate) use completion_diff_element::*;
|
pub(crate) use completion_diff_element::*;
|
||||||
use db::kvp::{Dismissable, KEY_VALUE_STORE};
|
use db::kvp::{Dismissable, KEY_VALUE_STORE};
|
||||||
|
use edit_prediction::DataCollectionState;
|
||||||
pub use init::*;
|
pub use init::*;
|
||||||
use inline_completion::DataCollectionState;
|
|
||||||
use license_detection::LICENSE_FILES_TO_CHECK;
|
use license_detection::LICENSE_FILES_TO_CHECK;
|
||||||
pub use license_detection::is_license_eligible_for_data_collection;
|
pub use license_detection::is_license_eligible_for_data_collection;
|
||||||
pub use rate_completion_modal::*;
|
pub use rate_completion_modal::*;
|
||||||
|
@ -50,7 +50,7 @@ use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
use telemetry_events::InlineCompletionRating;
|
use telemetry_events::EditPredictionRating;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
@ -81,15 +81,15 @@ actions!(
|
||||||
);
|
);
|
||||||
|
|
||||||
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct InlineCompletionId(Uuid);
|
pub struct EditPredictionId(Uuid);
|
||||||
|
|
||||||
impl From<InlineCompletionId> for gpui::ElementId {
|
impl From<EditPredictionId> for gpui::ElementId {
|
||||||
fn from(value: InlineCompletionId) -> Self {
|
fn from(value: EditPredictionId) -> Self {
|
||||||
gpui::ElementId::Uuid(value.0)
|
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 {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "{}", self.0)
|
write!(f, "{}", self.0)
|
||||||
}
|
}
|
||||||
|
@ -134,8 +134,8 @@ struct ZetaGlobal(Entity<Zeta>);
|
||||||
impl Global for ZetaGlobal {}
|
impl Global for ZetaGlobal {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct InlineCompletion {
|
pub struct EditPrediction {
|
||||||
id: InlineCompletionId,
|
id: EditPredictionId,
|
||||||
path: Arc<Path>,
|
path: Arc<Path>,
|
||||||
excerpt_range: Range<usize>,
|
excerpt_range: Range<usize>,
|
||||||
cursor_offset: usize,
|
cursor_offset: usize,
|
||||||
|
@ -150,7 +150,7 @@ pub struct InlineCompletion {
|
||||||
response_received_at: Instant,
|
response_received_at: Instant,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InlineCompletion {
|
impl EditPrediction {
|
||||||
fn latency(&self) -> Duration {
|
fn latency(&self) -> Duration {
|
||||||
self.response_received_at
|
self.response_received_at
|
||||||
.duration_since(self.buffer_snapshotted_at)
|
.duration_since(self.buffer_snapshotted_at)
|
||||||
|
@ -207,9 +207,9 @@ fn interpolate(
|
||||||
if edits.is_empty() { None } else { Some(edits) }
|
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 {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
f.debug_struct("InlineCompletion")
|
f.debug_struct("EditPrediction")
|
||||||
.field("id", &self.id)
|
.field("id", &self.id)
|
||||||
.field("path", &self.path)
|
.field("path", &self.path)
|
||||||
.field("edits", &self.edits)
|
.field("edits", &self.edits)
|
||||||
|
@ -222,8 +222,8 @@ pub struct Zeta {
|
||||||
client: Arc<Client>,
|
client: Arc<Client>,
|
||||||
events: VecDeque<Event>,
|
events: VecDeque<Event>,
|
||||||
registered_buffers: HashMap<gpui::EntityId, RegisteredBuffer>,
|
registered_buffers: HashMap<gpui::EntityId, RegisteredBuffer>,
|
||||||
shown_completions: VecDeque<InlineCompletion>,
|
shown_completions: VecDeque<EditPrediction>,
|
||||||
rated_completions: HashSet<InlineCompletionId>,
|
rated_completions: HashSet<EditPredictionId>,
|
||||||
data_collection_choice: Entity<DataCollectionChoice>,
|
data_collection_choice: Entity<DataCollectionChoice>,
|
||||||
llm_token: LlmApiToken,
|
llm_token: LlmApiToken,
|
||||||
_llm_token_subscription: Subscription,
|
_llm_token_subscription: Subscription,
|
||||||
|
@ -384,7 +384,7 @@ impl Zeta {
|
||||||
can_collect_data: bool,
|
can_collect_data: bool,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
perform_predict_edits: F,
|
perform_predict_edits: F,
|
||||||
) -> Task<Result<Option<InlineCompletion>>>
|
) -> Task<Result<Option<EditPrediction>>>
|
||||||
where
|
where
|
||||||
F: FnOnce(PerformPredictEditsParams) -> R + 'static,
|
F: FnOnce(PerformPredictEditsParams) -> R + 'static,
|
||||||
R: Future<Output = Result<(PredictEditsResponse, Option<EditPredictionUsage>)>>
|
R: Future<Output = Result<(PredictEditsResponse, Option<EditPredictionUsage>)>>
|
||||||
|
@ -664,7 +664,7 @@ and then another
|
||||||
position: language::Anchor,
|
position: language::Anchor,
|
||||||
response: PredictEditsResponse,
|
response: PredictEditsResponse,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Task<Result<Option<InlineCompletion>>> {
|
) -> Task<Result<Option<EditPrediction>>> {
|
||||||
use std::future::ready;
|
use std::future::ready;
|
||||||
|
|
||||||
self.request_completion_impl(None, project, buffer, position, false, cx, |_params| {
|
self.request_completion_impl(None, project, buffer, position, false, cx, |_params| {
|
||||||
|
@ -679,7 +679,7 @@ and then another
|
||||||
position: language::Anchor,
|
position: language::Anchor,
|
||||||
can_collect_data: bool,
|
can_collect_data: bool,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Task<Result<Option<InlineCompletion>>> {
|
) -> Task<Result<Option<EditPrediction>>> {
|
||||||
let workspace = self
|
let workspace = self
|
||||||
.workspace
|
.workspace
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -773,7 +773,7 @@ and then another
|
||||||
|
|
||||||
fn accept_edit_prediction(
|
fn accept_edit_prediction(
|
||||||
&mut self,
|
&mut self,
|
||||||
request_id: InlineCompletionId,
|
request_id: EditPredictionId,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Task<Result<()>> {
|
) -> Task<Result<()>> {
|
||||||
let client = self.client.clone();
|
let client = self.client.clone();
|
||||||
|
@ -852,7 +852,7 @@ and then another
|
||||||
input_excerpt: String,
|
input_excerpt: String,
|
||||||
buffer_snapshotted_at: Instant,
|
buffer_snapshotted_at: Instant,
|
||||||
cx: &AsyncApp,
|
cx: &AsyncApp,
|
||||||
) -> Task<Result<Option<InlineCompletion>>> {
|
) -> Task<Result<Option<EditPrediction>>> {
|
||||||
let snapshot = snapshot.clone();
|
let snapshot = snapshot.clone();
|
||||||
let request_id = prediction_response.request_id;
|
let request_id = prediction_response.request_id;
|
||||||
let output_excerpt = prediction_response.output_excerpt;
|
let output_excerpt = prediction_response.output_excerpt;
|
||||||
|
@ -884,8 +884,8 @@ and then another
|
||||||
|
|
||||||
let edit_preview = edit_preview.await;
|
let edit_preview = edit_preview.await;
|
||||||
|
|
||||||
Ok(Some(InlineCompletion {
|
Ok(Some(EditPrediction {
|
||||||
id: InlineCompletionId(request_id),
|
id: EditPredictionId(request_id),
|
||||||
path,
|
path,
|
||||||
excerpt_range: editable_range,
|
excerpt_range: editable_range,
|
||||||
cursor_offset,
|
cursor_offset,
|
||||||
|
@ -995,11 +995,11 @@ and then another
|
||||||
.collect()
|
.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)
|
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());
|
self.shown_completions.push_front(completion.clone());
|
||||||
if self.shown_completions.len() > 50 {
|
if self.shown_completions.len() > 50 {
|
||||||
let completion = self.shown_completions.pop_back().unwrap();
|
let completion = self.shown_completions.pop_back().unwrap();
|
||||||
|
@ -1010,8 +1010,8 @@ and then another
|
||||||
|
|
||||||
pub fn rate_completion(
|
pub fn rate_completion(
|
||||||
&mut self,
|
&mut self,
|
||||||
completion: &InlineCompletion,
|
completion: &EditPrediction,
|
||||||
rating: InlineCompletionRating,
|
rating: EditPredictionRating,
|
||||||
feedback: String,
|
feedback: String,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
|
@ -1029,7 +1029,7 @@ and then another
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shown_completions(&self) -> impl DoubleEndedIterator<Item = &InlineCompletion> {
|
pub fn shown_completions(&self) -> impl DoubleEndedIterator<Item = &EditPrediction> {
|
||||||
self.shown_completions.iter()
|
self.shown_completions.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1323,12 +1323,12 @@ impl Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct CurrentInlineCompletion {
|
struct CurrentEditPrediction {
|
||||||
buffer_id: EntityId,
|
buffer_id: EntityId,
|
||||||
completion: InlineCompletion,
|
completion: EditPrediction,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CurrentInlineCompletion {
|
impl CurrentEditPrediction {
|
||||||
fn should_replace_completion(&self, old_completion: &Self, snapshot: &BufferSnapshot) -> bool {
|
fn should_replace_completion(&self, old_completion: &Self, snapshot: &BufferSnapshot) -> bool {
|
||||||
if self.buffer_id != old_completion.buffer_id {
|
if self.buffer_id != old_completion.buffer_id {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1497,17 +1497,17 @@ async fn llm_token_retry(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ZetaInlineCompletionProvider {
|
pub struct ZetaEditPredictionProvider {
|
||||||
zeta: Entity<Zeta>,
|
zeta: Entity<Zeta>,
|
||||||
pending_completions: ArrayVec<PendingCompletion, 2>,
|
pending_completions: ArrayVec<PendingCompletion, 2>,
|
||||||
next_pending_completion_id: usize,
|
next_pending_completion_id: usize,
|
||||||
current_completion: Option<CurrentInlineCompletion>,
|
current_completion: Option<CurrentEditPrediction>,
|
||||||
/// None if this is entirely disabled for this provider
|
/// None if this is entirely disabled for this provider
|
||||||
provider_data_collection: ProviderDataCollection,
|
provider_data_collection: ProviderDataCollection,
|
||||||
last_request_timestamp: Instant,
|
last_request_timestamp: Instant,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ZetaInlineCompletionProvider {
|
impl ZetaEditPredictionProvider {
|
||||||
pub const THROTTLE_TIMEOUT: Duration = Duration::from_millis(300);
|
pub const THROTTLE_TIMEOUT: Duration = Duration::from_millis(300);
|
||||||
|
|
||||||
pub fn new(zeta: Entity<Zeta>, provider_data_collection: ProviderDataCollection) -> Self {
|
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 {
|
fn name() -> &'static str {
|
||||||
"zed-predict"
|
"zed-predict"
|
||||||
}
|
}
|
||||||
|
@ -1650,7 +1650,7 @@ impl inline_completion::EditPredictionProvider for ZetaInlineCompletionProvider
|
||||||
Ok(completion_request) => {
|
Ok(completion_request) => {
|
||||||
let completion_request = completion_request.await;
|
let completion_request = completion_request.await;
|
||||||
completion_request.map(|c| {
|
completion_request.map(|c| {
|
||||||
c.map(|completion| CurrentInlineCompletion {
|
c.map(|completion| CurrentEditPrediction {
|
||||||
buffer_id: buffer.entity_id(),
|
buffer_id: buffer.entity_id(),
|
||||||
completion,
|
completion,
|
||||||
})
|
})
|
||||||
|
@ -1723,7 +1723,7 @@ impl inline_completion::EditPredictionProvider for ZetaInlineCompletionProvider
|
||||||
&mut self,
|
&mut self,
|
||||||
_buffer: Entity<Buffer>,
|
_buffer: Entity<Buffer>,
|
||||||
_cursor_position: language::Anchor,
|
_cursor_position: language::Anchor,
|
||||||
_direction: inline_completion::Direction,
|
_direction: edit_prediction::Direction,
|
||||||
_cx: &mut Context<Self>,
|
_cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
// Right now we don't support cycling.
|
// Right now we don't support cycling.
|
||||||
|
@ -1754,8 +1754,8 @@ impl inline_completion::EditPredictionProvider for ZetaInlineCompletionProvider
|
||||||
buffer: &Entity<Buffer>,
|
buffer: &Entity<Buffer>,
|
||||||
cursor_position: language::Anchor,
|
cursor_position: language::Anchor,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Option<inline_completion::InlineCompletion> {
|
) -> Option<edit_prediction::EditPrediction> {
|
||||||
let CurrentInlineCompletion {
|
let CurrentEditPrediction {
|
||||||
buffer_id,
|
buffer_id,
|
||||||
completion,
|
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()),
|
id: Some(completion.id.to_string().into()),
|
||||||
edits: edits[edit_start_ix..edit_end_ix].to_vec(),
|
edits: edits[edit_start_ix..edit_end_ix].to_vec(),
|
||||||
edit_preview: Some(completion.edit_preview.clone()),
|
edit_preview: Some(completion.edit_preview.clone()),
|
||||||
|
@ -1833,7 +1833,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[gpui::test]
|
#[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 buffer = cx.new(|cx| Buffer::local("Lorem ipsum dolor", cx));
|
||||||
let edits: Arc<[(Range<Anchor>, String)]> = cx.update(|cx| {
|
let edits: Arc<[(Range<Anchor>, String)]> = cx.update(|cx| {
|
||||||
to_completion_edits(
|
to_completion_edits(
|
||||||
|
@ -1848,12 +1848,12 @@ mod tests {
|
||||||
.read(|cx| buffer.read(cx).preview_edits(edits.clone(), cx))
|
.read(|cx| buffer.read(cx).preview_edits(edits.clone(), cx))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let completion = InlineCompletion {
|
let completion = EditPrediction {
|
||||||
edits,
|
edits,
|
||||||
edit_preview,
|
edit_preview,
|
||||||
path: Path::new("").into(),
|
path: Path::new("").into(),
|
||||||
snapshot: cx.read(|cx| buffer.read(cx).snapshot()),
|
snapshot: cx.read(|cx| buffer.read(cx).snapshot()),
|
||||||
id: InlineCompletionId(Uuid::new_v4()),
|
id: EditPredictionId(Uuid::new_v4()),
|
||||||
excerpt_range: 0..0,
|
excerpt_range: 0..0,
|
||||||
cursor_offset: 0,
|
cursor_offset: 0,
|
||||||
input_outline: "".into(),
|
input_outline: "".into(),
|
||||||
|
@ -2014,7 +2014,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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| {
|
cx.update(|cx| {
|
||||||
let settings_store = SettingsStore::test(cx);
|
let settings_store = SettingsStore::test(cx);
|
||||||
cx.set_global(settings_store);
|
cx.set_global(settings_store);
|
||||||
|
|
|
@ -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).
|
> **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}
|
### Google AI {#google-ai}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ For example:
|
||||||
# in an editor, it might look like this:
|
# in an editor, it might look like this:
|
||||||
Workspace os=macos keyboard_layout=com.apple.keylayout.QWERTY
|
Workspace os=macos keyboard_layout=com.apple.keylayout.QWERTY
|
||||||
Pane
|
Pane
|
||||||
Editor mode=full extension=md inline_completion vim_mode=insert
|
Editor mode=full extension=md vim_mode=insert
|
||||||
|
|
||||||
# in the project panel
|
# in the project panel
|
||||||
Workspace os=macos
|
Workspace os=macos
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue