Revert useless changes, simplify

This commit is contained in:
Kirill Bulatov 2023-06-26 13:52:09 +03:00
parent f77b680db9
commit 096bad1f73
5 changed files with 30 additions and 50 deletions

View file

@ -10,6 +10,7 @@ doctest = false
[features]
test-support = [
"rand",
"copilot/test-support",
"text/test-support",
"language/test-support",
@ -56,7 +57,7 @@ ordered-float.workspace = true
parking_lot.workspace = true
postage.workspace = true
pulldown-cmark = { version = "0.9.2", default-features = false }
rand = { workspace = true }
rand = { workspace = true, optional = true }
schemars.workspace = true
serde.workspace = true
serde_derive.workspace = true

View file

@ -1,5 +1,4 @@
mod blink_manager;
pub mod display_map;
mod editor_settings;
mod element;
@ -54,7 +53,7 @@ use gpui::{
};
use highlight_matching_bracket::refresh_matching_bracket_highlights;
use hover_popover::{hide_hover, HoverState};
use inlay_hint_cache::{visible_inlay_hints, InlayHintCache, InlaySplice, InvalidationStrategy};
use inlay_hint_cache::{InlayHintCache, InlaySplice, InvalidationStrategy};
pub use items::MAX_TAB_TITLE_LEN;
use itertools::Itertools;
pub use language::{char_kind, CharKind};
@ -2617,7 +2616,7 @@ impl Editor {
let new_splice = self.inlay_hint_cache.update_settings(
&self.buffer,
new_settings,
visible_inlay_hints(self, cx).cloned().collect(),
self.visible_inlay_hints(cx),
cx,
);
if let Some(InlaySplice {
@ -2648,6 +2647,17 @@ impl Editor {
}
}
fn visible_inlay_hints(&self, cx: &ViewContext<'_, '_, Editor>) -> Vec<Inlay> {
self.display_map
.read(cx)
.current_inlays()
.filter(move |inlay| {
Some(inlay.id) != self.copilot_state.suggestion.as_ref().map(|h| h.id)
})
.cloned()
.collect()
}
fn excerpt_visible_offsets(
&self,
cx: &mut ViewContext<'_, '_, Editor>,
@ -5659,7 +5669,6 @@ impl Editor {
}
}
// TODO: Handle selections that cross excerpts
// TODO: Handle selections that cross excerpts
for selection in &mut selections {
let start_column = snapshot.indent_size_for_line(selection.start.row).len;
@ -7257,37 +7266,21 @@ impl Editor {
buffer,
predecessor,
excerpts,
} => {
cx.emit(Event::ExcerptsAdded {
buffer: buffer.clone(),
predecessor: *predecessor,
excerpts: excerpts.clone(),
});
}
} => cx.emit(Event::ExcerptsAdded {
buffer: buffer.clone(),
predecessor: *predecessor,
excerpts: excerpts.clone(),
}),
multi_buffer::Event::ExcerptsRemoved { ids } => {
cx.emit(Event::ExcerptsRemoved { ids: ids.clone() });
}
multi_buffer::Event::Reparsed => {
cx.emit(Event::Reparsed);
}
multi_buffer::Event::DirtyChanged => {
cx.emit(Event::DirtyChanged);
}
multi_buffer::Event::Saved => {
cx.emit(Event::Saved);
}
multi_buffer::Event::FileHandleChanged => {
cx.emit(Event::TitleChanged);
}
multi_buffer::Event::Reloaded => {
cx.emit(Event::TitleChanged);
}
multi_buffer::Event::DiffBaseChanged => {
cx.emit(Event::DiffBaseChanged);
}
multi_buffer::Event::Closed => {
cx.emit(Event::Closed);
cx.emit(Event::ExcerptsRemoved { ids: ids.clone() })
}
multi_buffer::Event::Reparsed => cx.emit(Event::Reparsed),
multi_buffer::Event::DirtyChanged => cx.emit(Event::DirtyChanged),
multi_buffer::Event::Saved => cx.emit(Event::Saved),
multi_buffer::Event::FileHandleChanged => cx.emit(Event::TitleChanged),
multi_buffer::Event::Reloaded => cx.emit(Event::TitleChanged),
multi_buffer::Event::DiffBaseChanged => cx.emit(Event::DiffBaseChanged),
multi_buffer::Event::Closed => cx.emit(Event::Closed),
multi_buffer::Event::DiagnosticsUpdated => {
self.refresh_active_diagnostics(cx);
}

View file

@ -306,7 +306,7 @@ fn spawn_new_update_tasks(
update_cache_version: usize,
cx: &mut ViewContext<'_, '_, Editor>,
) {
let visible_hints = Arc::new(visible_inlay_hints(editor, cx).cloned().collect::<Vec<_>>());
let visible_hints = Arc::new(editor.visible_inlay_hints(cx));
for (excerpt_id, (buffer_handle, excerpt_visible_range)) in excerpts_to_query {
if !excerpt_visible_range.is_empty() {
let buffer = buffer_handle.read(cx);
@ -786,17 +786,6 @@ fn hints_fetch_tasks(
}
}
pub fn visible_inlay_hints<'a, 'b: 'a, 'c, 'd: 'a>(
editor: &'a Editor,
cx: &'b ViewContext<'c, 'd, Editor>,
) -> impl Iterator<Item = &'b Inlay> + 'a {
editor
.display_map
.read(cx)
.current_inlays()
.filter(|inlay| Some(inlay.id) != editor.copilot_state.suggestion.as_ref().map(|h| h.id))
}
fn contains_position(
range: &Range<language::Anchor>,
position: language::Anchor,

View file

@ -2631,7 +2631,6 @@ impl MultiBufferSnapshot {
};
}
}
panic!("excerpt not found")
}