Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed Dec 17, 2024
1 parent 062b4a2 commit 7adcf90
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 24 deletions.
6 changes: 6 additions & 0 deletions crates/editor/src/display_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
46 changes: 36 additions & 10 deletions crates/editor/src/display_map/block_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand All @@ -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::<Vec<_>>(),
blocks_snapshot
.row_infos(BlockRow(0))
.map(|i| i.buffer_row)
.collect::<Vec<_>>(),
vec![
None,
None,
Expand Down Expand Up @@ -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::<Vec<_>>(),
blocks_snapshot
.row_infos(BlockRow(0))
.map(|i| i.buffer_row)
.collect::<Vec<_>>(),
vec![
None,
None,
Expand Down Expand Up @@ -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::<Vec<_>>(),
blocks_snapshot
.row_infos(BlockRow(0))
.map(|i| i.buffer_row)
.collect::<Vec<_>>(),
vec![
None,
None,
Expand Down Expand Up @@ -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::<Vec<_>>(),
blocks_snapshot
.row_infos(BlockRow(0))
.map(|i| i.buffer_row)
.collect::<Vec<_>>(),
vec![
None,
None,
Expand Down Expand Up @@ -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::<Vec<_>>(),
blocks_snapshot
.row_infos(BlockRow(0))
.map(|i| i.buffer_row)
.collect::<Vec<_>>(),
vec![
None,
None,
Expand Down Expand Up @@ -2879,7 +2895,10 @@ mod tests {
"Should have a single, first buffer left after folding"
);
assert_eq!(
blocks_snapshot.buffer_rows(BlockRow(0)).collect::<Vec<_>>(),
blocks_snapshot
.row_infos(BlockRow(0))
.map(|i| i.buffer_row)
.collect::<Vec<_>>(),
vec![
None,
None,
Expand Down Expand Up @@ -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) =
Expand Down Expand Up @@ -2949,7 +2969,10 @@ mod tests {
);
assert_eq!(blocks_snapshot.text(), "\n");
assert_eq!(
blocks_snapshot.buffer_rows(BlockRow(0)).collect::<Vec<_>>(),
blocks_snapshot
.row_infos(BlockRow(0))
.map(|i| i.buffer_row)
.collect::<Vec<_>>(),
vec![None, None],
"When fully folded, should be no buffer rows"
);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions crates/editor/src/display_map/diff_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
9 changes: 1 addition & 8 deletions crates/editor/src/display_map/inlay_map.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 1 addition & 3 deletions crates/editor/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
{
Expand Down
1 change: 1 addition & 0 deletions crates/multi_buffer/src/multi_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,7 @@ impl MultiBuffer {
}
ranges
}

pub fn excerpt_ranges_for_buffer(
&self,
buffer_id: BufferId,
Expand Down

0 comments on commit 7adcf90

Please sign in to comment.