From 7adcf903cccbf0a6373bd73128819725635771ee Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 17 Dec 2024 14:55:25 -0700 Subject: [PATCH] fix merge conflicts --- crates/editor/src/display_map.rs | 6 +++ crates/editor/src/display_map/block_map.rs | 46 +++++++++++++++++----- crates/editor/src/display_map/diff_map.rs | 4 +- crates/editor/src/display_map/inlay_map.rs | 9 +---- crates/editor/src/editor.rs | 2 +- crates/editor/src/element.rs | 4 +- crates/multi_buffer/src/multi_buffer.rs | 1 + 7 files changed, 48 insertions(+), 24 deletions(-) diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index 79054688c7d26..58d1b2f4f06ce 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -368,6 +368,9 @@ impl DisplayMap { let snapshot = self.buffer.read(cx).snapshot(cx); let edits = self.buffer_subscription.consume().into_inner(); let tab_size = Self::tab_size(&self.buffer, cx); + let (snapshot, edits) = self + .diff_map + .update(cx, |diff_map, cx| diff_map.sync(snapshot, edits, cx)); let (snapshot, edits) = self.inlay_map.sync(snapshot, edits); let (snapshot, edits) = self.fold_map.read(snapshot, edits); let (snapshot, edits) = self.tab_map.sync(snapshot, edits, tab_size); @@ -382,6 +385,9 @@ impl DisplayMap { let snapshot = self.buffer.read(cx).snapshot(cx); let edits = self.buffer_subscription.consume().into_inner(); let tab_size = Self::tab_size(&self.buffer, cx); + let (snapshot, edits) = self + .diff_map + .update(cx, |diff_map, cx| diff_map.sync(snapshot, edits, cx)); let (snapshot, edits) = self.inlay_map.sync(snapshot, edits); let (snapshot, edits) = self.fold_map.read(snapshot, edits); let (snapshot, edits) = self.tab_map.sync(snapshot, edits, tab_size); diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index 40e138f6804c0..8648f6aab4029 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -2542,7 +2542,8 @@ mod tests { let buffer_id_2 = buffer_ids[1]; let buffer_id_3 = buffer_ids[2]; - let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone()); + let (_, diff_snapshot) = cx.update(|cx| DiffMap::new(buffer.clone(), cx)); + let (_, inlay_snapshot) = InlayMap::new(diff_snapshot.clone()); let (_, fold_snapshot) = FoldMap::new(inlay_snapshot); let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap()); let (_, wrap_snapshot) = @@ -2555,7 +2556,10 @@ mod tests { "\n\n\n111\n\n\n\n\n222\n\n\n333\n\n\n444\n\n\n\n\n555\n\n\n666\n" ); assert_eq!( - blocks_snapshot.buffer_rows(BlockRow(0)).collect::>(), + blocks_snapshot + .row_infos(BlockRow(0)) + .map(|i| i.buffer_row) + .collect::>(), vec![ None, None, @@ -2631,7 +2635,10 @@ mod tests { "\n\n\n111\n\n\n\n\n\n222\n\n\n\n333\n\n\n444\n\n\n\n\n\n\n555\n\n\n666\n\n" ); assert_eq!( - blocks_snapshot.buffer_rows(BlockRow(0)).collect::>(), + blocks_snapshot + .row_infos(BlockRow(0)) + .map(|i| i.buffer_row) + .collect::>(), vec![ None, None, @@ -2706,7 +2713,10 @@ mod tests { "\n\n\n\n\n\n222\n\n\n\n333\n\n\n444\n\n\n\n\n\n\n555\n\n\n666\n\n" ); assert_eq!( - blocks_snapshot.buffer_rows(BlockRow(0)).collect::>(), + blocks_snapshot + .row_infos(BlockRow(0)) + .map(|i| i.buffer_row) + .collect::>(), vec![ None, None, @@ -2771,7 +2781,10 @@ mod tests { ); assert_eq!(blocks_snapshot.text(), "\n\n\n\n\n\n\n\n555\n\n\n666\n\n"); assert_eq!( - blocks_snapshot.buffer_rows(BlockRow(0)).collect::>(), + blocks_snapshot + .row_infos(BlockRow(0)) + .map(|i| i.buffer_row) + .collect::>(), vec![ None, None, @@ -2825,7 +2838,10 @@ mod tests { "Should have extra newline for 111 buffer, due to a new block added when it was folded" ); assert_eq!( - blocks_snapshot.buffer_rows(BlockRow(0)).collect::>(), + blocks_snapshot + .row_infos(BlockRow(0)) + .map(|i| i.buffer_row) + .collect::>(), vec![ None, None, @@ -2879,7 +2895,10 @@ mod tests { "Should have a single, first buffer left after folding" ); assert_eq!( - blocks_snapshot.buffer_rows(BlockRow(0)).collect::>(), + blocks_snapshot + .row_infos(BlockRow(0)) + .map(|i| i.buffer_row) + .collect::>(), vec![ None, None, @@ -2913,7 +2932,8 @@ mod tests { assert_eq!(buffer_ids.len(), 1); let buffer_id = buffer_ids[0]; - let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone()); + let (_, diff_snapshot) = cx.update(|cx| DiffMap::new(buffer.clone(), cx)); + let (_, inlay_snapshot) = InlayMap::new(diff_snapshot.clone()); let (_, fold_snapshot) = FoldMap::new(inlay_snapshot); let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap()); let (_, wrap_snapshot) = @@ -2949,7 +2969,10 @@ mod tests { ); assert_eq!(blocks_snapshot.text(), "\n"); assert_eq!( - blocks_snapshot.buffer_rows(BlockRow(0)).collect::>(), + blocks_snapshot + .row_infos(BlockRow(0)) + .map(|i| i.buffer_row) + .collect::>(), vec![None, None], "When fully folded, should be no buffer rows" ); @@ -3117,8 +3140,11 @@ mod tests { log::info!("Noop fold/unfold operation on a singleton buffer"); continue; } + let (diff_snapshot, diff_edits) = diff_map.update(cx, |diff_map, cx| { + diff_map.sync(buffer_snapshot.clone(), vec![], cx) + }); let (inlay_snapshot, inlay_edits) = - inlay_map.sync(buffer_snapshot.clone(), vec![]); + inlay_map.sync(diff_snapshot.clone(), diff_edits); let (fold_snapshot, fold_edits) = fold_map.read(inlay_snapshot, inlay_edits); let (tab_snapshot, tab_edits) = tab_map.sync(fold_snapshot, fold_edits, tab_size); diff --git a/crates/editor/src/display_map/diff_map.rs b/crates/editor/src/display_map/diff_map.rs index a494a2de99330..0c4c32e67e0f2 100644 --- a/crates/editor/src/display_map/diff_map.rs +++ b/crates/editor/src/display_map/diff_map.rs @@ -1134,11 +1134,11 @@ impl DiffMapSnapshot { let diff_anchor_a = a.diff_base_anchor.unwrap(); let diff_anchor_b = b.diff_base_anchor.unwrap(); - if diff_anchor_a.buffer_id != diff_anchor_b.buffer_id { + if diff_anchor_a.buffer_id != diff_anchor_b.buffer_id || diff_anchor_a.buffer_id.is_none() { return std::cmp::Ordering::Equal; } - let Some(diff_base_snapshot) = self.diffs.get(diff_anchor_a.buffer_id) else { + let Some(diff_base_snapshot) = self.diffs.get(&diff_anchor_a.buffer_id.unwrap()) else { return std::cmp::Ordering::Equal; }; diff --git a/crates/editor/src/display_map/inlay_map.rs b/crates/editor/src/display_map/inlay_map.rs index 6403f06d48d85..bbf1270d9df5c 100644 --- a/crates/editor/src/display_map/inlay_map.rs +++ b/crates/editor/src/display_map/inlay_map.rs @@ -1,21 +1,14 @@ use crate::{HighlightStyles, InlayId, RowInfo}; use collections::BTreeSet; use language::{Chunk, Edit, Point, TextSummary}; -use multi_buffer::{Anchor, MultiBufferRow, MultiBufferRows, MultiBufferSnapshot, ToOffset}; +use multi_buffer::{Anchor, MultiBufferSnapshot, ToOffset}; use std::{ cmp, ops::{Add, AddAssign, Range, Sub, SubAssign}, }; -use std::{ - cmp, - ops::{Add, AddAssign, Range, Sub, SubAssign}, -}; -use sum_tree::{Bias, Cursor, SumTree}; use sum_tree::{Bias, Cursor, SumTree}; use text::{Patch, Rope}; -use text::{Patch, Rope}; -use super::{custom_highlights::CustomHighlightsChunks, Highlights}; use super::{ diff_map::{DiffEdit, DiffMapChunks, DiffMapRows, DiffMapSnapshot, DiffOffset, DiffPoint}, Highlights, diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index fc888a1251bfc..207f5823b9f0e 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -5085,7 +5085,7 @@ impl Editor { })) } - #[cfg(feature = "test-support")] + #[cfg(any(test, feature = "test-support"))] pub fn context_menu_visible(&self) -> bool { self.context_menu .borrow() diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 4d640d9748c71..3d7caf9926668 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -22,7 +22,7 @@ use crate::{ EditorSnapshot, EditorStyle, ExpandExcerpts, FocusedBlock, GutterDimensions, HalfPageDown, HalfPageUp, HandleInput, HoveredCursor, HoveredHunk, InlineCompletion, JumpData, LineDown, LineUp, OpenExcerpts, PageDown, PageUp, Point, RowExt, RowInfo, RowRangeExt, SelectPhase, - Selection, SoftWrap, ToPoint, CURSORS_VISIBLE_FOR, FILE_HEADER_HEIGHT, + Selection, SoftWrap, ToPoint, ToggleFold, CURSORS_VISIBLE_FOR, FILE_HEADER_HEIGHT, GIT_BLAME_MAX_AUTHOR_CHARS_DISPLAYED, MAX_LINE_LEN, MULTI_BUFFER_EXCERPT_HEADER_HEIGHT, }; use client::ParticipantIndex; @@ -6199,8 +6199,6 @@ impl Element for EditorElement { if show_code_actions { let newest_selection_point = newest_selection_head.to_point(&snapshot.display_snapshot); - let newest_selection_display_row = - newest_selection_point.to_display_point(&snapshot).row(); if !snapshot .is_line_folded(MultiBufferRow(newest_selection_point.row)) { diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index cdcdd726131dc..f840dc4357c0c 100644 --- a/crates/multi_buffer/src/multi_buffer.rs +++ b/crates/multi_buffer/src/multi_buffer.rs @@ -1576,6 +1576,7 @@ impl MultiBuffer { } ranges } + pub fn excerpt_ranges_for_buffer( &self, buffer_id: BufferId,