Introduce custom fold placeholders (#12214)

This pull request replaces the static `⋯` character we used to insert
when folding a range with a custom render function that return an
`AnyElement`. We plan to use this in the assistant, but for now this
should be behavior-preserving.

Release Notes:

- N/A

---------

Co-authored-by: Nathan <nathan@zed.dev>
Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
Antonio Scandurra 2024-05-23 23:22:30 +02:00 committed by GitHub
parent e0cfba43aa
commit 57d570c281
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 774 additions and 437 deletions

View file

@ -577,7 +577,7 @@ mod tests {
use crate::{
display_map::Inlay,
test::{editor_test_context::EditorTestContext, marked_display_snapshot},
Buffer, DisplayMap, DisplayRow, ExcerptRange, InlayId, MultiBuffer,
Buffer, DisplayMap, DisplayRow, ExcerptRange, FoldPlaceholder, InlayId, MultiBuffer,
};
use gpui::{font, Context as _};
use language::Capability;
@ -695,8 +695,18 @@ mod tests {
let font_size = px(14.0);
let buffer = MultiBuffer::build_simple(input_text, cx);
let buffer_snapshot = buffer.read(cx).snapshot(cx);
let display_map =
cx.new_model(|cx| DisplayMap::new(buffer, font, font_size, None, 1, 1, cx));
let display_map = cx.new_model(|cx| {
DisplayMap::new(
buffer,
font,
font_size,
None,
1,
1,
FoldPlaceholder::test(),
cx,
)
});
// add all kinds of inlays between two word boundaries: we should be able to cross them all, when looking for another boundary
let mut id = 0;
@ -901,8 +911,18 @@ mod tests {
);
multibuffer
});
let display_map =
cx.new_model(|cx| DisplayMap::new(multibuffer, font, px(14.0), None, 2, 2, cx));
let display_map = cx.new_model(|cx| {
DisplayMap::new(
multibuffer,
font,
px(14.0),
None,
2,
2,
FoldPlaceholder::test(),
cx,
)
});
let snapshot = display_map.update(cx, |map, cx| map.snapshot(cx));
assert_eq!(snapshot.text(), "\n\nabc\ndefg\n\n\nhijkl\nmn");