@@ -56,6 +56,7 @@ use sum_tree::{Bias, TreeMap};
use text::{BufferId, LineIndent};
use ui::{SharedString, px};
use unicode_segmentation::UnicodeSegmentation;
+use ztracing::instrument;
use std::{
any::TypeId,
@@ -168,6 +169,7 @@ impl DisplayMap {
}
}
+ #[instrument(skip_all)]
pub fn snapshot(&mut self, cx: &mut Context<Self>) -> DisplaySnapshot {
let tab_size = Self::tab_size(&self.buffer, cx);
@@ -195,6 +197,7 @@ impl DisplayMap {
}
}
+ #[instrument(skip_all)]
pub fn set_state(&mut self, other: &DisplaySnapshot, cx: &mut Context<Self>) {
self.fold(
other
@@ -211,6 +214,7 @@ impl DisplayMap {
}
/// Creates folds for the given creases.
+ #[instrument(skip_all)]
pub fn fold<T: Clone + ToOffset>(&mut self, creases: Vec<Crease<T>>, cx: &mut Context<Self>) {
let buffer_snapshot = self.buffer.read(cx).snapshot(cx);
let edits = self.buffer_subscription.consume().into_inner();
@@ -279,6 +283,7 @@ impl DisplayMap {
}
/// Removes any folds with the given ranges.
+ #[instrument(skip_all)]
pub fn remove_folds_with_type<T: ToOffset>(
&mut self,
ranges: impl IntoIterator<Item = Range<T>>,
@@ -304,6 +309,7 @@ impl DisplayMap {
}
/// Removes any folds whose ranges intersect any of the given ranges.
+ #[instrument(skip_all)]
pub fn unfold_intersecting<T: ToOffset>(
&mut self,
ranges: impl IntoIterator<Item = Range<T>>,
@@ -335,6 +341,7 @@ impl DisplayMap {
block_map.remove_intersecting_replace_blocks(offset_ranges, inclusive);
}
+ #[instrument(skip_all)]
pub fn disable_header_for_buffer(&mut self, buffer_id: BufferId, cx: &mut Context<Self>) {
let snapshot = self.buffer.read(cx).snapshot(cx);
let edits = self.buffer_subscription.consume().into_inner();
@@ -349,6 +356,7 @@ impl DisplayMap {
block_map.disable_header_for_buffer(buffer_id)
}
+ #[instrument(skip_all)]
pub fn fold_buffers(
&mut self,
buffer_ids: impl IntoIterator<Item = language::BufferId>,
@@ -367,6 +375,7 @@ impl DisplayMap {
block_map.fold_buffers(buffer_ids, self.buffer.read(cx), cx)
}
+ #[instrument(skip_all)]
pub fn unfold_buffers(
&mut self,
buffer_ids: impl IntoIterator<Item = language::BufferId>,
@@ -385,14 +394,17 @@ impl DisplayMap {
block_map.unfold_buffers(buffer_ids, self.buffer.read(cx), cx)
}
+ #[instrument(skip_all)]
pub(crate) fn is_buffer_folded(&self, buffer_id: language::BufferId) -> bool {
self.block_map.folded_buffers.contains(&buffer_id)
}
+ #[instrument(skip_all)]
pub(crate) fn folded_buffers(&self) -> &HashSet<BufferId> {
&self.block_map.folded_buffers
}
+ #[instrument(skip_all)]
pub fn insert_creases(
&mut self,
creases: impl IntoIterator<Item = Crease<Anchor>>,
@@ -402,6 +414,7 @@ impl DisplayMap {
self.crease_map.insert(creases, &snapshot)
}
+ #[instrument(skip_all)]
pub fn remove_creases(
&mut self,
crease_ids: impl IntoIterator<Item = CreaseId>,
@@ -411,6 +424,7 @@ impl DisplayMap {
self.crease_map.remove(crease_ids, &snapshot)
}
+ #[instrument(skip_all)]
pub fn insert_blocks(
&mut self,
blocks: impl IntoIterator<Item = BlockProperties<Anchor>>,
@@ -429,6 +443,7 @@ impl DisplayMap {
block_map.insert(blocks)
}
+ #[instrument(skip_all)]
pub fn resize_blocks(&mut self, heights: HashMap<CustomBlockId, u32>, cx: &mut Context<Self>) {
let snapshot = self.buffer.read(cx).snapshot(cx);
let edits = self.buffer_subscription.consume().into_inner();
@@ -443,10 +458,12 @@ impl DisplayMap {
block_map.resize(heights);
}
+ #[instrument(skip_all)]
pub fn replace_blocks(&mut self, renderers: HashMap<CustomBlockId, RenderBlock>) {
self.block_map.replace_blocks(renderers);
}
+ #[instrument(skip_all)]
pub fn remove_blocks(&mut self, ids: HashSet<CustomBlockId>, cx: &mut Context<Self>) {
let snapshot = self.buffer.read(cx).snapshot(cx);
let edits = self.buffer_subscription.consume().into_inner();
@@ -461,6 +478,7 @@ impl DisplayMap {
block_map.remove(ids);
}
+ #[instrument(skip_all)]
pub fn row_for_block(
&mut self,
block_id: CustomBlockId,
@@ -480,6 +498,7 @@ impl DisplayMap {
Some(DisplayRow(block_row.0))
}
+ #[instrument(skip_all)]
pub fn highlight_text(
&mut self,
key: HighlightKey,
@@ -507,6 +526,7 @@ impl DisplayMap {
self.text_highlights.insert(key, to_insert);
}
+ #[instrument(skip_all)]
pub(crate) fn highlight_inlays(
&mut self,
type_id: TypeId,
@@ -526,6 +546,7 @@ impl DisplayMap {
}
}
+ #[instrument(skip_all)]
pub fn text_highlights(&self, type_id: TypeId) -> Option<(HighlightStyle, &[Range<Anchor>])> {
let highlights = self.text_highlights.get(&HighlightKey::Type(type_id))?;
Some((highlights.0, &highlights.1))
@@ -538,6 +559,7 @@ impl DisplayMap {
self.text_highlights.values()
}
+ #[instrument(skip_all)]
pub fn clear_highlights(&mut self, type_id: TypeId) -> bool {
let mut cleared = self
.text_highlights
@@ -566,6 +588,7 @@ impl DisplayMap {
.update(cx, |map, cx| map.set_wrap_width(width, cx))
}
+ #[instrument(skip_all)]
pub fn update_fold_widths(
&mut self,
widths: impl IntoIterator<Item = (ChunkRendererId, Pixels)>,
@@ -597,6 +620,7 @@ impl DisplayMap {
self.inlay_map.current_inlays()
}
+ #[instrument(skip_all)]
pub(crate) fn splice_inlays(
&mut self,
to_remove: &[InlayId],
@@ -626,6 +650,7 @@ impl DisplayMap {
self.block_map.read(snapshot, edits);
}
+ #[instrument(skip_all)]
fn tab_size(buffer: &Entity<MultiBuffer>, cx: &App) -> NonZeroU32 {
let buffer = buffer.read(cx).as_singleton().map(|buffer| buffer.read(cx));
let language = buffer
@@ -675,6 +700,7 @@ pub struct HighlightedChunk<'a> {
}
impl<'a> HighlightedChunk<'a> {
+ #[instrument(skip_all)]
fn highlight_invisibles(
self,
editor_style: &'a EditorStyle,
@@ -832,6 +858,7 @@ impl DisplaySnapshot {
self.buffer_snapshot().widest_line_number()
}
+ #[instrument(skip_all)]
pub fn prev_line_boundary(&self, mut point: MultiBufferPoint) -> (Point, DisplayPoint) {
loop {
let mut inlay_point = self.inlay_snapshot().to_inlay_point(point);
@@ -850,6 +877,7 @@ impl DisplaySnapshot {
}
}
+ #[instrument(skip_all)]
pub fn next_line_boundary(
&self,
mut point: MultiBufferPoint,
@@ -888,6 +916,7 @@ impl DisplaySnapshot {
new_start..new_end
}
+ #[instrument(skip_all)]
pub fn point_to_display_point(&self, point: MultiBufferPoint, bias: Bias) -> DisplayPoint {
let inlay_point = self.inlay_snapshot().to_inlay_point(point);
let fold_point = self.fold_snapshot().to_fold_point(inlay_point, bias);
@@ -917,6 +946,7 @@ impl DisplaySnapshot {
.anchor_at(point.to_offset(self, bias), bias)
}
+ #[instrument(skip_all)]
fn display_point_to_inlay_point(&self, point: DisplayPoint, bias: Bias) -> InlayPoint {
let block_point = point.0;
let wrap_point = self.block_snapshot.to_wrap_point(block_point, bias);
@@ -928,6 +958,7 @@ impl DisplaySnapshot {
fold_point.to_inlay_point(self.fold_snapshot())
}
+ #[instrument(skip_all)]
pub fn display_point_to_fold_point(&self, point: DisplayPoint, bias: Bias) -> FoldPoint {
let block_point = point.0;
let wrap_point = self.block_snapshot.to_wrap_point(block_point, bias);
@@ -937,6 +968,7 @@ impl DisplaySnapshot {
.0
}
+ #[instrument(skip_all)]
pub fn fold_point_to_display_point(&self, fold_point: FoldPoint) -> DisplayPoint {
let tab_point = self.tab_snapshot().fold_point_to_tab_point(fold_point);
let wrap_point = self.wrap_snapshot().tab_point_to_wrap_point(tab_point);
@@ -949,6 +981,7 @@ impl DisplaySnapshot {
}
/// Returns text chunks starting at the given display row until the end of the file
+ #[instrument(skip_all)]
pub fn text_chunks(&self, display_row: DisplayRow) -> impl Iterator<Item = &str> {
self.block_snapshot
.chunks(
@@ -961,6 +994,7 @@ impl DisplaySnapshot {
}
/// Returns text chunks starting at the end of the given display row in reverse until the start of the file
+ #[instrument(skip_all)]
pub fn reverse_text_chunks(&self, display_row: DisplayRow) -> impl Iterator<Item = &str> {
(0..=display_row.0).rev().flat_map(move |row| {
self.block_snapshot
@@ -977,6 +1011,7 @@ impl DisplaySnapshot {
})
}
+ #[instrument(skip_all)]
pub fn chunks(
&self,
display_rows: Range<DisplayRow>,
@@ -995,6 +1030,7 @@ impl DisplaySnapshot {
)
}
+ #[instrument(skip_all)]
pub fn highlighted_chunks<'a>(
&'a self,
display_rows: Range<DisplayRow>,
@@ -1071,6 +1107,7 @@ impl DisplaySnapshot {
})
}
+ #[instrument(skip_all)]
pub fn layout_row(
&self,
display_row: DisplayRow,
@@ -1132,6 +1169,7 @@ impl DisplaySnapshot {
layout_line.closest_index_for_x(x) as u32
}
+ #[instrument(skip_all)]
pub fn grapheme_at(&self, mut point: DisplayPoint) -> Option<SharedString> {
point = DisplayPoint(self.block_snapshot.clip_point(point.0, Bias::Left));
let chars = self
@@ -1321,6 +1359,7 @@ impl DisplaySnapshot {
.unwrap_or(false)
}
+ #[instrument(skip_all)]
pub fn crease_for_buffer_row(&self, buffer_row: MultiBufferRow) -> Option<Crease<Point>> {
let start =
MultiBufferPoint::new(buffer_row.0, self.buffer_snapshot().line_len(buffer_row));
@@ -1407,6 +1446,7 @@ impl DisplaySnapshot {
}
#[cfg(any(test, feature = "test-support"))]
+ #[instrument(skip_all)]
pub fn text_highlight_ranges<Tag: ?Sized + 'static>(
&self,
) -> Option<Arc<(HighlightStyle, Vec<Range<Anchor>>)>> {
@@ -1417,6 +1457,7 @@ impl DisplaySnapshot {
}
#[cfg(any(test, feature = "test-support"))]
+ #[instrument(skip_all)]
pub fn all_text_highlight_ranges<Tag: ?Sized + 'static>(
&self,
) -> Vec<(gpui::Hsla, Range<Point>)> {
@@ -1466,6 +1507,7 @@ impl DisplaySnapshot {
///
/// This moves by buffer rows instead of display rows, a distinction that is
/// important when soft wrapping is enabled.
+ #[instrument(skip_all)]
pub fn start_of_relative_buffer_row(&self, point: DisplayPoint, times: isize) -> DisplayPoint {
let start = self.display_point_to_fold_point(point, Bias::Left);
let target = start.row() as isize + times;