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
|
@ -48,7 +48,7 @@ fs.workspace = true
|
|||
git.workspace = true
|
||||
gpui.workspace = true
|
||||
indoc.workspace = true
|
||||
inline_completion.workspace = true
|
||||
edit_prediction.workspace = true
|
||||
itertools.workspace = true
|
||||
language.workspace = true
|
||||
linkify.workspace = true
|
||||
|
|
|
@ -635,7 +635,7 @@ pub(crate) struct Highlights<'a> {
|
|||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct InlineCompletionStyles {
|
||||
pub struct EditPredictionStyles {
|
||||
pub insertion: HighlightStyle,
|
||||
pub whitespace: HighlightStyle,
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ pub struct InlineCompletionStyles {
|
|||
#[derive(Default, Debug, Clone, Copy)]
|
||||
pub struct HighlightStyles {
|
||||
pub inlay_hint: Option<HighlightStyle>,
|
||||
pub inline_completion: Option<InlineCompletionStyles>,
|
||||
pub edit_prediction: Option<EditPredictionStyles>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -958,7 +958,7 @@ impl DisplaySnapshot {
|
|||
language_aware,
|
||||
HighlightStyles {
|
||||
inlay_hint: Some(editor_style.inlay_hints_style),
|
||||
inline_completion: Some(editor_style.inline_completion_styles),
|
||||
edit_prediction: Some(editor_style.edit_prediction_styles),
|
||||
},
|
||||
)
|
||||
.flat_map(|chunk| {
|
||||
|
@ -2036,7 +2036,7 @@ pub mod tests {
|
|||
map.update(cx, |map, cx| {
|
||||
map.splice_inlays(
|
||||
&[],
|
||||
vec![Inlay::inline_completion(
|
||||
vec![Inlay::edit_prediction(
|
||||
0,
|
||||
buffer_snapshot.anchor_after(0),
|
||||
"\n",
|
||||
|
|
|
@ -81,9 +81,9 @@ impl Inlay {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn inline_completion<T: Into<Rope>>(id: usize, position: Anchor, text: T) -> Self {
|
||||
pub fn edit_prediction<T: Into<Rope>>(id: usize, position: Anchor, text: T) -> Self {
|
||||
Self {
|
||||
id: InlayId::InlineCompletion(id),
|
||||
id: InlayId::EditPrediction(id),
|
||||
position,
|
||||
text: text.into(),
|
||||
color: None,
|
||||
|
@ -340,15 +340,13 @@ impl<'a> Iterator for InlayChunks<'a> {
|
|||
|
||||
let mut renderer = None;
|
||||
let mut highlight_style = match inlay.id {
|
||||
InlayId::InlineCompletion(_) => {
|
||||
self.highlight_styles.inline_completion.map(|s| {
|
||||
if inlay.text.chars().all(|c| c.is_whitespace()) {
|
||||
s.whitespace
|
||||
} else {
|
||||
s.insertion
|
||||
}
|
||||
})
|
||||
}
|
||||
InlayId::EditPrediction(_) => self.highlight_styles.edit_prediction.map(|s| {
|
||||
if inlay.text.chars().all(|c| c.is_whitespace()) {
|
||||
s.whitespace
|
||||
} else {
|
||||
s.insertion
|
||||
}
|
||||
}),
|
||||
InlayId::Hint(_) => self.highlight_styles.inlay_hint,
|
||||
InlayId::DebuggerValue(_) => self.highlight_styles.inlay_hint,
|
||||
InlayId::Color(_) => {
|
||||
|
@ -740,7 +738,7 @@ impl InlayMap {
|
|||
text.clone(),
|
||||
)
|
||||
} else {
|
||||
Inlay::inline_completion(
|
||||
Inlay::edit_prediction(
|
||||
post_inc(next_inlay_id),
|
||||
snapshot.buffer.anchor_at(position, bias),
|
||||
text.clone(),
|
||||
|
@ -1389,7 +1387,7 @@ mod tests {
|
|||
buffer.read(cx).snapshot(cx).anchor_before(3),
|
||||
"|123|",
|
||||
),
|
||||
Inlay::inline_completion(
|
||||
Inlay::edit_prediction(
|
||||
post_inc(&mut next_inlay_id),
|
||||
buffer.read(cx).snapshot(cx).anchor_after(3),
|
||||
"|456|",
|
||||
|
@ -1609,7 +1607,7 @@ mod tests {
|
|||
buffer.read(cx).snapshot(cx).anchor_before(4),
|
||||
"|456|",
|
||||
),
|
||||
Inlay::inline_completion(
|
||||
Inlay::edit_prediction(
|
||||
post_inc(&mut next_inlay_id),
|
||||
buffer.read(cx).snapshot(cx).anchor_before(7),
|
||||
"\n|567|\n",
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
use edit_prediction::EditPredictionProvider;
|
||||
use gpui::{Entity, prelude::*};
|
||||
use indoc::indoc;
|
||||
use inline_completion::EditPredictionProvider;
|
||||
use multi_buffer::{Anchor, MultiBufferSnapshot, ToPoint};
|
||||
use project::Project;
|
||||
use std::ops::Range;
|
||||
use text::{Point, ToOffset};
|
||||
|
||||
use crate::{
|
||||
InlineCompletion, editor_tests::init_test, test::editor_test_context::EditorTestContext,
|
||||
EditPrediction, editor_tests::init_test, test::editor_test_context::EditorTestContext,
|
||||
};
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_inline_completion_insert(cx: &mut gpui::TestAppContext) {
|
||||
async fn test_edit_prediction_insert(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
let mut cx = EditorTestContext::new(cx).await;
|
||||
let provider = cx.new(|_| FakeInlineCompletionProvider::default());
|
||||
let provider = cx.new(|_| FakeEditPredictionProvider::default());
|
||||
assign_editor_completion_provider(provider.clone(), &mut cx);
|
||||
cx.set_state("let absolute_zero_celsius = ˇ;");
|
||||
|
||||
propose_edits(&provider, vec![(28..28, "-273.15")], &mut cx);
|
||||
cx.update_editor(|editor, window, cx| editor.update_visible_inline_completion(window, cx));
|
||||
cx.update_editor(|editor, window, cx| editor.update_visible_edit_prediction(window, cx));
|
||||
|
||||
assert_editor_active_edit_completion(&mut cx, |_, edits| {
|
||||
assert_eq!(edits.len(), 1);
|
||||
|
@ -33,16 +33,16 @@ async fn test_inline_completion_insert(cx: &mut gpui::TestAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_inline_completion_modification(cx: &mut gpui::TestAppContext) {
|
||||
async fn test_edit_prediction_modification(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
let mut cx = EditorTestContext::new(cx).await;
|
||||
let provider = cx.new(|_| FakeInlineCompletionProvider::default());
|
||||
let provider = cx.new(|_| FakeEditPredictionProvider::default());
|
||||
assign_editor_completion_provider(provider.clone(), &mut cx);
|
||||
cx.set_state("let pi = ˇ\"foo\";");
|
||||
|
||||
propose_edits(&provider, vec![(9..14, "3.14159")], &mut cx);
|
||||
cx.update_editor(|editor, window, cx| editor.update_visible_inline_completion(window, cx));
|
||||
cx.update_editor(|editor, window, cx| editor.update_visible_edit_prediction(window, cx));
|
||||
|
||||
assert_editor_active_edit_completion(&mut cx, |_, edits| {
|
||||
assert_eq!(edits.len(), 1);
|
||||
|
@ -55,11 +55,11 @@ async fn test_inline_completion_modification(cx: &mut gpui::TestAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_inline_completion_jump_button(cx: &mut gpui::TestAppContext) {
|
||||
async fn test_edit_prediction_jump_button(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
let mut cx = EditorTestContext::new(cx).await;
|
||||
let provider = cx.new(|_| FakeInlineCompletionProvider::default());
|
||||
let provider = cx.new(|_| FakeEditPredictionProvider::default());
|
||||
assign_editor_completion_provider(provider.clone(), &mut cx);
|
||||
|
||||
// Cursor is 2+ lines above the proposed edit
|
||||
|
@ -77,7 +77,7 @@ async fn test_inline_completion_jump_button(cx: &mut gpui::TestAppContext) {
|
|||
&mut cx,
|
||||
);
|
||||
|
||||
cx.update_editor(|editor, window, cx| editor.update_visible_inline_completion(window, cx));
|
||||
cx.update_editor(|editor, window, cx| editor.update_visible_edit_prediction(window, cx));
|
||||
assert_editor_active_move_completion(&mut cx, |snapshot, move_target| {
|
||||
assert_eq!(move_target.to_point(&snapshot), Point::new(4, 3));
|
||||
});
|
||||
|
@ -107,7 +107,7 @@ async fn test_inline_completion_jump_button(cx: &mut gpui::TestAppContext) {
|
|||
&mut cx,
|
||||
);
|
||||
|
||||
cx.update_editor(|editor, window, cx| editor.update_visible_inline_completion(window, cx));
|
||||
cx.update_editor(|editor, window, cx| editor.update_visible_edit_prediction(window, cx));
|
||||
assert_editor_active_move_completion(&mut cx, |snapshot, move_target| {
|
||||
assert_eq!(move_target.to_point(&snapshot), Point::new(1, 3));
|
||||
});
|
||||
|
@ -124,11 +124,11 @@ async fn test_inline_completion_jump_button(cx: &mut gpui::TestAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_inline_completion_invalidation_range(cx: &mut gpui::TestAppContext) {
|
||||
async fn test_edit_prediction_invalidation_range(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
let mut cx = EditorTestContext::new(cx).await;
|
||||
let provider = cx.new(|_| FakeInlineCompletionProvider::default());
|
||||
let provider = cx.new(|_| FakeEditPredictionProvider::default());
|
||||
assign_editor_completion_provider(provider.clone(), &mut cx);
|
||||
|
||||
// Cursor is 3+ lines above the proposed edit
|
||||
|
@ -148,7 +148,7 @@ async fn test_inline_completion_invalidation_range(cx: &mut gpui::TestAppContext
|
|||
&mut cx,
|
||||
);
|
||||
|
||||
cx.update_editor(|editor, window, cx| editor.update_visible_inline_completion(window, cx));
|
||||
cx.update_editor(|editor, window, cx| editor.update_visible_edit_prediction(window, cx));
|
||||
assert_editor_active_move_completion(&mut cx, |snapshot, move_target| {
|
||||
assert_eq!(move_target.to_point(&snapshot), edit_location);
|
||||
});
|
||||
|
@ -176,7 +176,7 @@ async fn test_inline_completion_invalidation_range(cx: &mut gpui::TestAppContext
|
|||
line
|
||||
"});
|
||||
cx.editor(|editor, _, _| {
|
||||
assert!(editor.active_inline_completion.is_none());
|
||||
assert!(editor.active_edit_prediction.is_none());
|
||||
});
|
||||
|
||||
// Cursor is 3+ lines below the proposed edit
|
||||
|
@ -196,7 +196,7 @@ async fn test_inline_completion_invalidation_range(cx: &mut gpui::TestAppContext
|
|||
&mut cx,
|
||||
);
|
||||
|
||||
cx.update_editor(|editor, window, cx| editor.update_visible_inline_completion(window, cx));
|
||||
cx.update_editor(|editor, window, cx| editor.update_visible_edit_prediction(window, cx));
|
||||
assert_editor_active_move_completion(&mut cx, |snapshot, move_target| {
|
||||
assert_eq!(move_target.to_point(&snapshot), edit_location);
|
||||
});
|
||||
|
@ -224,7 +224,7 @@ async fn test_inline_completion_invalidation_range(cx: &mut gpui::TestAppContext
|
|||
line ˇ5
|
||||
"});
|
||||
cx.editor(|editor, _, _| {
|
||||
assert!(editor.active_inline_completion.is_none());
|
||||
assert!(editor.active_edit_prediction.is_none());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -234,11 +234,11 @@ fn assert_editor_active_edit_completion(
|
|||
) {
|
||||
cx.editor(|editor, _, cx| {
|
||||
let completion_state = editor
|
||||
.active_inline_completion
|
||||
.active_edit_prediction
|
||||
.as_ref()
|
||||
.expect("editor has no active completion");
|
||||
|
||||
if let InlineCompletion::Edit { edits, .. } = &completion_state.completion {
|
||||
if let EditPrediction::Edit { edits, .. } = &completion_state.completion {
|
||||
assert(editor.buffer().read(cx).snapshot(cx), edits);
|
||||
} else {
|
||||
panic!("expected edit completion");
|
||||
|
@ -252,11 +252,11 @@ fn assert_editor_active_move_completion(
|
|||
) {
|
||||
cx.editor(|editor, _, cx| {
|
||||
let completion_state = editor
|
||||
.active_inline_completion
|
||||
.active_edit_prediction
|
||||
.as_ref()
|
||||
.expect("editor has no active completion");
|
||||
|
||||
if let InlineCompletion::Move { target, .. } = &completion_state.completion {
|
||||
if let EditPrediction::Move { target, .. } = &completion_state.completion {
|
||||
assert(editor.buffer().read(cx).snapshot(cx), *target);
|
||||
} else {
|
||||
panic!("expected move completion");
|
||||
|
@ -271,7 +271,7 @@ fn accept_completion(cx: &mut EditorTestContext) {
|
|||
}
|
||||
|
||||
fn propose_edits<T: ToOffset>(
|
||||
provider: &Entity<FakeInlineCompletionProvider>,
|
||||
provider: &Entity<FakeEditPredictionProvider>,
|
||||
edits: Vec<(Range<T>, &str)>,
|
||||
cx: &mut EditorTestContext,
|
||||
) {
|
||||
|
@ -283,7 +283,7 @@ fn propose_edits<T: ToOffset>(
|
|||
|
||||
cx.update(|_, cx| {
|
||||
provider.update(cx, |provider, _| {
|
||||
provider.set_inline_completion(Some(inline_completion::InlineCompletion {
|
||||
provider.set_edit_prediction(Some(edit_prediction::EditPrediction {
|
||||
id: None,
|
||||
edits: edits.collect(),
|
||||
edit_preview: None,
|
||||
|
@ -293,7 +293,7 @@ fn propose_edits<T: ToOffset>(
|
|||
}
|
||||
|
||||
fn assign_editor_completion_provider(
|
||||
provider: Entity<FakeInlineCompletionProvider>,
|
||||
provider: Entity<FakeEditPredictionProvider>,
|
||||
cx: &mut EditorTestContext,
|
||||
) {
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
|
@ -302,20 +302,17 @@ fn assign_editor_completion_provider(
|
|||
}
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
pub struct FakeInlineCompletionProvider {
|
||||
pub completion: Option<inline_completion::InlineCompletion>,
|
||||
pub struct FakeEditPredictionProvider {
|
||||
pub completion: Option<edit_prediction::EditPrediction>,
|
||||
}
|
||||
|
||||
impl FakeInlineCompletionProvider {
|
||||
pub fn set_inline_completion(
|
||||
&mut self,
|
||||
completion: Option<inline_completion::InlineCompletion>,
|
||||
) {
|
||||
impl FakeEditPredictionProvider {
|
||||
pub fn set_edit_prediction(&mut self, completion: Option<edit_prediction::EditPrediction>) {
|
||||
self.completion = completion;
|
||||
}
|
||||
}
|
||||
|
||||
impl EditPredictionProvider for FakeInlineCompletionProvider {
|
||||
impl EditPredictionProvider for FakeEditPredictionProvider {
|
||||
fn name() -> &'static str {
|
||||
"fake-completion-provider"
|
||||
}
|
||||
|
@ -355,7 +352,7 @@ impl EditPredictionProvider for FakeInlineCompletionProvider {
|
|||
&mut self,
|
||||
_buffer: gpui::Entity<language::Buffer>,
|
||||
_cursor_position: language::Anchor,
|
||||
_direction: inline_completion::Direction,
|
||||
_direction: edit_prediction::Direction,
|
||||
_cx: &mut gpui::Context<Self>,
|
||||
) {
|
||||
}
|
||||
|
@ -369,7 +366,7 @@ impl EditPredictionProvider for FakeInlineCompletionProvider {
|
|||
_buffer: &gpui::Entity<language::Buffer>,
|
||||
_cursor_position: language::Anchor,
|
||||
_cx: &mut gpui::Context<Self>,
|
||||
) -> Option<inline_completion::InlineCompletion> {
|
||||
) -> Option<edit_prediction::EditPrediction> {
|
||||
self.completion.clone()
|
||||
}
|
||||
}
|
|
@ -43,15 +43,16 @@ pub mod tasks;
|
|||
#[cfg(test)]
|
||||
mod code_completion_tests;
|
||||
#[cfg(test)]
|
||||
mod editor_tests;
|
||||
mod edit_prediction_tests;
|
||||
#[cfg(test)]
|
||||
mod inline_completion_tests;
|
||||
mod editor_tests;
|
||||
mod signature_help;
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub mod test;
|
||||
|
||||
pub(crate) use actions::*;
|
||||
pub use display_map::{ChunkRenderer, ChunkRendererContext, DisplayPoint, FoldPlaceholder};
|
||||
pub use edit_prediction::Direction;
|
||||
pub use editor_settings::{
|
||||
CurrentLineHighlight, DocumentColorsRenderMode, EditorSettings, HideMouseMode,
|
||||
ScrollBeyondLastLine, ScrollbarAxes, SearchSettings, ShowMinimap, ShowScrollbar,
|
||||
|
@ -62,7 +63,6 @@ pub use element::{
|
|||
};
|
||||
pub use git::blame::BlameRenderer;
|
||||
pub use hover_popover::hover_markdown_style;
|
||||
pub use inline_completion::Direction;
|
||||
pub use items::MAX_TAB_TITLE_LEN;
|
||||
pub use lsp::CompletionContext;
|
||||
pub use lsp_ext::lsp_tasks;
|
||||
|
@ -93,6 +93,7 @@ use collections::{BTreeMap, HashMap, HashSet, VecDeque};
|
|||
use convert_case::{Case, Casing};
|
||||
use dap::TelemetrySpawnLocation;
|
||||
use display_map::*;
|
||||
use edit_prediction::{EditPredictionProvider, EditPredictionProviderHandle};
|
||||
use editor_settings::{GoToDefinitionFallback, Minimap as MinimapSettings};
|
||||
use element::{AcceptEditPredictionBinding, LineWithInvisibles, PositionMap, layout_line};
|
||||
use futures::{
|
||||
|
@ -117,7 +118,6 @@ use hover_links::{HoverLink, HoveredLinkState, InlayHighlight, find_file};
|
|||
use hover_popover::{HoverState, hide_hover};
|
||||
use indent_guides::ActiveIndentGuidesState;
|
||||
use inlay_hint_cache::{InlayHintCache, InlaySplice, InvalidationStrategy};
|
||||
use inline_completion::{EditPredictionProvider, InlineCompletionProviderHandle};
|
||||
use itertools::Itertools;
|
||||
use language::{
|
||||
AutoindentMode, BlockCommentConfig, BracketMatch, BracketPair, Buffer, BufferRow,
|
||||
|
@ -268,7 +268,7 @@ impl InlineValueCache {
|
|||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub enum InlayId {
|
||||
InlineCompletion(usize),
|
||||
EditPrediction(usize),
|
||||
DebuggerValue(usize),
|
||||
// LSP
|
||||
Hint(usize),
|
||||
|
@ -278,7 +278,7 @@ pub enum InlayId {
|
|||
impl InlayId {
|
||||
fn id(&self) -> usize {
|
||||
match self {
|
||||
Self::InlineCompletion(id) => *id,
|
||||
Self::EditPrediction(id) => *id,
|
||||
Self::DebuggerValue(id) => *id,
|
||||
Self::Hint(id) => *id,
|
||||
Self::Color(id) => *id,
|
||||
|
@ -547,7 +547,7 @@ pub struct EditorStyle {
|
|||
pub syntax: Arc<SyntaxTheme>,
|
||||
pub status: StatusColors,
|
||||
pub inlay_hints_style: HighlightStyle,
|
||||
pub inline_completion_styles: InlineCompletionStyles,
|
||||
pub edit_prediction_styles: EditPredictionStyles,
|
||||
pub unnecessary_code_fade: f32,
|
||||
pub show_underlines: bool,
|
||||
}
|
||||
|
@ -566,7 +566,7 @@ impl Default for EditorStyle {
|
|||
// style and retrieve them directly from the theme.
|
||||
status: StatusColors::dark(),
|
||||
inlay_hints_style: HighlightStyle::default(),
|
||||
inline_completion_styles: InlineCompletionStyles {
|
||||
edit_prediction_styles: EditPredictionStyles {
|
||||
insertion: HighlightStyle::default(),
|
||||
whitespace: HighlightStyle::default(),
|
||||
},
|
||||
|
@ -588,8 +588,8 @@ pub fn make_inlay_hints_style(cx: &mut App) -> HighlightStyle {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn make_suggestion_styles(cx: &mut App) -> InlineCompletionStyles {
|
||||
InlineCompletionStyles {
|
||||
pub fn make_suggestion_styles(cx: &mut App) -> EditPredictionStyles {
|
||||
EditPredictionStyles {
|
||||
insertion: HighlightStyle {
|
||||
color: Some(cx.theme().status().predictive),
|
||||
..HighlightStyle::default()
|
||||
|
@ -609,7 +609,7 @@ pub(crate) enum EditDisplayMode {
|
|||
Inline,
|
||||
}
|
||||
|
||||
enum InlineCompletion {
|
||||
enum EditPrediction {
|
||||
Edit {
|
||||
edits: Vec<(Range<Anchor>, String)>,
|
||||
edit_preview: Option<EditPreview>,
|
||||
|
@ -622,9 +622,9 @@ enum InlineCompletion {
|
|||
},
|
||||
}
|
||||
|
||||
struct InlineCompletionState {
|
||||
struct EditPredictionState {
|
||||
inlay_ids: Vec<InlayId>,
|
||||
completion: InlineCompletion,
|
||||
completion: EditPrediction,
|
||||
completion_id: Option<SharedString>,
|
||||
invalidation_range: Range<Anchor>,
|
||||
}
|
||||
|
@ -637,7 +637,7 @@ enum EditPredictionSettings {
|
|||
},
|
||||
}
|
||||
|
||||
enum InlineCompletionHighlight {}
|
||||
enum EditPredictionHighlight {}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct InlineDiagnostic {
|
||||
|
@ -648,7 +648,7 @@ struct InlineDiagnostic {
|
|||
severity: lsp::DiagnosticSeverity,
|
||||
}
|
||||
|
||||
pub enum MenuInlineCompletionsPolicy {
|
||||
pub enum MenuEditPredictionsPolicy {
|
||||
Never,
|
||||
ByProvider,
|
||||
}
|
||||
|
@ -1087,15 +1087,15 @@ pub struct Editor {
|
|||
pending_mouse_down: Option<Rc<RefCell<Option<MouseDownEvent>>>>,
|
||||
gutter_hovered: bool,
|
||||
hovered_link_state: Option<HoveredLinkState>,
|
||||
edit_prediction_provider: Option<RegisteredInlineCompletionProvider>,
|
||||
edit_prediction_provider: Option<RegisteredEditPredictionProvider>,
|
||||
code_action_providers: Vec<Rc<dyn CodeActionProvider>>,
|
||||
active_inline_completion: Option<InlineCompletionState>,
|
||||
active_edit_prediction: Option<EditPredictionState>,
|
||||
/// Used to prevent flickering as the user types while the menu is open
|
||||
stale_inline_completion_in_menu: Option<InlineCompletionState>,
|
||||
stale_edit_prediction_in_menu: Option<EditPredictionState>,
|
||||
edit_prediction_settings: EditPredictionSettings,
|
||||
inline_completions_hidden_for_vim_mode: bool,
|
||||
show_inline_completions_override: Option<bool>,
|
||||
menu_inline_completions_policy: MenuInlineCompletionsPolicy,
|
||||
edit_predictions_hidden_for_vim_mode: bool,
|
||||
show_edit_predictions_override: Option<bool>,
|
||||
menu_edit_predictions_policy: MenuEditPredictionsPolicy,
|
||||
edit_prediction_preview: EditPredictionPreview,
|
||||
edit_prediction_indent_conflict: bool,
|
||||
edit_prediction_requires_modifier_in_indent_conflict: bool,
|
||||
|
@ -1510,8 +1510,8 @@ pub struct RenameState {
|
|||
|
||||
struct InvalidationStack<T>(Vec<T>);
|
||||
|
||||
struct RegisteredInlineCompletionProvider {
|
||||
provider: Arc<dyn InlineCompletionProviderHandle>,
|
||||
struct RegisteredEditPredictionProvider {
|
||||
provider: Arc<dyn EditPredictionProviderHandle>,
|
||||
_subscription: Subscription,
|
||||
}
|
||||
|
||||
|
@ -2096,8 +2096,8 @@ impl Editor {
|
|||
pending_mouse_down: None,
|
||||
hovered_link_state: None,
|
||||
edit_prediction_provider: None,
|
||||
active_inline_completion: None,
|
||||
stale_inline_completion_in_menu: None,
|
||||
active_edit_prediction: None,
|
||||
stale_edit_prediction_in_menu: None,
|
||||
edit_prediction_preview: EditPredictionPreview::Inactive {
|
||||
released_too_fast: false,
|
||||
},
|
||||
|
@ -2116,9 +2116,9 @@ impl Editor {
|
|||
hovered_cursors: HashMap::default(),
|
||||
next_editor_action_id: EditorActionId::default(),
|
||||
editor_actions: Rc::default(),
|
||||
inline_completions_hidden_for_vim_mode: false,
|
||||
show_inline_completions_override: None,
|
||||
menu_inline_completions_policy: MenuInlineCompletionsPolicy::ByProvider,
|
||||
edit_predictions_hidden_for_vim_mode: false,
|
||||
show_edit_predictions_override: None,
|
||||
menu_edit_predictions_policy: MenuEditPredictionsPolicy::ByProvider,
|
||||
edit_prediction_settings: EditPredictionSettings::Disabled,
|
||||
edit_prediction_indent_conflict: false,
|
||||
edit_prediction_requires_modifier_in_indent_conflict: true,
|
||||
|
@ -2350,7 +2350,7 @@ impl Editor {
|
|||
}
|
||||
|
||||
pub fn key_context(&self, window: &Window, cx: &App) -> KeyContext {
|
||||
self.key_context_internal(self.has_active_inline_completion(), window, cx)
|
||||
self.key_context_internal(self.has_active_edit_prediction(), window, cx)
|
||||
}
|
||||
|
||||
fn key_context_internal(
|
||||
|
@ -2717,17 +2717,16 @@ impl Editor {
|
|||
) where
|
||||
T: EditPredictionProvider,
|
||||
{
|
||||
self.edit_prediction_provider =
|
||||
provider.map(|provider| RegisteredInlineCompletionProvider {
|
||||
_subscription: cx.observe_in(&provider, window, |this, _, window, cx| {
|
||||
if this.focus_handle.is_focused(window) {
|
||||
this.update_visible_inline_completion(window, cx);
|
||||
}
|
||||
}),
|
||||
provider: Arc::new(provider),
|
||||
});
|
||||
self.edit_prediction_provider = provider.map(|provider| RegisteredEditPredictionProvider {
|
||||
_subscription: cx.observe_in(&provider, window, |this, _, window, cx| {
|
||||
if this.focus_handle.is_focused(window) {
|
||||
this.update_visible_edit_prediction(window, cx);
|
||||
}
|
||||
}),
|
||||
provider: Arc::new(provider),
|
||||
});
|
||||
self.update_edit_prediction_settings(cx);
|
||||
self.refresh_inline_completion(false, false, window, cx);
|
||||
self.refresh_edit_prediction(false, false, window, cx);
|
||||
}
|
||||
|
||||
pub fn placeholder_text(&self) -> Option<&str> {
|
||||
|
@ -2798,24 +2797,24 @@ impl Editor {
|
|||
self.input_enabled = input_enabled;
|
||||
}
|
||||
|
||||
pub fn set_inline_completions_hidden_for_vim_mode(
|
||||
pub fn set_edit_predictions_hidden_for_vim_mode(
|
||||
&mut self,
|
||||
hidden: bool,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if hidden != self.inline_completions_hidden_for_vim_mode {
|
||||
self.inline_completions_hidden_for_vim_mode = hidden;
|
||||
if hidden != self.edit_predictions_hidden_for_vim_mode {
|
||||
self.edit_predictions_hidden_for_vim_mode = hidden;
|
||||
if hidden {
|
||||
self.update_visible_inline_completion(window, cx);
|
||||
self.update_visible_edit_prediction(window, cx);
|
||||
} else {
|
||||
self.refresh_inline_completion(true, false, window, cx);
|
||||
self.refresh_edit_prediction(true, false, window, cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_menu_inline_completions_policy(&mut self, value: MenuInlineCompletionsPolicy) {
|
||||
self.menu_inline_completions_policy = value;
|
||||
pub fn set_menu_edit_predictions_policy(&mut self, value: MenuEditPredictionsPolicy) {
|
||||
self.menu_edit_predictions_policy = value;
|
||||
}
|
||||
|
||||
pub fn set_autoindent(&mut self, autoindent: bool) {
|
||||
|
@ -2852,7 +2851,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if self.show_inline_completions_override.is_some() {
|
||||
if self.show_edit_predictions_override.is_some() {
|
||||
self.set_show_edit_predictions(None, window, cx);
|
||||
} else {
|
||||
let show_edit_predictions = !self.edit_predictions_enabled();
|
||||
|
@ -2866,17 +2865,17 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.show_inline_completions_override = show_edit_predictions;
|
||||
self.show_edit_predictions_override = show_edit_predictions;
|
||||
self.update_edit_prediction_settings(cx);
|
||||
|
||||
if let Some(false) = show_edit_predictions {
|
||||
self.discard_inline_completion(false, cx);
|
||||
self.discard_edit_prediction(false, cx);
|
||||
} else {
|
||||
self.refresh_inline_completion(false, true, window, cx);
|
||||
self.refresh_edit_prediction(false, true, window, cx);
|
||||
}
|
||||
}
|
||||
|
||||
fn inline_completions_disabled_in_scope(
|
||||
fn edit_predictions_disabled_in_scope(
|
||||
&self,
|
||||
buffer: &Entity<Buffer>,
|
||||
buffer_position: language::Anchor,
|
||||
|
@ -3043,7 +3042,7 @@ impl Editor {
|
|||
self.refresh_document_highlights(cx);
|
||||
self.refresh_selected_text_highlights(false, window, cx);
|
||||
refresh_matching_bracket_highlights(self, window, cx);
|
||||
self.update_visible_inline_completion(window, cx);
|
||||
self.update_visible_edit_prediction(window, cx);
|
||||
self.edit_prediction_requires_modifier_in_indent_conflict = true;
|
||||
linked_editing_ranges::refresh_linked_ranges(self, window, cx);
|
||||
self.inline_blame_popover.take();
|
||||
|
@ -3833,7 +3832,7 @@ impl Editor {
|
|||
return true;
|
||||
}
|
||||
|
||||
if is_user_requested && self.discard_inline_completion(true, cx) {
|
||||
if is_user_requested && self.discard_edit_prediction(true, cx) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -4239,7 +4238,7 @@ impl Editor {
|
|||
);
|
||||
}
|
||||
|
||||
let had_active_inline_completion = this.has_active_inline_completion();
|
||||
let had_active_edit_prediction = this.has_active_edit_prediction();
|
||||
this.change_selections(
|
||||
SelectionEffects::scroll(Autoscroll::fit()).completions(false),
|
||||
window,
|
||||
|
@ -4264,7 +4263,7 @@ impl Editor {
|
|||
}
|
||||
|
||||
let trigger_in_words =
|
||||
this.show_edit_predictions_in_menu() || !had_active_inline_completion;
|
||||
this.show_edit_predictions_in_menu() || !had_active_edit_prediction;
|
||||
if this.hard_wrap.is_some() {
|
||||
let latest: Range<Point> = this.selections.newest(cx).range();
|
||||
if latest.is_empty()
|
||||
|
@ -4286,7 +4285,7 @@ impl Editor {
|
|||
}
|
||||
this.trigger_completion_on_input(&text, trigger_in_words, window, cx);
|
||||
linked_editing_ranges::refresh_linked_ranges(this, window, cx);
|
||||
this.refresh_inline_completion(true, false, window, cx);
|
||||
this.refresh_edit_prediction(true, false, window, cx);
|
||||
jsx_tag_auto_close::handle_from(this, initial_buffer_versions, window, cx);
|
||||
});
|
||||
}
|
||||
|
@ -4621,7 +4620,7 @@ impl Editor {
|
|||
.collect();
|
||||
|
||||
this.change_selections(Default::default(), window, cx, |s| s.select(new_selections));
|
||||
this.refresh_inline_completion(true, false, window, cx);
|
||||
this.refresh_edit_prediction(true, false, window, cx);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -5669,9 +5668,9 @@ impl Editor {
|
|||
|
||||
crate::hover_popover::hide_hover(editor, cx);
|
||||
if editor.show_edit_predictions_in_menu() {
|
||||
editor.update_visible_inline_completion(window, cx);
|
||||
editor.update_visible_edit_prediction(window, cx);
|
||||
} else {
|
||||
editor.discard_inline_completion(false, cx);
|
||||
editor.discard_edit_prediction(false, cx);
|
||||
}
|
||||
|
||||
cx.notify();
|
||||
|
@ -5682,10 +5681,10 @@ impl Editor {
|
|||
if editor.completion_tasks.len() <= 1 {
|
||||
// If there are no more completion tasks and the last menu was empty, we should hide it.
|
||||
let was_hidden = editor.hide_context_menu(window, cx).is_none();
|
||||
// If it was already hidden and we don't show inline completions in the menu, we should
|
||||
// also show the inline-completion when available.
|
||||
// If it was already hidden and we don't show edit predictions in the menu,
|
||||
// we should also show the edit prediction when available.
|
||||
if was_hidden && editor.show_edit_predictions_in_menu() {
|
||||
editor.update_visible_inline_completion(window, cx);
|
||||
editor.update_visible_edit_prediction(window, cx);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -5779,7 +5778,7 @@ impl Editor {
|
|||
let entries = completions_menu.entries.borrow();
|
||||
let mat = entries.get(item_ix.unwrap_or(completions_menu.selected_item))?;
|
||||
if self.show_edit_predictions_in_menu() {
|
||||
self.discard_inline_completion(true, cx);
|
||||
self.discard_edit_prediction(true, cx);
|
||||
}
|
||||
mat.candidate_id
|
||||
};
|
||||
|
@ -5923,7 +5922,7 @@ impl Editor {
|
|||
})
|
||||
}
|
||||
|
||||
editor.refresh_inline_completion(true, false, window, cx);
|
||||
editor.refresh_edit_prediction(true, false, window, cx);
|
||||
});
|
||||
self.invalidate_autoclose_regions(&self.selections.disjoint_anchors(), &snapshot);
|
||||
|
||||
|
@ -5983,7 +5982,7 @@ impl Editor {
|
|||
let deployed_from = action.deployed_from.clone();
|
||||
let action = action.clone();
|
||||
self.completion_tasks.clear();
|
||||
self.discard_inline_completion(false, cx);
|
||||
self.discard_edit_prediction(false, cx);
|
||||
|
||||
let multibuffer_point = match &action.deployed_from {
|
||||
Some(CodeActionSource::Indicator(row)) | Some(CodeActionSource::RunMenu(row)) => {
|
||||
|
@ -6988,7 +6987,7 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn refresh_inline_completion(
|
||||
pub fn refresh_edit_prediction(
|
||||
&mut self,
|
||||
debounce: bool,
|
||||
user_requested: bool,
|
||||
|
@ -7005,7 +7004,7 @@ impl Editor {
|
|||
self.buffer.read(cx).text_anchor_for_position(cursor, cx)?;
|
||||
|
||||
if !self.edit_predictions_enabled_in_buffer(&buffer, cursor_buffer_position, cx) {
|
||||
self.discard_inline_completion(false, cx);
|
||||
self.discard_edit_prediction(false, cx);
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -7014,11 +7013,11 @@ impl Editor {
|
|||
|| !self.is_focused(window)
|
||||
|| buffer.read(cx).is_empty())
|
||||
{
|
||||
self.discard_inline_completion(false, cx);
|
||||
self.discard_edit_prediction(false, cx);
|
||||
return None;
|
||||
}
|
||||
|
||||
self.update_visible_inline_completion(window, cx);
|
||||
self.update_visible_edit_prediction(window, cx);
|
||||
provider.refresh(
|
||||
self.project.clone(),
|
||||
buffer,
|
||||
|
@ -7056,7 +7055,7 @@ impl Editor {
|
|||
pub fn update_edit_prediction_settings(&mut self, cx: &mut Context<Self>) {
|
||||
if self.edit_prediction_provider.is_none() || DisableAiSettings::get_global(cx).disable_ai {
|
||||
self.edit_prediction_settings = EditPredictionSettings::Disabled;
|
||||
self.discard_inline_completion(false, cx);
|
||||
self.discard_edit_prediction(false, cx);
|
||||
} else {
|
||||
let selection = self.selections.newest_anchor();
|
||||
let cursor = selection.head();
|
||||
|
@ -7077,8 +7076,8 @@ impl Editor {
|
|||
cx: &App,
|
||||
) -> EditPredictionSettings {
|
||||
if !self.mode.is_full()
|
||||
|| !self.show_inline_completions_override.unwrap_or(true)
|
||||
|| self.inline_completions_disabled_in_scope(buffer, buffer_position, cx)
|
||||
|| !self.show_edit_predictions_override.unwrap_or(true)
|
||||
|| self.edit_predictions_disabled_in_scope(buffer, buffer_position, cx)
|
||||
{
|
||||
return EditPredictionSettings::Disabled;
|
||||
}
|
||||
|
@ -7092,8 +7091,8 @@ impl Editor {
|
|||
};
|
||||
|
||||
let by_provider = matches!(
|
||||
self.menu_inline_completions_policy,
|
||||
MenuInlineCompletionsPolicy::ByProvider
|
||||
self.menu_edit_predictions_policy,
|
||||
MenuEditPredictionsPolicy::ByProvider
|
||||
);
|
||||
|
||||
let show_in_menu = by_provider
|
||||
|
@ -7163,7 +7162,7 @@ impl Editor {
|
|||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn cycle_inline_completion(
|
||||
fn cycle_edit_prediction(
|
||||
&mut self,
|
||||
direction: Direction,
|
||||
window: &mut Window,
|
||||
|
@ -7173,28 +7172,28 @@ impl Editor {
|
|||
let cursor = self.selections.newest_anchor().head();
|
||||
let (buffer, cursor_buffer_position) =
|
||||
self.buffer.read(cx).text_anchor_for_position(cursor, cx)?;
|
||||
if self.inline_completions_hidden_for_vim_mode || !self.should_show_edit_predictions() {
|
||||
if self.edit_predictions_hidden_for_vim_mode || !self.should_show_edit_predictions() {
|
||||
return None;
|
||||
}
|
||||
|
||||
provider.cycle(buffer, cursor_buffer_position, direction, cx);
|
||||
self.update_visible_inline_completion(window, cx);
|
||||
self.update_visible_edit_prediction(window, cx);
|
||||
|
||||
Some(())
|
||||
}
|
||||
|
||||
pub fn show_inline_completion(
|
||||
pub fn show_edit_prediction(
|
||||
&mut self,
|
||||
_: &ShowEditPrediction,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if !self.has_active_inline_completion() {
|
||||
self.refresh_inline_completion(false, true, window, cx);
|
||||
if !self.has_active_edit_prediction() {
|
||||
self.refresh_edit_prediction(false, true, window, cx);
|
||||
return;
|
||||
}
|
||||
|
||||
self.update_visible_inline_completion(window, cx);
|
||||
self.update_visible_edit_prediction(window, cx);
|
||||
}
|
||||
|
||||
pub fn display_cursor_names(
|
||||
|
@ -7226,11 +7225,11 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if self.has_active_inline_completion() {
|
||||
self.cycle_inline_completion(Direction::Next, window, cx);
|
||||
if self.has_active_edit_prediction() {
|
||||
self.cycle_edit_prediction(Direction::Next, window, cx);
|
||||
} else {
|
||||
let is_copilot_disabled = self
|
||||
.refresh_inline_completion(false, true, window, cx)
|
||||
.refresh_edit_prediction(false, true, window, cx)
|
||||
.is_none();
|
||||
if is_copilot_disabled {
|
||||
cx.propagate();
|
||||
|
@ -7244,11 +7243,11 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if self.has_active_inline_completion() {
|
||||
self.cycle_inline_completion(Direction::Prev, window, cx);
|
||||
if self.has_active_edit_prediction() {
|
||||
self.cycle_edit_prediction(Direction::Prev, window, cx);
|
||||
} else {
|
||||
let is_copilot_disabled = self
|
||||
.refresh_inline_completion(false, true, window, cx)
|
||||
.refresh_edit_prediction(false, true, window, cx)
|
||||
.is_none();
|
||||
if is_copilot_disabled {
|
||||
cx.propagate();
|
||||
|
@ -7266,18 +7265,14 @@ impl Editor {
|
|||
self.hide_context_menu(window, cx);
|
||||
}
|
||||
|
||||
let Some(active_inline_completion) = self.active_inline_completion.as_ref() else {
|
||||
let Some(active_edit_prediction) = self.active_edit_prediction.as_ref() else {
|
||||
return;
|
||||
};
|
||||
|
||||
self.report_inline_completion_event(
|
||||
active_inline_completion.completion_id.clone(),
|
||||
true,
|
||||
cx,
|
||||
);
|
||||
self.report_edit_prediction_event(active_edit_prediction.completion_id.clone(), true, cx);
|
||||
|
||||
match &active_inline_completion.completion {
|
||||
InlineCompletion::Move { target, .. } => {
|
||||
match &active_edit_prediction.completion {
|
||||
EditPrediction::Move { target, .. } => {
|
||||
let target = *target;
|
||||
|
||||
if let Some(position_map) = &self.last_position_map {
|
||||
|
@ -7319,7 +7314,7 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
}
|
||||
InlineCompletion::Edit { edits, .. } => {
|
||||
EditPrediction::Edit { edits, .. } => {
|
||||
if let Some(provider) = self.edit_prediction_provider() {
|
||||
provider.accept(cx);
|
||||
}
|
||||
|
@ -7347,9 +7342,9 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
|
||||
self.update_visible_inline_completion(window, cx);
|
||||
if self.active_inline_completion.is_none() {
|
||||
self.refresh_inline_completion(true, true, window, cx);
|
||||
self.update_visible_edit_prediction(window, cx);
|
||||
if self.active_edit_prediction.is_none() {
|
||||
self.refresh_edit_prediction(true, true, window, cx);
|
||||
}
|
||||
|
||||
cx.notify();
|
||||
|
@ -7359,27 +7354,23 @@ impl Editor {
|
|||
self.edit_prediction_requires_modifier_in_indent_conflict = false;
|
||||
}
|
||||
|
||||
pub fn accept_partial_inline_completion(
|
||||
pub fn accept_partial_edit_prediction(
|
||||
&mut self,
|
||||
_: &AcceptPartialEditPrediction,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let Some(active_inline_completion) = self.active_inline_completion.as_ref() else {
|
||||
let Some(active_edit_prediction) = self.active_edit_prediction.as_ref() else {
|
||||
return;
|
||||
};
|
||||
if self.selections.count() != 1 {
|
||||
return;
|
||||
}
|
||||
|
||||
self.report_inline_completion_event(
|
||||
active_inline_completion.completion_id.clone(),
|
||||
true,
|
||||
cx,
|
||||
);
|
||||
self.report_edit_prediction_event(active_edit_prediction.completion_id.clone(), true, cx);
|
||||
|
||||
match &active_inline_completion.completion {
|
||||
InlineCompletion::Move { target, .. } => {
|
||||
match &active_edit_prediction.completion {
|
||||
EditPrediction::Move { target, .. } => {
|
||||
let target = *target;
|
||||
self.change_selections(
|
||||
SelectionEffects::scroll(Autoscroll::newest()),
|
||||
|
@ -7390,7 +7381,7 @@ impl Editor {
|
|||
},
|
||||
);
|
||||
}
|
||||
InlineCompletion::Edit { edits, .. } => {
|
||||
EditPrediction::Edit { edits, .. } => {
|
||||
// Find an insertion that starts at the cursor position.
|
||||
let snapshot = self.buffer.read(cx).snapshot(cx);
|
||||
let cursor_offset = self.selections.newest::<usize>(cx).head();
|
||||
|
@ -7424,7 +7415,7 @@ impl Editor {
|
|||
|
||||
self.insert_with_autoindent_mode(&partial_completion, None, window, cx);
|
||||
|
||||
self.refresh_inline_completion(true, true, window, cx);
|
||||
self.refresh_edit_prediction(true, true, window, cx);
|
||||
cx.notify();
|
||||
} else {
|
||||
self.accept_edit_prediction(&Default::default(), window, cx);
|
||||
|
@ -7433,28 +7424,28 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
|
||||
fn discard_inline_completion(
|
||||
fn discard_edit_prediction(
|
||||
&mut self,
|
||||
should_report_inline_completion_event: bool,
|
||||
should_report_edit_prediction_event: bool,
|
||||
cx: &mut Context<Self>,
|
||||
) -> bool {
|
||||
if should_report_inline_completion_event {
|
||||
if should_report_edit_prediction_event {
|
||||
let completion_id = self
|
||||
.active_inline_completion
|
||||
.active_edit_prediction
|
||||
.as_ref()
|
||||
.and_then(|active_completion| active_completion.completion_id.clone());
|
||||
|
||||
self.report_inline_completion_event(completion_id, false, cx);
|
||||
self.report_edit_prediction_event(completion_id, false, cx);
|
||||
}
|
||||
|
||||
if let Some(provider) = self.edit_prediction_provider() {
|
||||
provider.discard(cx);
|
||||
}
|
||||
|
||||
self.take_active_inline_completion(cx)
|
||||
self.take_active_edit_prediction(cx)
|
||||
}
|
||||
|
||||
fn report_inline_completion_event(&self, id: Option<SharedString>, accepted: bool, cx: &App) {
|
||||
fn report_edit_prediction_event(&self, id: Option<SharedString>, accepted: bool, cx: &App) {
|
||||
let Some(provider) = self.edit_prediction_provider() else {
|
||||
return;
|
||||
};
|
||||
|
@ -7485,18 +7476,18 @@ impl Editor {
|
|||
);
|
||||
}
|
||||
|
||||
pub fn has_active_inline_completion(&self) -> bool {
|
||||
self.active_inline_completion.is_some()
|
||||
pub fn has_active_edit_prediction(&self) -> bool {
|
||||
self.active_edit_prediction.is_some()
|
||||
}
|
||||
|
||||
fn take_active_inline_completion(&mut self, cx: &mut Context<Self>) -> bool {
|
||||
let Some(active_inline_completion) = self.active_inline_completion.take() else {
|
||||
fn take_active_edit_prediction(&mut self, cx: &mut Context<Self>) -> bool {
|
||||
let Some(active_edit_prediction) = self.active_edit_prediction.take() else {
|
||||
return false;
|
||||
};
|
||||
|
||||
self.splice_inlays(&active_inline_completion.inlay_ids, Default::default(), cx);
|
||||
self.clear_highlights::<InlineCompletionHighlight>(cx);
|
||||
self.stale_inline_completion_in_menu = Some(active_inline_completion);
|
||||
self.splice_inlays(&active_edit_prediction.inlay_ids, Default::default(), cx);
|
||||
self.clear_highlights::<EditPredictionHighlight>(cx);
|
||||
self.stale_edit_prediction_in_menu = Some(active_edit_prediction);
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -7641,7 +7632,7 @@ impl Editor {
|
|||
since: Instant::now(),
|
||||
};
|
||||
|
||||
self.update_visible_inline_completion(window, cx);
|
||||
self.update_visible_edit_prediction(window, cx);
|
||||
cx.notify();
|
||||
}
|
||||
} else if let EditPredictionPreview::Active {
|
||||
|
@ -7664,12 +7655,12 @@ impl Editor {
|
|||
released_too_fast: since.elapsed() < Duration::from_millis(200),
|
||||
};
|
||||
self.clear_row_highlights::<EditPredictionPreview>();
|
||||
self.update_visible_inline_completion(window, cx);
|
||||
self.update_visible_edit_prediction(window, cx);
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
fn update_visible_inline_completion(
|
||||
fn update_visible_edit_prediction(
|
||||
&mut self,
|
||||
_window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
|
@ -7687,12 +7678,12 @@ impl Editor {
|
|||
let show_in_menu = self.show_edit_predictions_in_menu();
|
||||
let completions_menu_has_precedence = !show_in_menu
|
||||
&& (self.context_menu.borrow().is_some()
|
||||
|| (!self.completion_tasks.is_empty() && !self.has_active_inline_completion()));
|
||||
|| (!self.completion_tasks.is_empty() && !self.has_active_edit_prediction()));
|
||||
|
||||
if completions_menu_has_precedence
|
||||
|| !offset_selection.is_empty()
|
||||
|| self
|
||||
.active_inline_completion
|
||||
.active_edit_prediction
|
||||
.as_ref()
|
||||
.map_or(false, |completion| {
|
||||
let invalidation_range = completion.invalidation_range.to_offset(&multibuffer);
|
||||
|
@ -7700,11 +7691,11 @@ impl Editor {
|
|||
!invalidation_range.contains(&offset_selection.head())
|
||||
})
|
||||
{
|
||||
self.discard_inline_completion(false, cx);
|
||||
self.discard_edit_prediction(false, cx);
|
||||
return None;
|
||||
}
|
||||
|
||||
self.take_active_inline_completion(cx);
|
||||
self.take_active_edit_prediction(cx);
|
||||
let Some(provider) = self.edit_prediction_provider() else {
|
||||
self.edit_prediction_settings = EditPredictionSettings::Disabled;
|
||||
return None;
|
||||
|
@ -7730,8 +7721,8 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
|
||||
let inline_completion = provider.suggest(&buffer, cursor_buffer_position, cx)?;
|
||||
let edits = inline_completion
|
||||
let edit_prediction = provider.suggest(&buffer, cursor_buffer_position, cx)?;
|
||||
let edits = edit_prediction
|
||||
.edits
|
||||
.into_iter()
|
||||
.flat_map(|(range, new_text)| {
|
||||
|
@ -7766,15 +7757,15 @@ impl Editor {
|
|||
None
|
||||
};
|
||||
let is_move =
|
||||
move_invalidation_row_range.is_some() || self.inline_completions_hidden_for_vim_mode;
|
||||
move_invalidation_row_range.is_some() || self.edit_predictions_hidden_for_vim_mode;
|
||||
let completion = if is_move {
|
||||
invalidation_row_range =
|
||||
move_invalidation_row_range.unwrap_or(edit_start_row..edit_end_row);
|
||||
let target = first_edit_start;
|
||||
InlineCompletion::Move { target, snapshot }
|
||||
EditPrediction::Move { target, snapshot }
|
||||
} else {
|
||||
let show_completions_in_buffer = !self.edit_prediction_visible_in_cursor_popover(true)
|
||||
&& !self.inline_completions_hidden_for_vim_mode;
|
||||
&& !self.edit_predictions_hidden_for_vim_mode;
|
||||
|
||||
if show_completions_in_buffer {
|
||||
if edits
|
||||
|
@ -7783,7 +7774,7 @@ impl Editor {
|
|||
{
|
||||
let mut inlays = Vec::new();
|
||||
for (range, new_text) in &edits {
|
||||
let inlay = Inlay::inline_completion(
|
||||
let inlay = Inlay::edit_prediction(
|
||||
post_inc(&mut self.next_inlay_id),
|
||||
range.start,
|
||||
new_text.as_str(),
|
||||
|
@ -7795,7 +7786,7 @@ impl Editor {
|
|||
self.splice_inlays(&[], inlays, cx);
|
||||
} else {
|
||||
let background_color = cx.theme().status().deleted_background;
|
||||
self.highlight_text::<InlineCompletionHighlight>(
|
||||
self.highlight_text::<EditPredictionHighlight>(
|
||||
edits.iter().map(|(range, _)| range.clone()).collect(),
|
||||
HighlightStyle {
|
||||
background_color: Some(background_color),
|
||||
|
@ -7818,9 +7809,9 @@ impl Editor {
|
|||
EditDisplayMode::DiffPopover
|
||||
};
|
||||
|
||||
InlineCompletion::Edit {
|
||||
EditPrediction::Edit {
|
||||
edits,
|
||||
edit_preview: inline_completion.edit_preview,
|
||||
edit_preview: edit_prediction.edit_preview,
|
||||
display_mode,
|
||||
snapshot,
|
||||
}
|
||||
|
@ -7833,11 +7824,11 @@ impl Editor {
|
|||
multibuffer.line_len(MultiBufferRow(invalidation_row_range.end)),
|
||||
));
|
||||
|
||||
self.stale_inline_completion_in_menu = None;
|
||||
self.active_inline_completion = Some(InlineCompletionState {
|
||||
self.stale_edit_prediction_in_menu = None;
|
||||
self.active_edit_prediction = Some(EditPredictionState {
|
||||
inlay_ids,
|
||||
completion,
|
||||
completion_id: inline_completion.id,
|
||||
completion_id: edit_prediction.id,
|
||||
invalidation_range,
|
||||
});
|
||||
|
||||
|
@ -7846,7 +7837,7 @@ impl Editor {
|
|||
Some(())
|
||||
}
|
||||
|
||||
pub fn edit_prediction_provider(&self) -> Option<Arc<dyn InlineCompletionProviderHandle>> {
|
||||
pub fn edit_prediction_provider(&self) -> Option<Arc<dyn EditPredictionProviderHandle>> {
|
||||
Some(self.edit_prediction_provider.as_ref()?.provider.clone())
|
||||
}
|
||||
|
||||
|
@ -8415,14 +8406,14 @@ impl Editor {
|
|||
if self.mode().is_minimap() {
|
||||
return None;
|
||||
}
|
||||
let active_inline_completion = self.active_inline_completion.as_ref()?;
|
||||
let active_edit_prediction = self.active_edit_prediction.as_ref()?;
|
||||
|
||||
if self.edit_prediction_visible_in_cursor_popover(true) {
|
||||
return None;
|
||||
}
|
||||
|
||||
match &active_inline_completion.completion {
|
||||
InlineCompletion::Move { target, .. } => {
|
||||
match &active_edit_prediction.completion {
|
||||
EditPrediction::Move { target, .. } => {
|
||||
let target_display_point = target.to_display_point(editor_snapshot);
|
||||
|
||||
if self.edit_prediction_requires_modifier() {
|
||||
|
@ -8459,11 +8450,11 @@ impl Editor {
|
|||
)
|
||||
}
|
||||
}
|
||||
InlineCompletion::Edit {
|
||||
EditPrediction::Edit {
|
||||
display_mode: EditDisplayMode::Inline,
|
||||
..
|
||||
} => None,
|
||||
InlineCompletion::Edit {
|
||||
EditPrediction::Edit {
|
||||
display_mode: EditDisplayMode::TabAccept,
|
||||
edits,
|
||||
..
|
||||
|
@ -8484,7 +8475,7 @@ impl Editor {
|
|||
cx,
|
||||
)
|
||||
}
|
||||
InlineCompletion::Edit {
|
||||
EditPrediction::Edit {
|
||||
edits,
|
||||
edit_preview,
|
||||
display_mode: EditDisplayMode::DiffPopover,
|
||||
|
@ -8801,7 +8792,7 @@ impl Editor {
|
|||
}
|
||||
|
||||
let highlighted_edits =
|
||||
crate::inline_completion_edit_text(&snapshot, edits, edit_preview.as_ref()?, false, cx);
|
||||
crate::edit_prediction_edit_text(&snapshot, edits, edit_preview.as_ref()?, false, cx);
|
||||
|
||||
let styled_text = highlighted_edits.to_styled_text(&style.text);
|
||||
let line_count = highlighted_edits.text.lines().count();
|
||||
|
@ -9131,7 +9122,7 @@ impl Editor {
|
|||
.child(Icon::new(IconName::ZedPredict))
|
||||
}
|
||||
|
||||
let completion = match &self.active_inline_completion {
|
||||
let completion = match &self.active_edit_prediction {
|
||||
Some(prediction) => {
|
||||
if !self.has_visible_completions_menu() {
|
||||
const RADIUS: Pixels = px(6.);
|
||||
|
@ -9149,7 +9140,7 @@ impl Editor {
|
|||
.rounded_tl(px(0.))
|
||||
.overflow_hidden()
|
||||
.child(div().px_1p5().child(match &prediction.completion {
|
||||
InlineCompletion::Move { target, snapshot } => {
|
||||
EditPrediction::Move { target, snapshot } => {
|
||||
use text::ToPoint as _;
|
||||
if target.text_anchor.to_point(&snapshot).row > cursor_point.row
|
||||
{
|
||||
|
@ -9158,7 +9149,7 @@ impl Editor {
|
|||
Icon::new(IconName::ZedPredictUp)
|
||||
}
|
||||
}
|
||||
InlineCompletion::Edit { .. } => Icon::new(IconName::ZedPredict),
|
||||
EditPrediction::Edit { .. } => Icon::new(IconName::ZedPredict),
|
||||
}))
|
||||
.child(
|
||||
h_flex()
|
||||
|
@ -9217,7 +9208,7 @@ impl Editor {
|
|||
)?
|
||||
}
|
||||
|
||||
None if is_refreshing => match &self.stale_inline_completion_in_menu {
|
||||
None if is_refreshing => match &self.stale_edit_prediction_in_menu {
|
||||
Some(stale_completion) => self.render_edit_prediction_cursor_popover_preview(
|
||||
stale_completion,
|
||||
cursor_point,
|
||||
|
@ -9247,7 +9238,7 @@ impl Editor {
|
|||
completion.into_any_element()
|
||||
};
|
||||
|
||||
let has_completion = self.active_inline_completion.is_some();
|
||||
let has_completion = self.active_edit_prediction.is_some();
|
||||
|
||||
let is_platform_style_mac = PlatformStyle::platform() == PlatformStyle::Mac;
|
||||
Some(
|
||||
|
@ -9306,7 +9297,7 @@ impl Editor {
|
|||
|
||||
fn render_edit_prediction_cursor_popover_preview(
|
||||
&self,
|
||||
completion: &InlineCompletionState,
|
||||
completion: &EditPredictionState,
|
||||
cursor_point: Point,
|
||||
style: &EditorStyle,
|
||||
cx: &mut Context<Editor>,
|
||||
|
@ -9334,7 +9325,7 @@ impl Editor {
|
|||
}
|
||||
|
||||
match &completion.completion {
|
||||
InlineCompletion::Move {
|
||||
EditPrediction::Move {
|
||||
target, snapshot, ..
|
||||
} => Some(
|
||||
h_flex()
|
||||
|
@ -9351,7 +9342,7 @@ impl Editor {
|
|||
.child(Label::new("Jump to Edit")),
|
||||
),
|
||||
|
||||
InlineCompletion::Edit {
|
||||
EditPrediction::Edit {
|
||||
edits,
|
||||
edit_preview,
|
||||
snapshot,
|
||||
|
@ -9359,7 +9350,7 @@ impl Editor {
|
|||
} => {
|
||||
let first_edit_row = edits.first()?.0.start.text_anchor.to_point(&snapshot).row;
|
||||
|
||||
let (highlighted_edits, has_more_lines) = crate::inline_completion_edit_text(
|
||||
let (highlighted_edits, has_more_lines) = crate::edit_prediction_edit_text(
|
||||
&snapshot,
|
||||
&edits,
|
||||
edit_preview.as_ref()?,
|
||||
|
@ -9437,8 +9428,8 @@ impl Editor {
|
|||
cx.notify();
|
||||
self.completion_tasks.clear();
|
||||
let context_menu = self.context_menu.borrow_mut().take();
|
||||
self.stale_inline_completion_in_menu.take();
|
||||
self.update_visible_inline_completion(window, cx);
|
||||
self.stale_edit_prediction_in_menu.take();
|
||||
self.update_visible_edit_prediction(window, cx);
|
||||
if let Some(CodeContextMenu::Completions(_)) = &context_menu {
|
||||
if let Some(completion_provider) = &self.completion_provider {
|
||||
completion_provider.selection_changed(None, window, cx);
|
||||
|
@ -9796,7 +9787,7 @@ impl Editor {
|
|||
this.edit(edits, None, cx);
|
||||
})
|
||||
}
|
||||
this.refresh_inline_completion(true, false, window, cx);
|
||||
this.refresh_edit_prediction(true, false, window, cx);
|
||||
linked_editing_ranges::refresh_linked_ranges(this, window, cx);
|
||||
});
|
||||
}
|
||||
|
@ -9815,7 +9806,7 @@ impl Editor {
|
|||
})
|
||||
});
|
||||
this.insert("", window, cx);
|
||||
this.refresh_inline_completion(true, false, window, cx);
|
||||
this.refresh_edit_prediction(true, false, window, cx);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -9948,7 +9939,7 @@ impl Editor {
|
|||
self.transact(window, cx, |this, window, cx| {
|
||||
this.buffer.update(cx, |b, cx| b.edit(edits, None, cx));
|
||||
this.change_selections(Default::default(), window, cx, |s| s.select(selections));
|
||||
this.refresh_inline_completion(true, false, window, cx);
|
||||
this.refresh_edit_prediction(true, false, window, cx);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -12277,7 +12268,7 @@ impl Editor {
|
|||
}
|
||||
self.request_autoscroll(Autoscroll::fit(), cx);
|
||||
self.unmark_text(window, cx);
|
||||
self.refresh_inline_completion(true, false, window, cx);
|
||||
self.refresh_edit_prediction(true, false, window, cx);
|
||||
cx.emit(EditorEvent::Edited { transaction_id });
|
||||
cx.emit(EditorEvent::TransactionUndone { transaction_id });
|
||||
}
|
||||
|
@ -12307,7 +12298,7 @@ impl Editor {
|
|||
}
|
||||
self.request_autoscroll(Autoscroll::fit(), cx);
|
||||
self.unmark_text(window, cx);
|
||||
self.refresh_inline_completion(true, false, window, cx);
|
||||
self.refresh_edit_prediction(true, false, window, cx);
|
||||
cx.emit(EditorEvent::Edited { transaction_id });
|
||||
}
|
||||
}
|
||||
|
@ -15294,7 +15285,7 @@ impl Editor {
|
|||
])
|
||||
});
|
||||
self.activate_diagnostics(buffer_id, next_diagnostic, window, cx);
|
||||
self.refresh_inline_completion(false, true, window, cx);
|
||||
self.refresh_edit_prediction(false, true, window, cx);
|
||||
}
|
||||
|
||||
pub fn go_to_next_hunk(&mut self, _: &GoToHunk, window: &mut Window, cx: &mut Context<Self>) {
|
||||
|
@ -16258,7 +16249,7 @@ impl Editor {
|
|||
font_weight: Some(FontWeight::BOLD),
|
||||
..make_inlay_hints_style(cx.app)
|
||||
},
|
||||
inline_completion_styles: make_suggestion_styles(
|
||||
edit_prediction_styles: make_suggestion_styles(
|
||||
cx.app,
|
||||
),
|
||||
..EditorStyle::default()
|
||||
|
@ -19032,7 +19023,7 @@ impl Editor {
|
|||
(selection.range(), uuid.to_string())
|
||||
});
|
||||
this.edit(edits, cx);
|
||||
this.refresh_inline_completion(true, false, window, cx);
|
||||
this.refresh_edit_prediction(true, false, window, cx);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -19885,8 +19876,8 @@ impl Editor {
|
|||
self.refresh_selected_text_highlights(true, window, cx);
|
||||
self.refresh_single_line_folds(window, cx);
|
||||
refresh_matching_bracket_highlights(self, window, cx);
|
||||
if self.has_active_inline_completion() {
|
||||
self.update_visible_inline_completion(window, cx);
|
||||
if self.has_active_edit_prediction() {
|
||||
self.update_visible_edit_prediction(window, cx);
|
||||
}
|
||||
if let Some(project) = self.project.as_ref() {
|
||||
if let Some(edited_buffer) = edited_buffer {
|
||||
|
@ -20088,7 +20079,7 @@ impl Editor {
|
|||
}
|
||||
self.tasks_update_task = Some(self.refresh_runnables(window, cx));
|
||||
self.update_edit_prediction_settings(cx);
|
||||
self.refresh_inline_completion(true, false, window, cx);
|
||||
self.refresh_edit_prediction(true, false, window, cx);
|
||||
self.refresh_inline_values(cx);
|
||||
self.refresh_inlay_hints(
|
||||
InlayHintRefreshReason::SettingsChange(inlay_hint_settings(
|
||||
|
@ -20720,7 +20711,7 @@ impl Editor {
|
|||
{
|
||||
self.hide_context_menu(window, cx);
|
||||
}
|
||||
self.discard_inline_completion(false, cx);
|
||||
self.discard_edit_prediction(false, cx);
|
||||
cx.emit(EditorEvent::Blurred);
|
||||
cx.notify();
|
||||
}
|
||||
|
@ -22782,7 +22773,7 @@ impl Render for Editor {
|
|||
syntax: cx.theme().syntax().clone(),
|
||||
status: cx.theme().status().clone(),
|
||||
inlay_hints_style: make_inlay_hints_style(cx),
|
||||
inline_completion_styles: make_suggestion_styles(cx),
|
||||
edit_prediction_styles: make_suggestion_styles(cx),
|
||||
unnecessary_code_fade: ThemeSettings::get_global(cx).unnecessary_code_fade,
|
||||
show_underlines: self.diagnostics_enabled(),
|
||||
},
|
||||
|
@ -23177,7 +23168,7 @@ impl InvalidationRegion for SnippetState {
|
|||
}
|
||||
}
|
||||
|
||||
fn inline_completion_edit_text(
|
||||
fn edit_prediction_edit_text(
|
||||
current_snapshot: &BufferSnapshot,
|
||||
edits: &[(Range<Anchor>, String)],
|
||||
edit_preview: &EditPreview,
|
||||
|
|
|
@ -2,7 +2,7 @@ use super::*;
|
|||
use crate::{
|
||||
JoinLines,
|
||||
code_context_menus::CodeContextMenu,
|
||||
inline_completion_tests::FakeInlineCompletionProvider,
|
||||
edit_prediction_tests::FakeEditPredictionProvider,
|
||||
linked_editing_ranges::LinkedEditingRanges,
|
||||
scroll::scroll_amount::ScrollAmount,
|
||||
test::{
|
||||
|
@ -7251,12 +7251,12 @@ async fn test_undo_format_scrolls_to_last_edit_pos(cx: &mut TestAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_undo_inline_completion_scrolls_to_edit_pos(cx: &mut TestAppContext) {
|
||||
async fn test_undo_edit_prediction_scrolls_to_edit_pos(cx: &mut TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
let mut cx = EditorTestContext::new(cx).await;
|
||||
|
||||
let provider = cx.new(|_| FakeInlineCompletionProvider::default());
|
||||
let provider = cx.new(|_| FakeEditPredictionProvider::default());
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.set_edit_prediction_provider(Some(provider.clone()), window, cx);
|
||||
});
|
||||
|
@ -7279,7 +7279,7 @@ async fn test_undo_inline_completion_scrolls_to_edit_pos(cx: &mut TestAppContext
|
|||
|
||||
cx.update(|_, cx| {
|
||||
provider.update(cx, |provider, _| {
|
||||
provider.set_inline_completion(Some(inline_completion::InlineCompletion {
|
||||
provider.set_edit_prediction(Some(edit_prediction::EditPrediction {
|
||||
id: None,
|
||||
edits: vec![(edit_position..edit_position, "X".into())],
|
||||
edit_preview: None,
|
||||
|
@ -7287,7 +7287,7 @@ async fn test_undo_inline_completion_scrolls_to_edit_pos(cx: &mut TestAppContext
|
|||
})
|
||||
});
|
||||
|
||||
cx.update_editor(|editor, window, cx| editor.update_visible_inline_completion(window, cx));
|
||||
cx.update_editor(|editor, window, cx| editor.update_visible_edit_prediction(window, cx));
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.accept_edit_prediction(&crate::AcceptEditPrediction, window, cx)
|
||||
});
|
||||
|
@ -20552,7 +20552,7 @@ async fn test_multi_buffer_navigation_with_folded_buffers(cx: &mut TestAppContex
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_inline_completion_text(cx: &mut TestAppContext) {
|
||||
async fn test_edit_prediction_text(cx: &mut TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
// Simple insertion
|
||||
|
@ -20651,7 +20651,7 @@ async fn test_inline_completion_text(cx: &mut TestAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_inline_completion_text_with_deletions(cx: &mut TestAppContext) {
|
||||
async fn test_edit_prediction_text_with_deletions(cx: &mut TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
// Deletion
|
||||
|
@ -20741,7 +20741,7 @@ async fn assert_highlighted_edits(
|
|||
.await;
|
||||
|
||||
cx.update(|_window, cx| {
|
||||
let highlighted_edits = inline_completion_edit_text(
|
||||
let highlighted_edits = edit_prediction_edit_text(
|
||||
&snapshot.as_singleton().unwrap().2,
|
||||
&edits,
|
||||
&edit_preview,
|
||||
|
|
|
@ -3,11 +3,11 @@ use crate::{
|
|||
CodeActionSource, ColumnarMode, ConflictsOurs, ConflictsOursMarker, ConflictsOuter,
|
||||
ConflictsTheirs, ConflictsTheirsMarker, ContextMenuPlacement, CursorShape, CustomBlockId,
|
||||
DisplayDiffHunk, DisplayPoint, DisplayRow, DocumentHighlightRead, DocumentHighlightWrite,
|
||||
EditDisplayMode, Editor, EditorMode, EditorSettings, EditorSnapshot, EditorStyle,
|
||||
FILE_HEADER_HEIGHT, FocusedBlock, GutterDimensions, HalfPageDown, HalfPageUp, HandleInput,
|
||||
HoveredCursor, InlayHintRefreshReason, InlineCompletion, JumpData, LineDown, LineHighlight,
|
||||
LineUp, MAX_LINE_LEN, MINIMAP_FONT_SIZE, MULTI_BUFFER_EXCERPT_HEADER_HEIGHT, OpenExcerpts,
|
||||
PageDown, PageUp, PhantomBreakpointIndicator, Point, RowExt, RowRangeExt, SelectPhase,
|
||||
EditDisplayMode, EditPrediction, Editor, EditorMode, EditorSettings, EditorSnapshot,
|
||||
EditorStyle, FILE_HEADER_HEIGHT, FocusedBlock, GutterDimensions, HalfPageDown, HalfPageUp,
|
||||
HandleInput, HoveredCursor, InlayHintRefreshReason, JumpData, LineDown, LineHighlight, LineUp,
|
||||
MAX_LINE_LEN, MINIMAP_FONT_SIZE, MULTI_BUFFER_EXCERPT_HEADER_HEIGHT, OpenExcerpts, PageDown,
|
||||
PageUp, PhantomBreakpointIndicator, Point, RowExt, RowRangeExt, SelectPhase,
|
||||
SelectedTextHighlight, Selection, SelectionDragState, SoftWrap, StickyHeaderExcerpt, ToPoint,
|
||||
ToggleFold, ToggleFoldAll,
|
||||
code_context_menus::{CodeActionsMenu, MENU_ASIDE_MAX_WIDTH, MENU_ASIDE_MIN_WIDTH, MENU_GAP},
|
||||
|
@ -554,7 +554,7 @@ impl EditorElement {
|
|||
register_action(editor, window, Editor::signature_help_next);
|
||||
register_action(editor, window, Editor::next_edit_prediction);
|
||||
register_action(editor, window, Editor::previous_edit_prediction);
|
||||
register_action(editor, window, Editor::show_inline_completion);
|
||||
register_action(editor, window, Editor::show_edit_prediction);
|
||||
register_action(editor, window, Editor::context_menu_first);
|
||||
register_action(editor, window, Editor::context_menu_prev);
|
||||
register_action(editor, window, Editor::context_menu_next);
|
||||
|
@ -562,7 +562,7 @@ impl EditorElement {
|
|||
register_action(editor, window, Editor::display_cursor_names);
|
||||
register_action(editor, window, Editor::unique_lines_case_insensitive);
|
||||
register_action(editor, window, Editor::unique_lines_case_sensitive);
|
||||
register_action(editor, window, Editor::accept_partial_inline_completion);
|
||||
register_action(editor, window, Editor::accept_partial_edit_prediction);
|
||||
register_action(editor, window, Editor::accept_edit_prediction);
|
||||
register_action(editor, window, Editor::restore_file);
|
||||
register_action(editor, window, Editor::git_restore);
|
||||
|
@ -2093,7 +2093,7 @@ impl EditorElement {
|
|||
row_block_types: &HashMap<DisplayRow, bool>,
|
||||
content_origin: gpui::Point<Pixels>,
|
||||
scroll_pixel_position: gpui::Point<Pixels>,
|
||||
inline_completion_popover_origin: Option<gpui::Point<Pixels>>,
|
||||
edit_prediction_popover_origin: Option<gpui::Point<Pixels>>,
|
||||
start_row: DisplayRow,
|
||||
end_row: DisplayRow,
|
||||
line_height: Pixels,
|
||||
|
@ -2210,12 +2210,13 @@ impl EditorElement {
|
|||
cmp::max(padded_line, min_start)
|
||||
};
|
||||
|
||||
let behind_inline_completion_popover = inline_completion_popover_origin
|
||||
.as_ref()
|
||||
.map_or(false, |inline_completion_popover_origin| {
|
||||
(pos_y..pos_y + line_height).contains(&inline_completion_popover_origin.y)
|
||||
});
|
||||
let opacity = if behind_inline_completion_popover {
|
||||
let behind_edit_prediction_popover = edit_prediction_popover_origin.as_ref().map_or(
|
||||
false,
|
||||
|edit_prediction_popover_origin| {
|
||||
(pos_y..pos_y + line_height).contains(&edit_prediction_popover_origin.y)
|
||||
},
|
||||
);
|
||||
let opacity = if behind_edit_prediction_popover {
|
||||
0.5
|
||||
} else {
|
||||
1.0
|
||||
|
@ -2427,9 +2428,9 @@ impl EditorElement {
|
|||
|
||||
let mut padding = INLINE_BLAME_PADDING_EM_WIDTHS;
|
||||
|
||||
if let Some(inline_completion) = editor.active_inline_completion.as_ref() {
|
||||
match &inline_completion.completion {
|
||||
InlineCompletion::Edit {
|
||||
if let Some(edit_prediction) = editor.active_edit_prediction.as_ref() {
|
||||
match &edit_prediction.completion {
|
||||
EditPrediction::Edit {
|
||||
display_mode: EditDisplayMode::TabAccept,
|
||||
..
|
||||
} => padding += INLINE_ACCEPT_SUGGESTION_EM_WIDTHS,
|
||||
|
@ -4086,8 +4087,7 @@ impl EditorElement {
|
|||
|
||||
{
|
||||
let editor = self.editor.read(cx);
|
||||
if editor
|
||||
.edit_prediction_visible_in_cursor_popover(editor.has_active_inline_completion())
|
||||
if editor.edit_prediction_visible_in_cursor_popover(editor.has_active_edit_prediction())
|
||||
{
|
||||
height_above_menu +=
|
||||
editor.edit_prediction_cursor_popover_height() + POPOVER_Y_PADDING;
|
||||
|
@ -6676,14 +6676,14 @@ impl EditorElement {
|
|||
}
|
||||
}
|
||||
|
||||
fn paint_inline_completion_popover(
|
||||
fn paint_edit_prediction_popover(
|
||||
&mut self,
|
||||
layout: &mut EditorLayout,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) {
|
||||
if let Some(inline_completion_popover) = layout.inline_completion_popover.as_mut() {
|
||||
inline_completion_popover.paint(window, cx);
|
||||
if let Some(edit_prediction_popover) = layout.edit_prediction_popover.as_mut() {
|
||||
edit_prediction_popover.paint(window, cx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8501,7 +8501,7 @@ impl Element for EditorElement {
|
|||
)
|
||||
});
|
||||
|
||||
let (inline_completion_popover, inline_completion_popover_origin) = self
|
||||
let (edit_prediction_popover, edit_prediction_popover_origin) = self
|
||||
.editor
|
||||
.update(cx, |editor, cx| {
|
||||
editor.render_edit_prediction_popover(
|
||||
|
@ -8530,7 +8530,7 @@ impl Element for EditorElement {
|
|||
&row_block_types,
|
||||
content_origin,
|
||||
scroll_pixel_position,
|
||||
inline_completion_popover_origin,
|
||||
edit_prediction_popover_origin,
|
||||
start_row,
|
||||
end_row,
|
||||
line_height,
|
||||
|
@ -8919,7 +8919,7 @@ impl Element for EditorElement {
|
|||
cursors,
|
||||
visible_cursors,
|
||||
selections,
|
||||
inline_completion_popover,
|
||||
edit_prediction_popover,
|
||||
diff_hunk_controls,
|
||||
mouse_context_menu,
|
||||
test_indicators,
|
||||
|
@ -9001,7 +9001,7 @@ impl Element for EditorElement {
|
|||
|
||||
self.paint_minimap(layout, window, cx);
|
||||
self.paint_scrollbars(layout, window, cx);
|
||||
self.paint_inline_completion_popover(layout, window, cx);
|
||||
self.paint_edit_prediction_popover(layout, window, cx);
|
||||
self.paint_mouse_context_menu(layout, window, cx);
|
||||
});
|
||||
})
|
||||
|
@ -9102,7 +9102,7 @@ pub struct EditorLayout {
|
|||
expand_toggles: Vec<Option<(AnyElement, gpui::Point<Pixels>)>>,
|
||||
diff_hunk_controls: Vec<AnyElement>,
|
||||
crease_trailers: Vec<Option<CreaseTrailerLayout>>,
|
||||
inline_completion_popover: Option<AnyElement>,
|
||||
edit_prediction_popover: Option<AnyElement>,
|
||||
mouse_context_menu: Option<AnyElement>,
|
||||
tab_invisible: ShapedLine,
|
||||
space_invisible: ShapedLine,
|
||||
|
|
|
@ -907,12 +907,12 @@ mod tests {
|
|||
let inlays = (0..buffer_snapshot.len())
|
||||
.flat_map(|offset| {
|
||||
[
|
||||
Inlay::inline_completion(
|
||||
Inlay::edit_prediction(
|
||||
post_inc(&mut id),
|
||||
buffer_snapshot.anchor_at(offset, Bias::Left),
|
||||
"test",
|
||||
),
|
||||
Inlay::inline_completion(
|
||||
Inlay::edit_prediction(
|
||||
post_inc(&mut id),
|
||||
buffer_snapshot.anchor_at(offset, Bias::Right),
|
||||
"test",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue