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