Skip to content

Commit

Permalink
Initial addition of multibuffer footers
Browse files Browse the repository at this point in the history
  • Loading branch information
mikayla-maki committed Apr 24, 2024
1 parent 53f67a8 commit cf93a26
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 99 deletions.
3 changes: 3 additions & 0 deletions crates/diagnostics/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1647,11 +1647,14 @@ mod tests {
starts_new_buffer, ..
} => {
if *starts_new_buffer {
// TODO change wording
"path header block".into()
} else {
// TODO change wording
"collapsed context".into()
}
}
TransformBlock::ExcerptFooter { .. } => "excerpt footer".into(),
};

Some((row, name))
Expand Down
63 changes: 54 additions & 9 deletions crates/editor/src/display_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl DisplayMap {
wrap_width: Option<Pixels>,
buffer_header_height: u8,
excerpt_header_height: u8,
excerpt_footer_height: u8,
cx: &mut ModelContext<Self>,
) -> Self {
let buffer_subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
Expand All @@ -107,7 +108,12 @@ impl DisplayMap {
let (fold_map, snapshot) = FoldMap::new(snapshot);
let (tab_map, snapshot) = TabMap::new(snapshot, tab_size);
let (wrap_map, snapshot) = WrapMap::new(snapshot, font, font_size, wrap_width, cx);
let block_map = BlockMap::new(snapshot, buffer_header_height, excerpt_header_height);
let block_map = BlockMap::new(
snapshot,
buffer_header_height,
excerpt_header_height,
excerpt_footer_height,
);
cx.observe(&wrap_map, |_, _, cx| cx.notify()).detach();
DisplayMap {
buffer,
Expand Down Expand Up @@ -1033,6 +1039,7 @@ pub mod tests {
wrap_width,
buffer_start_excerpt_header_height,
excerpt_header_height,
0,
cx,
)
});
Expand Down Expand Up @@ -1273,6 +1280,7 @@ pub mod tests {
wrap_width,
1,
1,
0,
cx,
)
});
Expand Down Expand Up @@ -1373,7 +1381,16 @@ pub mod tests {

let font_size = px(14.0);
let map = cx.new_model(|cx| {
DisplayMap::new(buffer.clone(), font("Helvetica"), font_size, None, 1, 1, cx)
DisplayMap::new(
buffer.clone(),
font("Helvetica"),
font_size,
None,
1,
1,
0,
cx,
)
});

buffer.update(cx, |buffer, cx| {
Expand Down Expand Up @@ -1450,8 +1467,9 @@ pub mod tests {

let font_size = px(14.0);

let map = cx
.new_model(|cx| DisplayMap::new(buffer, font("Helvetica"), font_size, None, 1, 1, cx));
let map = cx.new_model(|cx| {
DisplayMap::new(buffer, font("Helvetica"), font_size, None, 1, 1, 0, cx)
});
assert_eq!(
cx.update(|cx| syntax_chunks(0..5, &map, &theme, cx)),
vec![
Expand Down Expand Up @@ -1536,7 +1554,16 @@ pub mod tests {
let font_size = px(16.0);

let map = cx.new_model(|cx| {
DisplayMap::new(buffer, font("Courier"), font_size, Some(px(40.0)), 1, 1, cx)
DisplayMap::new(
buffer,
font("Courier"),
font_size,
Some(px(40.0)),
1,
1,
0,
cx,
)
});
assert_eq!(
cx.update(|cx| syntax_chunks(0..5, &map, &theme, cx)),
Expand Down Expand Up @@ -1602,8 +1629,8 @@ pub mod tests {
let buffer_snapshot = buffer.read_with(cx, |buffer, cx| buffer.snapshot(cx));

let font_size = px(16.0);
let map =
cx.new_model(|cx| DisplayMap::new(buffer, font("Courier"), font_size, None, 1, 1, cx));
let map = cx
.new_model(|cx| DisplayMap::new(buffer, font("Courier"), font_size, None, 1, 1, 0, cx));

enum MyType {}

Expand Down Expand Up @@ -1718,7 +1745,16 @@ pub mod tests {
let font_size = px(14.0);

let map = cx.new_model(|cx| {
DisplayMap::new(buffer.clone(), font("Helvetica"), font_size, None, 1, 1, cx)
DisplayMap::new(
buffer.clone(),
font("Helvetica"),
font_size,
None,
1,
1,
0,
cx,
)
});
let map = map.update(cx, |map, cx| map.snapshot(cx));
assert_eq!(map.text(), "✅ α\nβ \n🏀β γ");
Expand Down Expand Up @@ -1772,7 +1808,16 @@ pub mod tests {
let buffer = MultiBuffer::build_simple("aaa\n\t\tbbb", cx);
let font_size = px(14.0);
let map = cx.new_model(|cx| {
DisplayMap::new(buffer.clone(), font("Helvetica"), font_size, None, 1, 1, cx)
DisplayMap::new(
buffer.clone(),
font("Helvetica"),
font_size,
None,
1,
1,
0,
cx,
)
});
assert_eq!(
map.update(cx, |map, cx| map.snapshot(cx)).max_point(),
Expand Down

0 comments on commit cf93a26

Please sign in to comment.