mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-07 02:57:34 +00:00
Cleanup the warnings
This commit is contained in:
parent
76d35b7122
commit
e217a95fcc
4 changed files with 26 additions and 37 deletions
|
@ -1169,6 +1169,7 @@ impl FoldOffset {
|
|||
FoldPoint(cursor.start().1.output.lines + overshoot)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn to_inlay_offset(self, snapshot: &FoldSnapshot) -> InlayOffset {
|
||||
let mut cursor = snapshot.transforms.cursor::<(FoldOffset, InlayOffset)>();
|
||||
cursor.seek(&self, Bias::Right, &());
|
||||
|
|
|
@ -13,7 +13,6 @@ use std::{
|
|||
};
|
||||
use sum_tree::{Bias, Cursor, SumTree};
|
||||
use text::Patch;
|
||||
use util::post_inc;
|
||||
|
||||
pub struct InlayMap {
|
||||
snapshot: Mutex<InlaySnapshot>,
|
||||
|
@ -284,10 +283,6 @@ impl InlayPoint {
|
|||
pub fn row(self) -> u32 {
|
||||
self.0.row
|
||||
}
|
||||
|
||||
pub fn column(self) -> u32 {
|
||||
self.0.column
|
||||
}
|
||||
}
|
||||
|
||||
impl InlayMap {
|
||||
|
@ -493,13 +488,14 @@ impl InlayMap {
|
|||
self.sync(buffer_snapshot, buffer_edits)
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
#[cfg(test)]
|
||||
pub(crate) fn randomly_mutate(
|
||||
&mut self,
|
||||
next_inlay_id: &mut usize,
|
||||
rng: &mut rand::rngs::StdRng,
|
||||
) -> (InlaySnapshot, Vec<InlayEdit>) {
|
||||
use rand::prelude::*;
|
||||
use util::post_inc;
|
||||
|
||||
let mut to_remove = Vec::new();
|
||||
let mut to_insert = Vec::new();
|
||||
|
@ -590,11 +586,6 @@ impl InlaySnapshot {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn chars_at(&self, start: InlayPoint) -> impl '_ + Iterator<Item = char> {
|
||||
self.chunks(self.to_offset(start)..self.len(), false, None)
|
||||
.flat_map(|chunk| chunk.text.chars())
|
||||
}
|
||||
|
||||
pub fn to_buffer_point(&self, point: InlayPoint) -> Point {
|
||||
let mut cursor = self.transforms.cursor::<(InlayPoint, Point)>();
|
||||
cursor.seek(&point, Bias::Right, &());
|
||||
|
|
|
@ -55,7 +55,7 @@ use gpui::{
|
|||
use highlight_matching_bracket::refresh_matching_bracket_highlights;
|
||||
use hover_popover::{hide_hover, HoverState};
|
||||
use inlay_cache::{
|
||||
Inlay, InlayCache, InlayFetchRange, InlayId, InlayProperties, InlayRefreshReason, InlaySplice,
|
||||
Inlay, InlayCache, InlayHintQuery, InlayId, InlayProperties, InlayRefreshReason, InlaySplice,
|
||||
};
|
||||
pub use items::MAX_TAB_TITLE_LEN;
|
||||
use itertools::Itertools;
|
||||
|
@ -1302,7 +1302,7 @@ impl Editor {
|
|||
}
|
||||
project_subscriptions.push(cx.subscribe(project, |editor, _, event, cx| {
|
||||
if let project::Event::RefreshInlays = event {
|
||||
editor.refresh_inlays(InlayRefreshReason::OpenExcerptsChange, cx);
|
||||
editor.refresh_inlays(InlayRefreshReason::VisibleExcerptsChange, cx);
|
||||
};
|
||||
}));
|
||||
}
|
||||
|
@ -1382,7 +1382,7 @@ impl Editor {
|
|||
}
|
||||
|
||||
this.report_editor_event("open", None, cx);
|
||||
this.refresh_inlays(InlayRefreshReason::OpenExcerptsChange, cx);
|
||||
this.refresh_inlays(InlayRefreshReason::VisibleExcerptsChange, cx);
|
||||
this
|
||||
}
|
||||
|
||||
|
@ -2615,7 +2615,7 @@ impl Editor {
|
|||
self.splice_inlay_hints(to_remove, to_insert, cx);
|
||||
}
|
||||
InlayRefreshReason::Scroll(scrolled_to) => {
|
||||
let ranges_to_add = self
|
||||
let addition_queries = self
|
||||
.excerpt_visible_offsets(&multi_buffer_handle, cx)
|
||||
.into_iter()
|
||||
.find_map(|(buffer, excerpt_visible_offset_range, excerpt_id)| {
|
||||
|
@ -2623,12 +2623,7 @@ impl Editor {
|
|||
if buffer_id == buffer.read(cx).remote_id()
|
||||
&& scrolled_to.anchor.excerpt_id == excerpt_id
|
||||
{
|
||||
get_inlay_fetch_range(
|
||||
&buffer,
|
||||
excerpt_id,
|
||||
excerpt_visible_offset_range,
|
||||
cx,
|
||||
)
|
||||
inlay_hint_query(&buffer, excerpt_id, excerpt_visible_offset_range, cx)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -2641,9 +2636,11 @@ impl Editor {
|
|||
to_insert,
|
||||
} = editor
|
||||
.update(&mut cx, |editor, cx| {
|
||||
editor
|
||||
.inlay_cache
|
||||
.append_inlays(multi_buffer_handle, ranges_to_add, cx)
|
||||
editor.inlay_cache.append_inlays(
|
||||
multi_buffer_handle,
|
||||
addition_queries,
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await
|
||||
.context("inlay cache hint fetch")?;
|
||||
|
@ -2654,12 +2651,12 @@ impl Editor {
|
|||
})
|
||||
.detach_and_log_err(cx);
|
||||
}
|
||||
InlayRefreshReason::OpenExcerptsChange => {
|
||||
let new_ranges = self
|
||||
InlayRefreshReason::VisibleExcerptsChange => {
|
||||
let replacement_queries = self
|
||||
.excerpt_visible_offsets(&multi_buffer_handle, cx)
|
||||
.into_iter()
|
||||
.filter_map(|(buffer, excerpt_visible_offset_range, excerpt_id)| {
|
||||
get_inlay_fetch_range(&buffer, excerpt_id, excerpt_visible_offset_range, cx)
|
||||
inlay_hint_query(&buffer, excerpt_id, excerpt_visible_offset_range, cx)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
cx.spawn(|editor, mut cx| async move {
|
||||
|
@ -2670,7 +2667,7 @@ impl Editor {
|
|||
.update(&mut cx, |editor, cx| {
|
||||
editor.inlay_cache.replace_inlays(
|
||||
multi_buffer_handle,
|
||||
new_ranges.into_iter(),
|
||||
replacement_queries.into_iter(),
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
|
@ -7355,7 +7352,7 @@ impl Editor {
|
|||
};
|
||||
|
||||
if refresh_inlays {
|
||||
self.refresh_inlays(InlayRefreshReason::OpenExcerptsChange, cx);
|
||||
self.refresh_inlays(InlayRefreshReason::VisibleExcerptsChange, cx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7660,12 +7657,12 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_inlay_fetch_range(
|
||||
fn inlay_hint_query(
|
||||
buffer: &ModelHandle<Buffer>,
|
||||
excerpt_id: ExcerptId,
|
||||
excerpt_visible_offset_range: Range<usize>,
|
||||
cx: &mut ViewContext<'_, '_, Editor>,
|
||||
) -> Option<InlayFetchRange> {
|
||||
) -> Option<InlayHintQuery> {
|
||||
let buffer = buffer.read(cx);
|
||||
let buffer_snapshot = buffer.snapshot();
|
||||
let max_buffer_len = buffer.len();
|
||||
|
@ -7679,7 +7676,7 @@ fn get_inlay_fetch_range(
|
|||
.end
|
||||
.saturating_add(visible_offset_range_len),
|
||||
);
|
||||
Some(InlayFetchRange {
|
||||
Some(InlayHintQuery {
|
||||
buffer_path: buffer_snapshot.resolve_file_path(cx, true)?,
|
||||
buffer_id: buffer.remote_id(),
|
||||
buffer_version: buffer.version().clone(),
|
||||
|
|
|
@ -31,7 +31,7 @@ pub struct InlayProperties<T> {
|
|||
pub enum InlayRefreshReason {
|
||||
SettingsChange(editor_settings::InlayHints),
|
||||
Scroll(ScrollAnchor),
|
||||
OpenExcerptsChange,
|
||||
VisibleExcerptsChange,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
|
@ -89,7 +89,7 @@ pub struct InlaySplice {
|
|||
pub to_insert: Vec<(InlayId, Anchor, InlayHint)>,
|
||||
}
|
||||
|
||||
pub struct InlayFetchRange {
|
||||
pub struct InlayHintQuery {
|
||||
pub buffer_id: u64,
|
||||
pub buffer_path: PathBuf,
|
||||
pub buffer_version: Global,
|
||||
|
@ -109,7 +109,7 @@ impl InlayCache {
|
|||
pub fn append_inlays(
|
||||
&mut self,
|
||||
multi_buffer: ModelHandle<MultiBuffer>,
|
||||
ranges_to_add: impl Iterator<Item = InlayFetchRange>,
|
||||
ranges_to_add: impl Iterator<Item = InlayHintQuery>,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) -> Task<anyhow::Result<InlaySplice>> {
|
||||
self.fetch_inlays(multi_buffer, ranges_to_add, false, cx)
|
||||
|
@ -118,7 +118,7 @@ impl InlayCache {
|
|||
pub fn replace_inlays(
|
||||
&mut self,
|
||||
multi_buffer: ModelHandle<MultiBuffer>,
|
||||
new_ranges: impl Iterator<Item = InlayFetchRange>,
|
||||
new_ranges: impl Iterator<Item = InlayHintQuery>,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) -> Task<anyhow::Result<InlaySplice>> {
|
||||
self.fetch_inlays(multi_buffer, new_ranges, true, cx)
|
||||
|
@ -127,7 +127,7 @@ impl InlayCache {
|
|||
fn fetch_inlays(
|
||||
&mut self,
|
||||
multi_buffer: ModelHandle<MultiBuffer>,
|
||||
inlay_fetch_ranges: impl Iterator<Item = InlayFetchRange>,
|
||||
inlay_fetch_ranges: impl Iterator<Item = InlayHintQuery>,
|
||||
replace_old: bool,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) -> Task<anyhow::Result<InlaySplice>> {
|
||||
|
|
Loading…
Reference in a new issue